* 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);
+
+#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);
}
/*
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
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;
+ 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);
}