< prev index next >

src/java.desktop/windows/native/libfontmanager/lcdglyph.c

Print this page

        

@@ -155,10 +155,13 @@
         DeleteObject(hMemoryDC); \
     } \
     if (hBitmap != 0) { \
         DeleteObject(hBitmap); \
     } \
+    if (tmpBitmap != 0) { \
+        DeleteObject(tmpBitmap); \
+    } \
     if (dibImage != NULL) { \
         free(dibImage); \
     } \
     if (glyphInfo != NULL) { \
         free(glyphInfo); \

@@ -194,10 +197,11 @@
     int topLeftY;
     int err;
     int bmWidth, bmHeight;
     int x, y;
     HBITMAP hBitmap = NULL, hOrigBM;
+    HBITMAP tmpBitmap = NULL;
     int gamma, orient;
 
     HWND hWnd = NULL;
     HDC hDesktopDC = NULL;
     HDC hMemoryDC = NULL;

@@ -248,10 +252,16 @@
     if (hFont == NULL) {
         FREE_AND_RETURN;
     }
     oldFont = SelectObject(hMemoryDC, hFont);
 
+    tmpBitmap = CreateCompatibleBitmap(hDesktopDC, 1, 1);
+    if (tmpBitmap == NULL) {
+        FREE_AND_RETURN;
+    }
+    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, tmpBitmap);
+
     memset(&textMetric, 0, sizeof(TEXTMETRIC));
     err = GetTextMetrics(hMemoryDC, &textMetric);
     if (err == 0) {
         FREE_AND_RETURN;
     }

@@ -332,11 +342,11 @@
     /* Must use desktop DC to create a bitmap of that depth */
     hBitmap = CreateCompatibleBitmap(hDesktopDC, bmWidth, bmHeight);
     if (hBitmap == NULL) {
         FREE_AND_RETURN;
     }
-    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, hBitmap);
+    SelectObject(hMemoryDC, hBitmap);
 
     /* Fill in black */
     rect.left = 0;
     rect.top = 0;
     rect.right = bmWidth;

@@ -476,8 +486,9 @@
 
     free(dibImage);
     ReleaseDC(hWnd, hDesktopDC);
     DeleteObject(hMemoryDC);
     DeleteObject(hBitmap);
+    DeleteObject(tmpBitmap);
 
     return ptr_to_jlong(glyphInfo);
 }
< prev index next >