- if (image->byte_order != image->bitmap_bit_order)
- return (GetImagePixels(image, width, height, pmap));
- else {
- data = image->data;
- iptr = pmap->pixelindex;
- if (image->bitmap_bit_order == MSBFirst)
- for (y = 0; y < height; y++)
- for (x = 0; x < width; x++, iptr++) {
- pixel = (data[ZINDEX1(x, y, image)] & (0x80 >> (x & 7)))
- ? 1 : 0;
- if ((*storeFunc) (pixel, pmap, iptr))
- return (XpmNoMemory);
- }
- else
- for (y = 0; y < height; y++)
- for (x = 0; x < width; x++, iptr++) {
- pixel = (data[ZINDEX1(x, y, image)] & (1 << (x & 7)))
- ? 1 : 0;
- if ((*storeFunc) (pixel, pmap, iptr))
- return (XpmNoMemory);
- }
- }
+ data = image->data;
+ iptr = pmap->pixelindex;
+ offset = image->xoffset;
+ bpl = image->bytes_per_line;
+
+ if (image->bitmap_bit_order == MSBFirst)
+ for (y = 0; y < height; y++)
+ for (x = 0; x < width; x++, iptr++) {
+ xoff = x + offset;
+ yoff = y * bpl + (xoff >> 3);
+ xoff &= 7;
+ pixel = (data[yoff] & (0x80 >> xoff)) ? 1 : 0;
+ if ((*storeFunc) (pixel, pmap, iptr))
+ return (XpmNoMemory);
+ }
+ else
+ for (y = 0; y < height; y++)
+ for (x = 0; x < width; x++, iptr++) {
+ xoff = x + offset;
+ yoff = y * bpl + (xoff >> 3);
+ xoff &= 7;
+ pixel = (data[yoff] & (1 << xoff)) ? 1 : 0;
+ if ((*storeFunc) (pixel, pmap, iptr))
+ return (XpmNoMemory);
+ }