X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e6ed776fb2d330b4b6d0105c3628ccf88fd3bb60..77611ad4da9df336a0805508276a81b8f4437107:/src/xpm/scan.c diff --git a/src/xpm/scan.c b/src/xpm/scan.c index eabbde1158..c4ee723280 100644 --- a/src/xpm/scan.c +++ b/src/xpm/scan.c @@ -111,11 +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, pmap, index_return) Pixel pixel; PixelsMap *pmap; unsigned int *index_return; +#endif { unsigned int i; Pixel *p; @@ -146,11 +151,16 @@ storePixel(pixel, pmap, 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, pmap, index_return) Pixel pixel; PixelsMap *pmap; unsigned int *index_return; +#endif { if (!pixel) { if (!pmap->ncolors) { @@ -176,6 +186,16 @@ storeMaskPixel(pixel, pmap, index_return) * 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, image, shapeimage, xpmimage, attributes) @@ -184,6 +204,7 @@ XpmCreateXpmImageFromImage(display, image, shapeimage, XImage *shapeimage; XpmImage *xpmimage; XpmAttributes *attributes; +#endif { /* variables stored in the XpmAttributes structure */ unsigned int cpp; @@ -240,57 +261,72 @@ XpmCreateXpmImageFromImage(display, image, shapeimage, /* * scan shape mask if any */ - if (shapeimage) { + if (shapeimage) + { #ifndef FOR_MSW # ifndef AMIGA - ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap, - storeMaskPixel); + ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap, + storeMaskPixel); # else - ErrorStatus = AGetImagePixels(shapeimage, width, height, &pmap, - storeMaskPixel); -# endif + ErrorStatus = AGetImagePixels(shapeimage, width, height, &pmap, + storeMaskPixel); +# endif /* AMIGA */ #else - ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height, - &pmap, storeMaskPixel); + +#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); } /* * scan the image data - * + * * In case depth is 1 or bits_per_pixel is 4, 6, 8, 24 or 32 use optimized * functions, otherwise use slower but sure general one. - * + * */ - if (image) { + if (image) + { #ifndef FOR_MSW # 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); + 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 + ErrorStatus = AGetImagePixels(image, width, height, &pmap, + storePixel); +# endif /* AMIGA */ #else - ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap, - storePixel); + +#ifndef __VISAGECPP30__ + ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap, + storePixel); #endif - if (ErrorStatus != XpmSuccess) - RETURN(ErrorStatus); + +#endif + + if (ErrorStatus != XpmSuccess) + RETURN(ErrorStatus); } /* @@ -345,11 +381,16 @@ error: 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(color, cpp, attributes) XpmColor *color; unsigned int cpp; XpmAttributes *attributes; +#endif { char *s; unsigned int a, b, c; @@ -399,6 +440,18 @@ ScanTransparentColor(color, cpp, attributes) 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, colors, ncolors, pixels, mask, cpp, attributes) Display *display; @@ -408,6 +461,7 @@ ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes) unsigned int mask; unsigned int cpp; XpmAttributes *attributes; +#endif { /* variables stored in the XpmAttributes structure */ Colormap colormap; @@ -416,8 +470,8 @@ ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes) #ifndef FOR_MSW xpmRgbName rgbn[MAX_RGBNAMES]; #else - xpmRgbName *rgbn = NULL; -#endif + xpmRgbName *rgbn = NULL; +#endif int rgbn_max = 0; unsigned int i, j, c, i2; XpmColor *color; @@ -465,7 +519,11 @@ ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes) xcolor->pixel = *pixels; } +#ifdef __OS2__ + XQueryColors(display, &colormap, xcolors, ncolors); +#else XQueryColors(display, colormap, xcolors, ncolors); +#endif #ifndef FOR_MSW /* read the rgb file if any was specified */ @@ -540,7 +598,7 @@ ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes) #ifndef FOR_MSW sprintf(buf, "#%04X%04X%04X", xcolor->red, xcolor->green, xcolor->blue); -#else +#else sprintf(buf, "#%02x%02x%02x", xcolor->red, xcolor->green, xcolor->blue); #endif @@ -902,15 +960,15 @@ AGetImagePixels ( 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) { @@ -921,7 +979,7 @@ AGetImagePixels ( CLEAN_UP (XpmNoMemory) } } - + CLEAN_UP (XpmSuccess) } @@ -929,6 +987,30 @@ AGetImagePixels ( # 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, image, width, height, pmap, storeFunc) Display *display; @@ -937,17 +1019,38 @@ MSWGetImagePixels(display, image, width, height, pmap, storeFunc) 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++) { for (x = 0; x < width; x++, iptr++) { +#ifdef __OS2__ + point.x = x; + point.y = y; + pixel = GpiQueryPel(hps, &point); +#else pixel = GetPixel(*display, x, y); +#endif + if ((*storeFunc) (pixel, pmap, iptr)) return (XpmNoMemory); }