I've got some very large bitmap files (1 bpp), and the code seems awfully slow and convoluted. This is the code segment that just takes forever (from the ReadBMPImage() function in bmp.c):
Code: Select all
switch (bmp_info.bits_per_pixel)
{
case 1:
{
/*
Convert bitmap scanline.
*/
for (y=(long) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=SetImagePixels(image,0,y,image->columns,1);
if (q == (PixelPacket *) NULL)
break;
indexes=GetIndexes(image);
for (x=0; x < ((long) image->columns-7); x+=8)
{
for (bit=0; bit < 8; bit++)
{
index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
indexes[x+bit]=index;
*q++=image->colormap[(long) index];
}
p++;
}
if ((image->columns % 8) != 0)
{
for (bit=0; bit < (image->columns % 8); bit++)
{
index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
indexes[x+bit]=index;
*q++=image->colormap[(long) index];
}
p++;
}
if (SyncImagePixels(image) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
(QuantumTick(y,image->rows) != MagickFalse))
{
status=image->progress_monitor(LoadImageTag,y,image->rows,
image->client_data);
if (status == MagickFalse)
break;
}
}
break;
}
My file has these details (from identify):
Image: C:\testing\BMP\DIB135.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: PseudoClass
Geometry: 27543x14158+0+0
Type: Bilevel
Endianess: Undefined
Colorspace: Gray
Channel depth:
Gray: 1-bit
Channel statistics:
Gray:
Min: 0 (0)
Max: 1 (1)
Mean: 0.761977 (0.761977)
Standard deviation: 0.425873 (0.425873)
Colors: 2
Histogram:
92818039: #000000 black
297135755: #FFFFFF white
Colormap: 2
0: #000000 black
1: #FFFFFF white
Rendering intent: Undefined
Resolution: 28.34x28.34
Units: PixelsPerCentimeter
Filesize: 46.5014mb
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Page geometry: 27543x14158+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Signature: 818b67524accbaeec8646570dd052cf6b80661cc1ee45c6b218459f26929c686
Tainted: False
User time: 14.375u
Elapsed time: 6:34
Pixels per second: 1.11629mb
Version: ImageMagick 6.3.3 03/10/07 Q8 http://www.imagemagick.org
ftp://ftp.cadlink.com/pub/ImageMagick_/DIB135.bmp
Any ideas/help would be GREATLY appreciated!
Thanks,
sanderton