WinWorkstation.st
changeset 7991 09cc63f1c5c8
parent 7680 6597c1842893
child 8011 6fb515551297
--- a/WinWorkstation.st	Tue Mar 28 10:57:09 2017 +0200
+++ b/WinWorkstation.st	Tue Mar 28 14:29:29 2017 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
 COPYRIGHT (c) 1996 by Claus Gittinger
 	      All Rights Reserved
@@ -2054,7 +2056,7 @@
 		    }
 		    goto again;
 		}
-		/* fail evtl. später ändern und in st verzögert aufrufen
+		/* fail evtl. später ändern und in st verzögert aufrufen
 		*/
 		console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
 	    }
@@ -16438,110 +16440,419 @@
 
 !WinWorkstation methodsFor:'retrieving pixels'!
 
-getBitsFromId:aDrawableId x:srcx y:srcy width:w height:h into:imageBits
+getBitsFromId:aDrawableId x:srcX y:srcY width:w height:h into:imageBits
     "get bits from a drawable into the imageBits. The storage for the bits
      must be big enough for the data to fit. If ok, returns an array with some
      info and the bits in imageBits. The info contains the depth, bitOrder and
      number of bytes per scanline. The number of bytes per scanline is not known
-     in advance, since the X-server is free to return whatever it thinks is a good padding."
-
-    |rawInfo info|
+     in advance, since the Workstation is free to return whatever it thinks is a good padding."
+
+    |error bytesPerLine bitmapPad bitsPerPixel|
 
     ((w <= 0) or:[h <= 0]) ifTrue:[
-	self primitiveFailed.
-	^ nil
-    ].
-
-    rawInfo := Array new:11.
-		  "1 -> bit order"
-		  "2 -> depth"
-		  "3 -> bytes_per_line"
-		  "4 -> byte_order"
-		  "5 -> format"
-		  "6 -> bitmap_unit"
-		  "7 -> bitmap_pad"
-		  "8 -> bits_per_pixel"
-		  "9 -> red_mask"
-		  "10 -> green_mask"
-		  "11 -> blue_mask"
-
-    "/ had to extract the getPixel call into a separate method, to specify
-    "/ unlimitedStack (some implementations use alloca and require huge amounts
-    "/ of temporary stack space
-
-    (self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[
-	info := IdentityDictionary new.
-	info at:#bitOrder put:(rawInfo at:1).
-	info at:#depth put:(rawInfo at:2).
-	info at:#bytesPerLine put:(rawInfo at:3).
-	info at:#byteOrder put:(rawInfo at:4).
-	info at:#format put:(rawInfo at:5).
-	info at:#bitmapUnit put:(rawInfo at:6).
-	info at:#bitmapPad put:(rawInfo at:7).
-	info at:#bitsPerPixel put:(rawInfo at:8).
-	info at:#redMask put:(rawInfo at:9).
-	info at:#greenMask put:(rawInfo at:10).
-	info at:#blueMask put:(rawInfo at:11).
-	^ info
-    ].
-    "
-     some error occured - either args are not smallintegers, imageBits is not a ByteArray
-     or is too small to hold the bits
-    "
-    ^ self primitiveFailed
-!
-
-getBitsFromPixmapId:aDrawableId x:srcx y:srcy width:w height:h into:imageBits
+        ^ self primitiveFailed:'zero width or height'.
+    ].
+
+%{
+    int     height, width;
+    unsigned int numBytes;
+    int     bytesPerRow;
+    HWND    hWnd;
+    HBITMAP hBitmap = 0;
+    HGDIOBJ hPrevious = 0;
+    HDC     bDC = 0;
+    struct {
+        BITMAPINFOHEADER bmiHeader;
+        DWORD r;
+        DWORD g;
+        DWORD b;
+    } bitmap;
+
+    if (! __isExternalAddress(aDrawableId)) {
+        error = __MKSTRING("externalAddress arg");
+        goto out;
+    }
+    if (! __bothSmallInteger(srcX, srcY)) {
+        error = __MKSTRING("x,y args");
+        goto out;
+    }
+    if (! __bothSmallInteger(w, h)) {
+        error = __MKSTRING("w,h args");
+        goto out;
+    }
+    if (! __isByteArray(imageBits)) {
+        error = __MKSTRING("imageBits arg");
+        goto out;
+    }
+
+    {
+        hWnd = _HWNDVal( aDrawableId );
+        BMDPRINTF(("primGetBits %x\n",hWnd));
+        if ( hWnd != 0 ) {
+            HDC wDC;
+            HANDLE prevBitmap;
+            int widthRoundedUpToNextMultipleOf4 = ((width + 3 ) / 4) * 4;
+            int widthUsed;
+
+            bDC = CreateCompatibleDC(__rootDC);
+
+            BMDPRINTF(("primGetBits srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
+            height =  __intVal(h);
+            width  =  __intVal(w);
+
+            widthUsed = widthRoundedUpToNextMultipleOf4;
+            widthUsed = width;
+
+            BMDPRINTF(("width %d height %d\n",width,height));
+            hBitmap = CreateCompatibleBitmap(__rootDC, widthUsed, height);
+            if (!hBitmap) {
+                error = __MKSTRING("CreateCompatibleBitmap failed");
+                goto out;
+            }
+            bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+            bitmap.bmiHeader.biPlanes = 1;
+#ifdef ALWAYSTRUECOLOR
+            bitmap.bmiHeader.biCompression = BI_RGB;
+            bytesPerRow = (((width*3) + 3 ) / 4) * 4;
+#else
+            if (__depth == 24) {
+                bitmap.bmiHeader.biCompression = BI_RGB;
+                bytesPerRow = (((width*3) + 3 ) / 4) * 4;
+            } else if (__depth == 16) {
+# if 0
+                bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+                bitmap.b = 0x001f;
+                bitmap.g = 0x07e0;
+                bitmap.r = 0xf800;
+                bytesPerRow = (((width*2) + 1 ) / 4) * 4;
+# else
+                bitmap.b = 0;
+                bitmap.g = 0;
+                bitmap.r = 0;
+                bitmap.bmiHeader.biCompression = BI_RGB;
+                bytesPerRow = (((width*3) + 3 ) / 4) * 4;
+# endif
+            }
+#endif /* ALWAYSTRUECOLOR */
+            bitmap.bmiHeader.biSizeImage = 0;
+            bitmap.bmiHeader.biXPelsPerMeter = 0;
+            bitmap.bmiHeader.biYPelsPerMeter = 0;
+            bitmap.bmiHeader.biClrUsed = 0;
+            bitmap.bmiHeader.biClrImportant = 0;
+            bitmap.bmiHeader.biBitCount = __depth;
+
+            bitmap.bmiHeader.biWidth = widthUsed;
+            bitmap.bmiHeader.biHeight = -height;
+
+            wDC = GetDC(hWnd);
+
+            hPrevious = SelectObject(bDC, hBitmap);
+            if (BitBlt(bDC,
+                   0,0,
+                   width,height,
+                   wDC,
+                   __intVal(srcX), __intVal(srcY),
+                   SRCCOPY|CAPTUREBLT)
+                 == 0
+                )
+            {
+                INFOFPRINTF((stderr, "WinWorkstation [warning]: in primGetBitsFrom: BitBlt\n"));
+            }
+
+#ifdef CACHE_LAST_DC
+            if (lastGcData && (lastGcData->_hDC == wDC)) {
+# ifdef DEBUG_DC_REUSE
+                console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - cachedDC reuse\n", __LINE__);
+# endif
+            } else
+#endif
+            {
+#ifdef CACHE_LAST_WM_PAINT_DC
+                if (last_wm_paint_dc && (last_wm_paint_dc == wDC)) {
+# ifdef DEBUG_DC_REUSE
+                    console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - last_wm_paint_dc reuse\n", __LINE__);
+# endif
+                } else
+#endif
+                {
+                    ReleaseDC(hWnd, wDC);
+                }
+            }
+
+            if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
+            {
+                error = __MKSTRING("noinfo returned in primGetBits");
+                goto out;
+            }
+            BMDPRINTF(("bitmap info:%d %d %d %d\n",
+                        bitmap.bmiHeader.biWidth, bitmap.bmiHeader.biHeight,
+                        bitmap.bmiHeader.biBitCount, bitmap.bmiHeader.biSizeImage));
+            numBytes = bitmap.bmiHeader.biSizeImage;
+            if ( numBytes != 0 ) {
+                if (numBytes > __byteArraySize(imageBits)) {
+                    /* imageBits too small */
+                    INFOFPRINTF((stderr, "WinWorkstation [warning]: primGetBits - byteArray too small (is:%d need:%d; w:%d h:%d)\n",
+                                __byteArraySize(imageBits), numBytes,
+                                bitmap.bmiHeader.biWidth, -bitmap.bmiHeader.biHeight
+                             ));
+                    error = __MKSTRING("byteArray too small");
+                    goto out;
+                }
+                BMDPRINTF(("numBytes %d\n",numBytes));
+
+                bitmap.bmiHeader.biHeight = -height;
+                if (GetDIBits(bDC,hBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
+                {
+                    error = __MKSTRING("zero bits returned in primGetBits");
+                    goto out;
+                }
+
+                /* swap red and blue (windows delivers BGR) */
+                {
+                    char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
+                    int _h;
+                    char *rowp = cp;
+
+                    for (_h=height; _h>0; _h--) {
+                        int _w;
+                        char *pixel = rowp;
+
+                        for (_w=width; _w>0; _w--) {
+                            char b;
+
+                            b = pixel[0];
+                            pixel[0] = pixel[2];
+                            pixel[2] = b;
+                            pixel += 3;
+                        };
+                        rowp += bytesPerRow;
+                    };
+                }
+            } else {
+                error = __MKSTRING("unacceptable bitmap in primGetBits");
+                goto out;
+            }
+        } else {
+            error = __MKSTRING("unacceptable HWND in primGetBits");
+            goto out;
+        }
+
+        bytesPerLine = __MKSMALLINT(bytesPerRow);
+        bitmapPad = __MKSMALLINT(WIN32PADDING);
+        bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
+    }
+
+out:
+    if ((hPrevious != NULL) && (bDC != NULL))
+        SelectObject(bDC, hPrevious);
+    if (bDC)
+        DeleteDC(bDC);
+    if (hBitmap)
+        _DeleteObject(hBitmap, __LINE__);
+%}.
+
+    error notNil ifTrue:[
+        ^ self primitiveFailed:error.
+    ].
+
+
+    ^ IdentityDictionary new
+            at:#bitOrder put:#msbFirst;
+            at:#depth put:1;
+            at:#bytesPerLine put:bytesPerLine;
+            at:#byteOrder put:#lsbFirst;
+            at:#format put:#XYPixmap;
+            at:#bitmapUnit put:0;
+            at:#bitmapPad put:bitmapPad;
+            at:#bitsPerPixel put:bitsPerPixel;
+            at:#redMask put:16rFF0000;
+            at:#greenMask put:16r00FF00;
+            at:#blueMask put:16r0000FF;
+            yourself.
+
+    "Modified (comment): / 28-03-2017 / 14:28:39 / stefan"
+!
+
+getBitsFromPixmapId:aDrawableId x:srcX y:srcY width:w height:h into:imageBits
     "get bits from a drawable into the imageBits. The storage for the bits
      must be big enough for the data to fit. If ok, returns an array with some
      info and the bits in imageBits. The info contains the depth, bitOrder and
      number of bytes per scanline. The number of bytes per scanline is not known
-     in advance, since the X-server is free to return whatever it thinks is a good padding."
-
-    |rawInfo info|
+     in advance, since the Workstation is free to return whatever it thinks is a good padding."
+
+    |rawInfo error bytesPerLine format bitmapPad bitsPerPixel|
 
     ((w <= 0) or:[h <= 0]) ifTrue:[
-	self primitiveFailed.
-	^ nil
+        self primitiveFailed:'zero width or height'.
+        ^ nil
     ].
 
     rawInfo := Array new:11.
-		  "1 -> bit order"
-		  "2 -> depth"
-		  "3 -> bytes_per_line"
-		  "4 -> byte_order"
-		  "5 -> format"
-		  "6 -> bitmap_unit"
-		  "7 -> bitmap_pad"
-		  "8 -> bits_per_pixel"
-		  "9 -> red_mask"
-		  "10 -> green_mask"
-		  "11 -> blue_mask"
-
-    "/ had to extract the getPixel call into a separate method, to specify
-    "/ unlimitedStack (some implementations use alloca and require huge amounts
-    "/ of temporary stack space
-
-    (self primGetBitsFromPixmap:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[
-	info := IdentityDictionary new.
-	info at:#bitOrder put:(rawInfo at:1).
-	info at:#depth put:(rawInfo at:2).
-	info at:#bytesPerLine put:(rawInfo at:3).
-	info at:#byteOrder put:(rawInfo at:4).
-	info at:#format put:(rawInfo at:5).
-	info at:#bitmapUnit put:(rawInfo at:6).
-	info at:#bitmapPad put:(rawInfo at:7).
-	info at:#bitsPerPixel put:(rawInfo at:8).
-	info at:#redMask put:(rawInfo at:9).
-	info at:#greenMask put:(rawInfo at:10).
-	info at:#blueMask put:(rawInfo at:11).
-	^ info
-    ].
-    "
-     some error occured - either args are not smallintegers, imageBits is not a ByteArray
-     or is too small to hold the bits
-    "
-    ^ self primitiveFailed
+
+%{
+    int            height, width;
+    unsigned int   numBytes;
+    unsigned char* ep = 0;
+    HBITMAP        xBitmap;
+    HBITMAP hBitmap = 0;
+    HDC bDC = 0;
+    HDC xDC = 0;
+    struct
+    {
+        BITMAPINFOHEADER bmiHeader;
+        DWORD rgb[2];
+    } bitmap;
+    BITMAP bitmapInfo;
+
+    if (__isExternalAddress(aDrawableId)
+     && __bothSmallInteger(srcX, srcY)
+     && __bothSmallInteger(w, h)
+     && __isArray(rawInfo) && __arraySize(rawInfo) >= 11
+     && __isByteArray(imageBits))
+    {
+        xBitmap = _HBITMAPVAL( aDrawableId );
+        BMDPRINTF(("primGetBitsFromPixmap %x\n",xBitmap));
+        if (xBitmap != 0) {
+            xDC = GetDC(0);
+            SelectObject(xDC, xBitmap);
+            GetObject(xBitmap,sizeof(bitmapInfo),&bitmapInfo);
+
+            bDC = CreateCompatibleDC(__rootDC);
+            BMDPRINTF(("srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
+            height =  __intVal(h);
+            width  =  __intVal(w);
+            BMDPRINTF(("width %d height %d\n",width,height));
+
+            hBitmap = CreateCompatibleBitmap(xDC, width, height);
+            if (!hBitmap) {
+                error = __MKSTRING("create bitmap failed");
+                goto out;
+            }
+
+            SelectObject(bDC,hBitmap);
+            if (BitBlt(bDC,
+                   0,0,
+                   width,height,
+                   xDC,
+                   __intVal(srcX), __intVal(srcY),
+                   SRCCOPY)
+                 == 0
+                )
+            {
+                error = __MKSTRING("BitBlt failed");
+                goto out;
+            }
+            bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+            bitmap.bmiHeader.biPlanes = 1;
+#ifdef ALWAYSTRUECOLOR
+            bitmap.bmiHeader.biCompression = BI_RGB;
+#else
+            if (__depth == 24) {
+                /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+                bitmap.r = 0xff0000;
+                bitmap.g = 0x00ff00;
+                bitmap.b = 0x0000ff;*/
+                bitmap.bmiHeader.biCompression = BI_RGB;
+            } else if (__depth == 16) {
+                bitmap.b = 0x001f;
+                bitmap.g = 0x07e0;
+                bitmap.r = 0xf800;*/
+                bitmap.bmiHeader.biCompression = BI_RGB;
+            } else {
+                error = __MKSTRING("primGetBitsFromPixmap: unsupported depth");
+                got fail;
+            }
+#endif /* ALWAYSTRUECOLOR */
+            bitmap.bmiHeader.biSizeImage = 0;
+            bitmap.bmiHeader.biXPelsPerMeter = 0;
+            bitmap.bmiHeader.biYPelsPerMeter = 0;
+            bitmap.bmiHeader.biClrUsed = 0;
+            bitmap.bmiHeader.biClrImportant = 0;
+
+            bitmap.bmiHeader.biWidth = width;
+            bitmap.bmiHeader.biHeight = -height;
+            bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel;
+
+            if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
+            {
+                error = __MKSTRING("GetDIBits failed");
+                goto out;
+            }
+            BMDPRINTF(("bitmap info:%d %d %d %d\n",bitmap.bmiHeader.biWidth,bitmap.bmiHeader.biHeight,bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biSizeImage));
+            numBytes = bitmap.bmiHeader.biSizeImage;
+            if ( numBytes != 0 ) {
+                if (numBytes > __byteArraySize(imageBits)) {
+                    /* imageBits too small */
+                    error = __MKSTRING("provided byteArray too small");
+                    goto out;
+                }
+                BMDPRINTF(("numBytes %d\n",numBytes));
+
+                bitmap.bmiHeader.biHeight = -height;
+                bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel; /*__depth;*/
+                bitmap.rgb[0] = 0;
+                bitmap.rgb[1] = 0xffffff;
+                if (GetDIBits(xDC,xBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
+                {
+                    BMDPRINTF(("zero bits returned\n"));
+                    error = __MKSTRING("zero bits returned");
+                    goto out;
+                }
+
+#if 0
+                {
+                    /* swap red and blue (windows delivers BGR) */
+                    char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
+                    int n = numBytes;
+
+                    for ( ;n > 0; n -= 3, cp += 3) {
+                          char b = cp[0];
+                          cp[0] = cp[2];
+                          cp[2] = b;
+                    }
+                }
+#endif
+            } else {
+                error = __MKSTRING("unacceptable bitmap (size is 0 bytes)");
+                goto out;
+            }
+        } else {
+            error = __MKSTRING("unacceptable bitmap (null xBitmap)");
+            goto out;
+        }
+        bytesPerLine = __MKSMALLINT(numBytes/height);
+        format = (bitmap.bmiHeader.biBitCount == 1) ? @symbol(ZPixmap) : @symbol(XYPixmap);
+        bitmapPad = __MKSMALLINT(WIN32PADDING);
+        bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
+    }
+out:
+    if (bDC)
+        DeleteDC(bDC);
+    if (xDC)
+        ReleaseDC(0, xDC); //DeleteDC(xDC);
+    if (hBitmap)
+        DeleteObject(hBitmap);
+%}.
+
+    error notNil ifTrue:[
+        self primitiveFailed:error.
+    ].
+
+    ^ IdentityDictionary new
+            at:#bitOrder put:#msbFirst;
+            at:#depth put:1;
+            at:#bytesPerLine put:bytesPerLine;
+            at:#byteOrder put:#lsbFirst;
+            at:#format put:format;
+            at:#bitmapUnit put:0;
+            at:#bitmapPad put:bitmapPad;
+            at:#bitsPerPixel put:bitsPerPixel;
+            at:#redMask put:16rFF0000;
+            at:#greenMask put:16r00FF00;
+            at:#blueMask put:16r0000FF;
+            yourself.
+
+    "Modified (comment): / 28-03-2017 / 14:28:46 / stefan"
 !
 
 getPixelX:px y:py from:ignoredDrawableId with:aGCId
@@ -16575,397 +16886,6 @@
     }
 %}.
     ^ nil
-!
-
-primGetBitsFrom:aDrawableId x:srcX y:srcY width:w height:h into:imageBits infoInto:info
-
-%{
-    int     height, width;
-    unsigned int numBytes;
-    int     bytesPerRow;
-    HWND    hWnd;
-    HBITMAP hBitmap = 0;
-    HGDIOBJ hPrevious = 0;
-    HDC     bDC = 0;
-    struct {
-	BITMAPINFOHEADER bmiHeader;
-	DWORD r;
-	DWORD g;
-	DWORD b;
-    } bitmap;
-
-    if (! __isExternalAddress(aDrawableId)) {
-	INFOFPRINTF((stderr, "WinWorkstation [warning]: externalAddress arg\n"));
-	goto fail;
-    }
-    if (! __bothSmallInteger(srcX, srcY)) {
-	INFOFPRINTF((stderr, "WinWorkstation [warning]: x,y args\n"));
-	goto fail;
-    }
-    if (! __bothSmallInteger(w, h)) {
-	INFOFPRINTF((stderr, "WinWorkstation [warning]: w,h args\n"));
-	goto fail;
-    }
-    if (! __isArray(info)) {
-	INFOFPRINTF((stderr, "WinWorkstation [warning]: info arg\n"));
-	goto fail;
-    }
-    if (! __isByteArray(imageBits)) {
-	INFOFPRINTF((stderr, "WinWorkstation [warning]: info arg\n"));
-	goto fail;
-    }
-
-    {
-	hWnd = _HWNDVal( aDrawableId );
-	BMDPRINTF(("primGetBits %x\n",hWnd));
-	if( hWnd != 0 ) {
-	    HDC wDC;
-	    HANDLE prevBitmap;
-	    int widthRoundedUpToNextMultipleOf4 = ((width + 3 ) / 4) * 4;
-	    int widthUsed;
-
-	    bDC = CreateCompatibleDC(__rootDC);
-
-	    BMDPRINTF(("primGetBits srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
-	    height =  __intVal(h);
-	    width  =  __intVal(w);
-
-	    widthUsed = widthRoundedUpToNextMultipleOf4;
-	    widthUsed = width;
-
-	    BMDPRINTF(("width %d height %d\n",width,height));
-	    hBitmap = CreateCompatibleBitmap(__rootDC, widthUsed, height);
-	    if (!hBitmap) {
-		INFOFPRINTF((stderr, "WinWorkstation [warning]: CreateCompatibleBitmap failed\n"));
-		goto fail;
-	    }
-	    bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-	    bitmap.bmiHeader.biPlanes = 1;
-#ifdef ALWAYSTRUECOLOR
-	    bitmap.bmiHeader.biCompression = BI_RGB;
-	    bytesPerRow = (((width*3) + 3 ) / 4) * 4;
-#else
-	    if (__depth == 24) {
-		bitmap.bmiHeader.biCompression = BI_RGB;
-		bytesPerRow = (((width*3) + 3 ) / 4) * 4;
-	    } else if (__depth == 16) {
-# if 0
-		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
-		bitmap.b = 0x001f;
-		bitmap.g = 0x07e0;
-		bitmap.r = 0xf800;
-		bytesPerRow = (((width*2) + 1 ) / 4) * 4;
-# else
-		bitmap.b = 0;
-		bitmap.g = 0;
-		bitmap.r = 0;
-		bitmap.bmiHeader.biCompression = BI_RGB;
-		bytesPerRow = (((width*3) + 3 ) / 4) * 4;
-# endif
-	    }
-#endif /* ALWAYSTRUECOLOR */
-	    bitmap.bmiHeader.biSizeImage = 0;
-	    bitmap.bmiHeader.biXPelsPerMeter = 0;
-	    bitmap.bmiHeader.biYPelsPerMeter = 0;
-	    bitmap.bmiHeader.biClrUsed = 0;
-	    bitmap.bmiHeader.biClrImportant = 0;
-	    bitmap.bmiHeader.biBitCount = __depth;
-
-	    bitmap.bmiHeader.biWidth = widthUsed;
-	    bitmap.bmiHeader.biHeight = -height;
-
-	    wDC = GetDC(hWnd);
-
-	    hPrevious = SelectObject(bDC, hBitmap);
-	    if (BitBlt(bDC,
-		   0,0,
-		   width,height,
-		   wDC,
-		   __intVal(srcX), __intVal(srcY),
-		   SRCCOPY|CAPTUREBLT)
-		 == 0
-		)
-	    {
-		INFOFPRINTF((stderr, "WinWorkstation [warning]: in primGetBitsFrom: BitBlt\n"));
-	    }
-
-#ifdef CACHE_LAST_DC
-	    if (lastGcData && (lastGcData->_hDC == wDC)) {
-# ifdef DEBUG_DC_REUSE
-		console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - cachedDC reuse\n", __LINE__);
-# endif
-	    } else
-#endif
-	    {
-#ifdef CACHE_LAST_WM_PAINT_DC
-		if (last_wm_paint_dc && (last_wm_paint_dc == wDC)) {
-# ifdef DEBUG_DC_REUSE
-		    console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - last_wm_paint_dc reuse\n", __LINE__);
-# endif
-		} else
-#endif
-		{
-		    ReleaseDC(hWnd, wDC);
-		}
-	    }
-
-	    if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
-	    {
-		INFOFPRINTF((stderr, "WinWorkstation [warning]: noinfo returned in primGetBits\n"));
-		goto fail;
-	    }
-	    BMDPRINTF(("bitmap info:%d %d %d %d\n",
-			bitmap.bmiHeader.biWidth, bitmap.bmiHeader.biHeight,
-			bitmap.bmiHeader.biBitCount, bitmap.bmiHeader.biSizeImage));
-	    numBytes = bitmap.bmiHeader.biSizeImage;
-	    if( numBytes != 0 ) {
-		if (numBytes > __byteArraySize(imageBits)) {
-		    /* imageBits too small */
-		    INFOFPRINTF((stderr, "WinWorkstation [warning]: primGetBits - byteArray too small (is:%d need:%d; w:%d h:%d)\n",
-				__byteArraySize(imageBits), numBytes,
-				bitmap.bmiHeader.biWidth, -bitmap.bmiHeader.biHeight
-			     ));
-		    goto fail;
-		}
-		BMDPRINTF(("numBytes %d\n",numBytes));
-
-		bitmap.bmiHeader.biHeight = -height;
-		if (GetDIBits(bDC,hBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
-		{
-		    INFOFPRINTF((stderr, "WinWorkstation [warning]: zero bits returned in primGetBits\n"));
-		    goto fail;
-		}
-
-		/* swap red and blue (windows delivers BGR) */
-		{
-		    char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
-#ifdef PRE_18_FEB_05
-		    int n = numBytes;
-		    for ( ;n > 0; n -= 3, cp += 3) {
-			  char b = cp[0];
-			  cp[0] = cp[2];
-			  cp[2] = b;
-		    }
-#else
-		    int _h;
-		    char *rowp = cp;
-
-		    for (_h=height; _h>0; _h--) {
-			int _w;
-			char *pixel = rowp;
-
-			for (_w=width; _w>0; _w--) {
-			    char b;
-
-			    b = pixel[0];
-			    pixel[0] = pixel[2];
-			    pixel[2] = b;
-			    pixel += 3;
-			};
-			rowp += bytesPerRow;
-		    };
-#endif
-		}
-	    } else {
-		INFOFPRINTF((stderr, "WinWorkstation [warning]: unacceptable bitmap in primGetBits\n"));
-		goto fail;
-	    }
-	} else {
-	    INFOFPRINTF((stderr, "WinWorkstation [warning]: unacceptable HWND in primGetBits\n"));
-	    goto fail;
-	}
-
-	__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst);                                 // bitOrder
-	__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(1);                                   // depth
-	__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(bytesPerRow);                         // bytesPerLine
-	__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst);                                 // byteOrder
-	__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap);                                 // format
-	__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(0);                                   // bitmapUnit
-	__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(WIN32PADDING);                        // bitmapPad
-	__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(bitmap.bmiHeader.biBitCount);         // bitsPerPixel
-	__ArrayInstPtr(info)->a_element[8] = __MKSMALLINT(0x0000FF);   // redMask
-	__ArrayInstPtr(info)->a_element[9] = __MKSMALLINT(0x00FF00);   // greenMask
-	__ArrayInstPtr(info)->a_element[10] = __MKSMALLINT(0xFF0000);  // blueMask
-	if ((hPrevious != NULL) && (bDC != NULL))
-	    SelectObject(bDC, hPrevious);
-	if (bDC)
-	    DeleteDC(bDC);
-	if (hBitmap)
-	    _DeleteObject(hBitmap, __LINE__);
-	RETURN ( true );
-    }
-fail: ;
-    if ((hPrevious != NULL) && (bDC != NULL))
-	SelectObject(bDC, hPrevious);
-    if (bDC)
-	DeleteDC(bDC);
-    if (hBitmap)
-	_DeleteObject(hBitmap, __LINE__);
-%}.
-    ^ false
-!
-
-primGetBitsFromPixmap:aDrawableId x:srcX y:srcY width:w height:h into:imageBits infoInto:info
-
-%{
-    int            height, width;
-    unsigned int   numBytes;
-    unsigned char* ep = 0;
-    HBITMAP        xBitmap;
-    HBITMAP hBitmap = 0;
-    HDC bDC = 0;
-    HDC xDC = 0;
-    struct
-    {
-	BITMAPINFOHEADER bmiHeader;
-	DWORD rgb[2];
-    } bitmap;
-    BITMAP bitmapInfo;
-
-    if (__isExternalAddress(aDrawableId)
-     && __bothSmallInteger(srcX, srcY)
-     && __bothSmallInteger(w, h)
-     && __isArray(info)
-     && __isByteArray(imageBits))
-    {
-	xBitmap = _HBITMAPVAL( aDrawableId );
-	BMDPRINTF(("primGetBitsFromPixmap %x\n",xBitmap));
-	if (xBitmap != 0) {
-	    xDC = GetDC(0);
-	    SelectObject(xDC, xBitmap);
-	    GetObject(xBitmap,sizeof(bitmapInfo),&bitmapInfo);
-
-	    bDC = CreateCompatibleDC(__rootDC);
-	    BMDPRINTF(("srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
-	    height =  __intVal(h);
-	    width  =  __intVal(w);
-	    BMDPRINTF(("width %d height %d\n",width,height));
-
-	    hBitmap = CreateCompatibleBitmap(xDC, width, height);
-	    if (!hBitmap)
-		goto fail;
-
-	    SelectObject(bDC,hBitmap);
-	    if (BitBlt(bDC,
-		   0,0,
-		   width,height,
-		   xDC,
-		   __intVal(srcX), __intVal(srcY),
-		   SRCCOPY)
-		 == 0
-		)
-	    {
-		 BMDPRINTF(("ERROR in primGetBitsFromPixmap: BitBlt\n"));
-		 goto fail;
-	    }
-	    bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-	    bitmap.bmiHeader.biPlanes = 1;
-#ifdef ALWAYSTRUECOLOR
-	    bitmap.bmiHeader.biCompression = BI_RGB;
-#else
-	    if (__depth == 24) {
-		/*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
-		bitmap.r = 0xff0000;
-		bitmap.g = 0x00ff00;
-		bitmap.b = 0x0000ff;*/
-		bitmap.bmiHeader.biCompression = BI_RGB;
-	    } else if (__depth == 16) {
-		/*bitmap.bmiHeader.biCompression = BI_RGB;
-		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
-		bitmap.b = 0x001f;
-		bitmap.g = 0x07e0;
-		bitmap.r = 0xf800;*/
-		bitmap.bmiHeader.biCompression = BI_RGB;
-	    } else {
-		BMDPRINTF(("primGetBitsFromPixmap: unsupported depth\n"));
-		got fail;
-	    }
-#endif /* ALWAYSTRUECOLOR */
-	    bitmap.bmiHeader.biSizeImage = 0;
-	    bitmap.bmiHeader.biXPelsPerMeter = 0;
-	    bitmap.bmiHeader.biYPelsPerMeter = 0;
-	    bitmap.bmiHeader.biClrUsed = 0;
-	    bitmap.bmiHeader.biClrImportant = 0;
-
-	    bitmap.bmiHeader.biWidth = width;
-	    bitmap.bmiHeader.biHeight = -height;
-	    bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel;
-
-	    if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
-	    {
-		BMDPRINTF(("noinfo returned\n"));
-		goto fail;
-	    }
-	    BMDPRINTF(("bitmap info:%d %d %d %d\n",bitmap.bmiHeader.biWidth,bitmap.bmiHeader.biHeight,bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biSizeImage));
-	    numBytes = bitmap.bmiHeader.biSizeImage;
-	    if ( numBytes != 0 ) {
-		if (numBytes > __byteArraySize(imageBits)) {
-		    /* imageBits too small */
-		    BMDPRINTF(("provided byteArray too small\n"));
-		    goto fail;
-		}
-		BMDPRINTF(("numBytes %d\n",numBytes));
-
-		bitmap.bmiHeader.biHeight = -height;
-		bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel; /*__depth;*/
-		bitmap.rgb[0] = 0;
-		bitmap.rgb[1] = 0xffffff;
-		if (GetDIBits(xDC,xBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
-		{
-		    BMDPRINTF(("zero bits returned\n"));
-		    goto fail;
-		}
-
-#if 0
-		{
-		    /* swap red and blue (windows delivers BGR) */
-		    char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
-		    int n = numBytes;
-
-		    for ( ;n > 0; n -= 3, cp += 3) {
-			  char b = cp[0];
-			  cp[0] = cp[2];
-			  cp[2] = b;
-		    }
-		}
-#endif
-	    } else {
-		BMDPRINTF(("unacceptable bitmap\n"));
-		goto fail;
-	    }
-	} else {
-	    BMDPRINTF(("unacceptable bitmap\n"));
-	    goto fail;
-	}
-	__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst);
-	__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(1);
-	__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(numBytes/height);
-	__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst);
-	__ArrayInstPtr(info)->a_element[4] = (bitmap.bmiHeader.biBitCount == 1) ? @symbol(ZPixmap) : @symbol(XYPixmap);
-	__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(0);
-	__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(WIN32PADDING);
-	__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
-	__ArrayInstPtr(info)->a_element[8] = __MKSMALLINT(0xFF0000);   // redMask
-	__ArrayInstPtr(info)->a_element[9] = __MKSMALLINT(0x00FF00);   // greenMask
-	__ArrayInstPtr(info)->a_element[10] = __MKSMALLINT(0x0000FF);  // blueMask
-	if (bDC)
-	    DeleteDC(bDC);
-	if (xDC)
-	    ReleaseDC(0, xDC); //DeleteDC(xDC);
-	if (hBitmap)
-	    DeleteObject(hBitmap);
-	RETURN ( true );
-    }
-fail:
-    if (bDC)
-	DeleteDC(bDC);
-    if (xDC)
-	ReleaseDC(0, xDC); //DeleteDC(xDC);
-    if (hBitmap)
-	DeleteObject(hBitmap);
-
-%}.
-    ^ false
 ! !
 
 !WinWorkstation methodsFor:'style defaults'!
@@ -18963,7 +18883,7 @@
     }
 %}
     "
-     (StandardSystemView new label:'äöü') open
+     (StandardSystemView new label:'äöü') open
     "
 !