X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c2a05373bff436737034d97540715d6c6a7e3581..2adaf5969faf352d740f267b1a4ef79a2cf75980:/src/xpm/simx.c diff --git a/src/xpm/simx.c b/src/xpm/simx.c index 6b8ef57b91..267c419576 100644 --- a/src/xpm/simx.c +++ b/src/xpm/simx.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 @@ -33,11 +33,12 @@ * Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) * \*****************************************************************************/ -#include "xpm34.h" +/* Moved here so that FOR_MSW gets defined if we are using wxWindows (GRG) */ +#include "xpm.h" #ifdef FOR_MSW -#include "xpm34p.h" /* for XpmMalloc */ +#include "XpmI.h" /* for XpmMalloc */ /* * On DOS size_t is only 2 bytes, thus malloc(size_t s) can only malloc @@ -119,18 +120,25 @@ XDefaultScreen(Display *d) } /* I get only 1 plane but 8 bits per pixel, - so I think BITSPIXEL should be depth - - TRS: I assume that all "displays" have the same number of - planes later in the code, which is based on the assumption - that the display variable is ignored below. :) - */ + so I think BITSPIXEL should be depth */ int XDefaultDepth(Display *display, Screen *screen) { int d, b; +#ifdef __OS2__ + HPS hpsScreen; + HDC hdcScreen; + LONG lPlanes; + LONG lBitsPerPixel; + LONG nDepth; -#if !defined(__VISAGECPP__) /* fisme for OS/2 */ + hpsScreen = WinGetScreenPS(HWND_DESKTOP); + hdcScreen = GpiQueryDevice(hpsScreen); + DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, 1L, &lPlanes); + DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitsPerPixel); + b = (int)lBitsPerPixel; + WinReleasePS(hpsScreen); +#else b = GetDeviceCaps(*display, BITSPIXEL); d = GetDeviceCaps(*display, PLANES); #endif @@ -210,7 +218,9 @@ XParseColor(Display *d, Colormap *cmap, char *name, XColor *color) } if (okay) { -#if !defined(__VISAGECPP__) /* fixme for OS/2 */ +#ifdef __OS2__ + color->pixel = OS2RGB(r, g, b); +#else color->pixel = RGB(r, g, b); #endif color->red = (BYTE) r; @@ -222,6 +232,8 @@ XParseColor(Display *d, Colormap *cmap, char *name, XColor *color) } +/* GRG: 2nd arg is Colormap*, not Colormap */ + int XAllocColor(Display *d, Colormap *cmap, XColor *color) { @@ -238,13 +250,11 @@ XQueryColors(Display *display, Colormap *colormap, XColor *xc = xcolors; int i; -#if !defined(__VISAGECPP__) /* fixme for OS/2 */ for (i = 0; i < ncolors; i++, xc++) { xc->red = GetRValue(xc->pixel); xc->green = GetGValue(xc->pixel); xc->blue = GetBValue(xc->pixel); } -#endif return; } int @@ -263,17 +273,33 @@ XCreateImage(Display *d, Visual *v, int pad, int foo) { XImage *img = (XImage *) XpmMalloc(sizeof(XImage)); +#ifdef __OS2__ + BITMAPINFOHEADER2 bmih; + + memset(&bmih, 0, sizeof(BITMAPINFOHEADER2)); + bmih.cbFix = sizeof(BITMAPINFOHEADER2); + bmih.cx = width; + bmih.cy = height; + bmih.cPlanes = 1; + bmih.cBitCount = depth; +#endif if (img) { - /* *img = CreateCompatibleBitmap(*d, width, height); */ - -#if !defined(__VISAGECPP__) /* fixme for OS/2 */ - /* create the bitmap with the same number of planes as the default display - * (otherwise it wouldn't work for 16 color mode) */ - img->bitmap = CreateBitmap(width, height, - GetDeviceCaps(*d, PLANES), - depth /* bits per pixel */ , NULL); + /*JW: This is what it should be, but the picture comes out + just black!? It appears to be doing monochrome reduction, + but I've got no clue why. Using CreateBitmap() is supposed + to be slower, but otherwise ok + if ( depth == GetDeviceCaps(*d, BITSPIXEL) ) { + img->bitmap = CreateCompatibleBitmap(*d, width, height); + } else*/ { +#ifdef __OS2__ + img->bitmap = GpiCreateBitmap(*d, &bmih, 0L, NULL, NULL); + WinReleasePS(*d); +#else + img->bitmap = CreateBitmap(width, height, 1 /* plane */ , + depth /* bits per pixel */ , NULL); #endif + } img->width = width; img->height = height; img->depth = depth; @@ -293,7 +319,9 @@ void XDestroyImage(XImage *img) { if (img) { -#if !defined(__VISAGECPP__) /* fixme for OS/2 */ +#ifdef __OS2__ + GpiDeleteBitmap(img->bitmap); +#else DeleteObject(img->bitmap); /* check return ??? */ #endif XImageFree(img);