int (*storeFunc) ()));
# endif/* AMIGA */
#else /* ndef FOR_MSW */
+
+#if defined(__OS2__) && defined(__VISAGECPP30__)
+LFUNC(MSWGetImagePixels, int, (Display* display, XImage* image, unsigned int width,
+ unsigned int height, PixelsMap* pmap,
+ int (*storeFunc) (Pixel, PixelsMap*, unsigned int*)));
+#else
LFUNC(MSWGetImagePixels, int, (Display *d, XImage *image, unsigned int width,
- unsigned int height, PixelsMap *pmap,
- int (*storeFunc) ()));
+ unsigned int height, PixelsMap *pmap,
+ int (*storeFunc) ()));
+#endif
+
#endif
+
LFUNC(ScanTransparentColor, int, (XpmColor *color, unsigned int cpp,
- XpmAttributes *attributes));
+ XpmAttributes *attributes));
LFUNC(ScanOtherColors, int, (Display *display, XpmColor *colors, int ncolors,
- Pixel *pixels, unsigned int mask,
- unsigned int cpp, XpmAttributes *attributes));
+ Pixel *pixels, unsigned int mask,
+ unsigned int cpp, XpmAttributes *attributes));
/*
* 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;
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) {
* 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)
XImage *shapeimage;
XpmImage *xpmimage;
XpmAttributes *attributes;
+#endif
{
/* variables stored in the XpmAttributes structure */
unsigned int cpp;
/*
* 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);
-#endif
+
+ ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height,
+ &pmap, storeMaskPixel);
+
+#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);
+
+ ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap,
+ storePixel);
+
#endif
- if (ErrorStatus != XpmSuccess)
- RETURN(ErrorStatus);
+
+ if (ErrorStatus != XpmSuccess)
+ RETURN(ErrorStatus);
}
/*
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;
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;
unsigned int mask;
unsigned int cpp;
XpmAttributes *attributes;
+#endif
{
/* variables stored in the XpmAttributes structure */
Colormap colormap;
#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;
return (XpmNoMemory);
for (i = 0, i2 = mask, color = colors, xcolor = xcolors;
- i < ncolors; i++, i2++, color++, xcolor++, pixels++) {
+ i < (unsigned)ncolors; i++, i2++, color++, xcolor++, pixels++) {
if (!(s = color->string = (char *) XpmMalloc(cpp + 1))) {
XpmFree(xcolors);
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 */
}
/* end 3.2 bc */
- for (i = 0, color = colors, xcolor = xcolors; i < ncolors;
+ for (i = 0, color = colors, xcolor = xcolors; i < (unsigned)ncolors;
i++, color++, xcolor++) {
/* look for related info from the attributes if any */
#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
+#endif
color->c_color = (char *) xpmstrdup(buf);
}
if (!color->c_color) {
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)
{
CLEAN_UP (XpmNoMemory)
}
}
-
+
CLEAN_UP (XpmSuccess)
}
# 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;
unsigned int height;
PixelsMap *pmap;
int (*storeFunc) ();
+#endif
{
unsigned int *iptr;
unsigned int x, y;
Pixel pixel;
+#ifdef __OS2__
+ HAB hab = WinQueryAnchorBlock(HWND_DESKTOP);
+ HDC shapedc;
+ DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+ SIZEL sizl = {0, 0};
+ POINTL point;
+#endif
iptr = pmap->pixelindex;
+#ifdef __OS2__
+ shapedc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
+ *display = GpiCreatePS(hab, shapedc, &sizl, GPIA_ASSOC | PU_PELS);
+ GpiSetBitmap(*display, 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(*display, &point);
+#else
pixel = GetPixel(*display, x, y);
+#endif
+
if ((*storeFunc) (pixel, pmap, iptr))
return (XpmNoMemory);
}