X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/16a12a3d27d3d3e2557bcde15365245ef2675bb4..c0f09a2e88168989a36c53e95ed225e2cf3f9ff0:/src/xpm/scan.c?ds=sidebyside diff --git a/src/xpm/scan.c b/src/xpm/scan.c index 16c1d2e674..8660ff99ed 100644 --- a/src/xpm/scan.c +++ b/src/xpm/scan.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1989-94 GROUPE BULL + * Copyright (C) 1989-95 GROUPE BULL * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -37,7 +37,12 @@ * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 */ -#include "xpm34p.h" +/* + * The code related to AMIGA has been added by + * Lorens Younes (d93-hyo@nada.kth.se) 4/96 + */ + +#include "XpmI.h" #define MAXPRINTABLE 92 /* number of printable ascii chars * minus \ and " for string compat @@ -69,6 +74,7 @@ LFUNC(storeMaskPixel, int, (Pixel pixel, PixelsMap *pmap, unsigned int *index_return)); #ifndef FOR_MSW +# ifndef AMIGA LFUNC(GetImagePixels, int, (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)); @@ -83,16 +89,16 @@ LFUNC(GetImagePixels8, int, (XImage *image, unsigned int width, LFUNC(GetImagePixels1, int, (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap, - int (*storeFunc) (Pixel,PixelsMap*, - unsigned int*))); - -/* int (*storeFunc) ())); -*/ - +# else /* AMIGA */ +LFUNC(AGetImagePixels, int, (XImage *image, unsigned int width, + unsigned int height, PixelsMap *pmap, + int (*storeFunc) ())); +# endif/* AMIGA */ #else /* ndef FOR_MSW */ LFUNC(MSWGetImagePixels, int, (Display *d, XImage *image, unsigned int width, - unsigned int height, PixelsMap *pmap)); + unsigned int height, PixelsMap *pmap, + int (*storeFunc) ())); #endif LFUNC(ScanTransparentColor, int, (XpmColor *color, unsigned int cpp, XpmAttributes *attributes)); @@ -105,8 +111,16 @@ LFUNC(ScanOtherColors, int, (Display *display, XpmColor *colors, int ncolors, * This function stores the given pixel in the given arrays which are grown * if not large enough. */ +#ifdef __OS2__ +/* Visual Age cannot deal with old, non-ansi, code */ +static int storePixel(Pixel pixel, PixelsMap* pmap, unsigned int* index_return) +#else static int -storePixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return) +storePixel(pixel, pmap, index_return) + Pixel pixel; + PixelsMap *pmap; + unsigned int *index_return; +#endif { unsigned int i; Pixel *p; @@ -137,8 +151,16 @@ storePixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return) return 0; } +#ifdef __OS2__ +/* Visual Age cannot deal with old, non-ansi, code */ +static int storeMaskPixel(Pixel pixel, PixelsMap* pmap, unsigned int* index_return) +#else static int -storeMaskPixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return) +storeMaskPixel(pixel, pmap, index_return) + Pixel pixel; + PixelsMap *pmap; + unsigned int *index_return; +#endif { if (!pixel) { if (!pmap->ncolors) { @@ -152,23 +174,37 @@ storeMaskPixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return) return 0; } -/* function call in case of error, frees only locally allocated variables */ +/* function call in case of error */ #undef RETURN #define RETURN(status) \ { \ - if (pmap.pixelindex) XpmFree(pmap.pixelindex); \ - if (pmap.pixels) XpmFree(pmap.pixels); \ - if (colorTable) xpmFreeColorTable(colorTable, pmap.ncolors); \ - return(status); \ + ErrorStatus = status; \ + goto error; \ } /* * This function scans the given image and stores the found informations in * the given XpmImage structure. */ +#ifdef __OS2__ +/* Visual Age cannot deal with old, non-ansi, code */ +int XpmCreateXpmImageFromImage( + Display* display +, XImage* image +, XImage* shapeimage +, XpmImage* xpmimage +, XpmAttributes* attributes +) +#else int -XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage, - XpmImage *xpmimage, XpmAttributes *attributes) +XpmCreateXpmImageFromImage(display, image, shapeimage, + xpmimage, attributes) + Display *display; + XImage *image; + XImage *shapeimage; + XpmImage *xpmimage; + XpmAttributes *attributes; +#endif { /* variables stored in the XpmAttributes structure */ unsigned int cpp; @@ -183,7 +219,6 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage, unsigned int height = 0; unsigned int cppm; /* minimum chars per pixel */ unsigned int c; - unsigned int offset; /* initialize pmap */ pmap.pixels = NULL; @@ -226,14 +261,26 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage, /* * scan shape mask if any */ - if (shapeimage) { + if (shapeimage) + { #ifndef FOR_MSW - ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap, - storeMaskPixel); +# ifndef AMIGA + ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap, + storeMaskPixel); +# else + ErrorStatus = AGetImagePixels(shapeimage, width, height, &pmap, + storeMaskPixel); +# endif /* AMIGA */ #else - ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height, - &pmap); + +#ifndef __OS2__ + ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height, + &pmap, storeMaskPixel); +/* calling convention all messed up OS/2 -- figure out later */ #endif + +#endif /* ndef for FOR_MSW */ + if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); } @@ -246,24 +293,40 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage, * */ - if (image) { + if (image) + { #ifndef FOR_MSW - if (image->depth == 1) - ErrorStatus = GetImagePixels1(image, width, height, &pmap, - storePixel); - else if (image->bits_per_pixel == 8) - ErrorStatus = GetImagePixels8(image, width, height, &pmap); - else if (image->bits_per_pixel == 16) - ErrorStatus = GetImagePixels16(image, width, height, &pmap); - else if (image->bits_per_pixel == 32) - ErrorStatus = GetImagePixels32(image, width, height, &pmap); - else - ErrorStatus = GetImagePixels(image, width, height, &pmap); -#else /* FOR_MSW */ - ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap); +# ifndef AMIGA + if (((image->bits_per_pixel | image->depth) == 1) && + (image->byte_order == image->bitmap_bit_order)) + ErrorStatus = GetImagePixels1(image, width, height, &pmap, + storePixel); + else if (image->format == ZPixmap) + { + if (image->bits_per_pixel == 8) + ErrorStatus = GetImagePixels8(image, width, height, &pmap); + else if (image->bits_per_pixel == 16) + ErrorStatus = GetImagePixels16(image, width, height, &pmap); + else if (image->bits_per_pixel == 32) + ErrorStatus = GetImagePixels32(image, width, height, &pmap); + } + else + ErrorStatus = GetImagePixels(image, width, height, &pmap); +# else + ErrorStatus = AGetImagePixels(image, width, height, &pmap, + storePixel); +# endif /* AMIGA */ +#else + +#ifndef __VISAGECPP30__ + ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap, + storePixel); #endif - if (ErrorStatus != XpmSuccess) - RETURN(ErrorStatus); + +#endif + + if (ErrorStatus != XpmSuccess) + RETURN(ErrorStatus); } /* @@ -285,13 +348,11 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage, ErrorStatus = ScanTransparentColor(colorTable, cpp, attributes); if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); - offset = 1; - } else - offset = 0; + } - ErrorStatus = ScanOtherColors(display, colorTable + offset, - pmap.ncolors - offset, pmap.pixels + offset, - pmap.mask_pixel, cpp, attributes); + ErrorStatus = ScanOtherColors(display, colorTable, pmap.ncolors, + pmap.pixels, pmap.mask_pixel, cpp, + attributes); if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); @@ -307,10 +368,29 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage, XpmFree(pmap.pixels); return (XpmSuccess); + +/* exit point in case of error, free only locally allocated variables */ +error: + if (pmap.pixelindex) + XpmFree(pmap.pixelindex); + if (pmap.pixels) + XpmFree(pmap.pixels); + if (colorTable) + xpmFreeColorTable(colorTable, pmap.ncolors); + + return (ErrorStatus); } +#ifdef __OS2__ +/* Visual Age cannot deal with old, non-ansi, code */ +static int ScanTransparentColor(XpmColor* color, unsigned int cpp, XpmAttributes* attributes) +#else static int -ScanTransparentColor(XpmColor *color, unsigned int cpp, XpmAttributes *attributes) +ScanTransparentColor(color, cpp, attributes) + XpmColor *color; + unsigned int cpp; + XpmAttributes *attributes; +#endif { char *s; unsigned int a, b, c; @@ -325,42 +405,63 @@ ScanTransparentColor(XpmColor *color, unsigned int cpp, XpmAttributes *attribute *s = '\0'; /* then retreive related info from the attributes if any */ - if (attributes && attributes->mask_pixel != XpmUndefPixel && ( + if (attributes && (attributes->valuemask & XpmColorTable /* 3.2 backward compatibility code */ - attributes->valuemask & XpmInfos || + || attributes->valuemask & XpmInfos) /* end 3.2 bc */ - attributes->valuemask & XpmColorTable)) { + && attributes->mask_pixel != XpmUndefPixel) { unsigned int key; char **defaults = (char **) color; char **mask_defaults; /* 3.2 backward compatibility code */ - if (attributes->valuemask & XpmInfos) - mask_defaults = (char **) - ((XpmColor **) attributes->colorTable)[attributes->mask_pixel]; - else + if (attributes->valuemask & XpmColorTable) /* end 3.2 bc */ mask_defaults = (char **) ( attributes->colorTable + attributes->mask_pixel); +/* 3.2 backward compatibility code */ + else + mask_defaults = (char **) + ((XpmColor **) attributes->colorTable)[attributes->mask_pixel]; +/* end 3.2 bc */ for (key = 1; key <= NKEYS; key++) { if (s = mask_defaults[key]) { - defaults[key] = (char *) strdup(s); + defaults[key] = (char *) xpmstrdup(s); if (!defaults[key]) return (XpmNoMemory); } } } else { - color->c_color = (char *) strdup(TRANSPARENT_COLOR); + color->c_color = (char *) xpmstrdup(TRANSPARENT_COLOR); if (!color->c_color) return (XpmNoMemory); } return (XpmSuccess); } +#ifdef __OS2__ +/* Visual Age cannot deal with old, non-ansi, code */ +static int ScanOtherColors( + Display* display +, XpmColor* colors +, int ncolors +, Pixel* pixels +, unsigned int mask +, unsigned int cpp +, XpmAttributes* attributes +) +#else static int -ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, - unsigned int mask, unsigned int cpp, XpmAttributes *attributes) +ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes) + Display *display; + XpmColor *colors; + int ncolors; + Pixel *pixels; + unsigned int mask; + unsigned int cpp; + XpmAttributes *attributes; +#endif { /* variables stored in the XpmAttributes structure */ Colormap colormap; @@ -380,7 +481,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, unsigned int ancolors = 0; Pixel *apixels; unsigned int mask_pixel; - int found; + Bool found; /* retrieve information from the XpmAttributes */ if (attributes && (attributes->valuemask & XpmColormap)) @@ -392,13 +493,20 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, else rgb_fname = NULL; + /* start from the right element */ + if (mask) { + colors++; + ncolors--; + pixels++; + } + /* first get character strings and rgb values */ xcolors = (XColor *) XpmMalloc(sizeof(XColor) * ncolors); if (!xcolors) return (XpmNoMemory); - for (i = 0, i2 = (mask ? i + 1 : i), color = colors, xcolor = xcolors; - i < (unsigned int)ncolors; i++, i2++, color++, xcolor++, pixels++) { + for (i = 0, i2 = mask, color = colors, xcolor = xcolors; + i < (unsigned)ncolors; i++, i2++, color++, xcolor++, pixels++) { if (!(s = color->string = (char *) XpmMalloc(cpp + 1))) { XpmFree(xcolors); @@ -411,10 +519,10 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, xcolor->pixel = *pixels; } -#ifdef wx_msw - XQueryColors(display, (Colormap *)colormap, xcolors, ncolors); +#ifdef __OS2__ + XQueryColors(display, &colormap, xcolors, ncolors); #else - XQueryColors(display, (Colormap)colormap, xcolors, ncolors); + XQueryColors(display, colormap, xcolors, ncolors); #endif #ifndef FOR_MSW @@ -441,7 +549,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, } /* end 3.2 bc */ - for (i = 0, color = colors, xcolor = xcolors; i < (unsigned int)ncolors; + for (i = 0, color = colors, xcolor = xcolors; i < (unsigned)ncolors; i++, color++, xcolor++) { /* look for related info from the attributes if any */ @@ -472,7 +580,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, found = True; for (key = 1; key <= NKEYS; key++) { if (s = adefaults[key]) - defaults[key] = (char *) strdup(s); + defaults[key] = (char *) xpmstrdup(s); } } } @@ -483,7 +591,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, colorname = xpmGetRgbName(rgbn, rgbn_max, xcolor->red, xcolor->green, xcolor->blue); if (colorname) - color->c_color = (char *) strdup(colorname); + color->c_color = (char *) xpmstrdup(colorname); else { /* at last store the rgb value */ char buf[BUFSIZ]; @@ -494,7 +602,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, sprintf(buf, "#%02x%02x%02x", xcolor->red, xcolor->green, xcolor->blue); #endif - color->c_color = (char *) strdup(buf); + color->c_color = (char *) xpmstrdup(buf); } if (!color->c_color) { XpmFree(xcolors); @@ -510,13 +618,14 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels, } #ifndef FOR_MSW +# ifndef AMIGA /* * The functions below are written from X11R5 MIT's code (XImUtil.c) * * The idea is to have faster functions than the standard XGetPixel function * to scan the image data. Indeed we can speed up things by suppressing tests * performed for each pixel. We do exactly the same tests but at the image - * level. Assuming that we use only ZPixmap images. + * level. */ static unsigned long Const low_bits_table[] = { @@ -532,7 +641,7 @@ static unsigned long Const low_bits_table[] = { }; /* - * Default method to scan pixels of a Z image data structure. + * Default method to scan pixels of an image data structure. * The algorithm used is: * * copy the source bitmap_unit or Zpixel into temp @@ -542,14 +651,18 @@ static unsigned long Const low_bits_table[] = { */ static int -GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap) +GetImagePixels(image, width, height, pmap) + XImage *image; + unsigned int width; + unsigned int height; + PixelsMap *pmap; { char *src; char *dst; unsigned int *iptr; char *data; int x, y, i; - int bits, depth, ibu, ibpp; + int bits, depth, ibu, ibpp, offset; unsigned long lbt; Pixel pixel, px; @@ -558,7 +671,9 @@ GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap depth = image->depth; lbt = low_bits_table[depth]; ibpp = image->bits_per_pixel; - if (image->depth == 1) { + offset = image->xoffset; + + if ((image->bits_per_pixel | image->depth) == 1) { ibu = image->bitmap_unit; for (y = 0; y < height; y++) for (x = 0; x < width; x++, iptr++) { @@ -568,14 +683,41 @@ GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap for (i = ibu >> 3; --i >= 0;) *dst++ = *src++; XYNORMALIZE(&pixel, image); - bits = x % ibu; + bits = (x + offset) % ibu; pixel = ((((char *) &pixel)[bits >> 3]) >> (bits & 7)) & 1; if (ibpp != depth) pixel &= lbt; if (storePixel(pixel, pmap, iptr)) return (XpmNoMemory); } - } else { + } else if (image->format == XYPixmap) { + int nbytes, bpl, j; + long plane = 0; + ibu = image->bitmap_unit; + nbytes = ibu >> 3; + bpl = image->bytes_per_line; + for (y = 0; y < height; y++) + for (x = 0; x < width; x++, iptr++) { + pixel = 0; + plane = 0; + for (i = depth; --i >= 0;) { + src = &data[XYINDEX(x, y, image) + plane]; + dst = (char *) &px; + px = 0; + for (j = nbytes; --j >= 0;) + *dst++ = *src++; + XYNORMALIZE(&px, image); + bits = (x + offset) % ibu; + pixel = (pixel << 1) | + (((((char *) &px)[bits >> 3]) >> (bits & 7)) & 1); + plane = plane + (bpl * height); + } + if (ibpp != depth) + pixel &= lbt; + if (storePixel(pixel, pmap, iptr)) + return (XpmNoMemory); + } + } else if (image->format == ZPixmap) { for (y = 0; y < height; y++) for (x = 0; x < width; x++, iptr++) { src = &data[ZINDEX(x, y, image)]; @@ -598,7 +740,8 @@ GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap if (storePixel(pixel, pmap, iptr)) return (XpmNoMemory); } - } + } else + return (XpmColorError); /* actually a bad image */ return (XpmSuccess); } @@ -606,13 +749,16 @@ GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap * scan pixels of a 32-bits Z image data structure */ -#ifndef WORD64 +#if !defined(WORD64) && !defined(LONG64) static unsigned long byteorderpixel = MSBFirst << 24; - #endif static int -GetImagePixels32(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap) +GetImagePixels32(image, width, height, pmap) + XImage *image; + unsigned int width; + unsigned int height; + PixelsMap *pmap; { unsigned char *addr; unsigned char *data; @@ -626,7 +772,7 @@ GetImagePixels32(XImage *image, unsigned int width, unsigned int height, PixelsM iptr = pmap->pixelindex; depth = image->depth; lbt = low_bits_table[depth]; -#ifndef WORD64 +#if !defined(WORD64) && !defined(LONG64) if (*((char *) &byteorderpixel) == image->byte_order) { for (y = 0; y < height; y++) for (x = 0; x < width; x++, iptr++) { @@ -646,7 +792,7 @@ GetImagePixels32(XImage *image, unsigned int width, unsigned int height, PixelsM pixel = ((unsigned long) addr[0] << 24 | (unsigned long) addr[1] << 16 | (unsigned long) addr[2] << 8 | - addr[4]); + addr[3]); if (depth != 32) pixel &= lbt; if (storePixel(pixel, pmap, iptr)) @@ -673,7 +819,11 @@ GetImagePixels32(XImage *image, unsigned int width, unsigned int height, PixelsM */ static int -GetImagePixels16(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap) +GetImagePixels16(image, width, height, pmap) + XImage *image; + unsigned int width; + unsigned int height; + PixelsMap *pmap; { unsigned char *addr; unsigned char *data; @@ -715,7 +865,11 @@ GetImagePixels16(XImage *image, unsigned int width, unsigned int height, PixelsM */ static int -GetImagePixels8(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap) +GetImagePixels8(image, width, height, pmap) + XImage *image; + unsigned int width; + unsigned int height; + PixelsMap *pmap; { unsigned int *iptr; unsigned char *data; @@ -744,62 +898,162 @@ GetImagePixels8(XImage *image, unsigned int width, unsigned int height, PixelsMa */ static int -GetImagePixels1(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap, -/* - int (*storeFunc)() -*/ - int (*storeFunc)(Pixel,PixelsMap*,unsigned int*) -) +GetImagePixels1(image, width, height, pmap, storeFunc) + XImage *image; + unsigned int width; + unsigned int height; + PixelsMap *pmap; + int (*storeFunc) (); { unsigned int *iptr; int x, y; char *data; Pixel pixel; + int xoff, yoff, offset, bpl; - 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); + } return (XpmSuccess); } +# else /* AMIGA */ + +#define CLEAN_UP(status) \ +{\ + if (pixels) XpmFree (pixels);\ + if (tmp_img) FreeXImage (tmp_img);\ + return (status);\ +} + +static int +AGetImagePixels ( + XImage *image, + unsigned int width, + unsigned int height, + PixelsMap *pmap, + int (*storeFunc) ()) +{ + unsigned int *iptr; + unsigned int x, y; + unsigned char *pixels; + XImage *tmp_img; + + pixels = XpmMalloc ((((width+15)>>4)<<4)*sizeof (*pixels)); + if (pixels == NULL) + return XpmNoMemory; + + tmp_img = AllocXImage ((((width+15)>>4)<<4), 1, image->rp->BitMap->Depth); + if (tmp_img == NULL) + CLEAN_UP (XpmNoMemory) + + iptr = pmap->pixelindex; + for (y = 0; y < height; ++y) + { + ReadPixelLine8 (image->rp, 0, y, width, pixels, tmp_img->rp); + for (x = 0; x < width; ++x, ++iptr) + { + if ((*storeFunc) (pixels[x], pmap, iptr)) + CLEAN_UP (XpmNoMemory) + } + } + + CLEAN_UP (XpmSuccess) +} + +#undef CLEAN_UP + +# endif/* AMIGA */ #else /* ndef FOR_MSW */ + +#ifdef __OS2__ + +#ifdef __VISAGECPP30__ +static int MSWGetImagePixels( + Display* display +, XImage* image +, unsigned int width +, unsigned int height +, PixelsMap* pmap +, int (*storeFunc) (Pixel, PixelsMap*, unsigned int*) +) +#else +static int MSWGetImagePixels( + Display* display +, XImage* image +, unsigned int width +, unsigned int height +, PixelsMap* pmap +, int (*storeFunc) () +) +#endif + +#else static int -MSWGetImagePixels(Display *display, XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap) +MSWGetImagePixels(display, image, width, height, pmap, storeFunc) + Display *display; + XImage *image; + unsigned int width; + unsigned int height; + PixelsMap *pmap; + int (*storeFunc) (); +#endif { unsigned int *iptr; unsigned int x, y; Pixel pixel; +#ifdef __OS2__ + HAB hab; + HPS hps; + DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + SIZEL sizl = {0, 0}; + POINTL point; +#endif iptr = pmap->pixelindex; +#ifdef __OS2__ + hps = GpiCreatePS(hab, *display, &sizl, GPIA_ASSOC | PU_PELS); + GpiSetBitmap(hps, image->bitmap); +#else + SelectObject(*display, image->bitmap); +#endif + for (y = 0; y < height; y++) { -#if !defined(__VISAGECPP__) /* fixme for OS/2 */ for (x = 0; x < width; x++, iptr++) { - /* bitmap must be selected !!! ??? */ +#ifdef __OS2__ + point.x = x; + point.y = y; + pixel = GpiQueryPel(hps, &point); +#else pixel = GetPixel(*display, x, y); - if (storePixel(pixel, pmap, iptr)) +#endif + + if ((*storeFunc) (pixel, pmap, iptr)) return (XpmNoMemory); } -#endif } return (XpmSuccess); } @@ -807,9 +1061,15 @@ MSWGetImagePixels(Display *display, XImage *image, unsigned int width, unsigned #endif #ifndef FOR_MSW +# ifndef AMIGA int -XpmCreateXpmImageFromPixmap(Display *display, Pixmap pixmap, Pixmap shapemask, - XpmImage *xpmimage, XpmAttributes *attributes) +XpmCreateXpmImageFromPixmap(display, pixmap, shapemask, + xpmimage, attributes) + Display *display; + Pixmap pixmap; + Pixmap shapemask; + XpmImage *xpmimage; + XpmAttributes *attributes; { XImage *ximage = NULL; XImage *shapeimage = NULL; @@ -842,4 +1102,5 @@ XpmCreateXpmImageFromPixmap(Display *display, Pixmap pixmap, Pixmap shapemask, return (ErrorStatus); } +# endif/* not AMIGA */ #endif /* ndef FOR_MSW */