[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 2b08052 2/2: [graph/win32] Simplify icon settin
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] master 2b08052 2/2: [graph/win32] Simplify icon setting. |
Date: |
Sun, 22 May 2022 22:48:58 -0400 (EDT) |
branch: master
commit 2b08052931dd20a675573e855a4890d0207b52da
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[graph/win32] Simplify icon setting.
* graph/win32/grwin32.c (gr_win32_surface_set_icon): Use basic
`CreateBitmap` for color, which seems to work.
---
graph/win32/grwin32.c | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c
index 431e4c6..e7f2052 100644
--- a/graph/win32/grwin32.c
+++ b/graph/win32/grwin32.c
@@ -250,26 +250,9 @@ gr_win32_surface_set_icon( grWin32Surface* surface,
int s[] = { GetSystemMetrics( SM_CYSMICON ),
GetSystemMetrics( SM_CYICON ) };
WPARAM wParam;
- HDC hDC;
- VOID* bts;
ICONINFO ici = { TRUE };
HICON hIcon;
- /* NOTE: The Mingw64 header file `wingdi.h` defines this macro as `sRGB`,
- * which triggers the `-Wmultichar` warning during compilation, so replace
- * it with the corresponding numerical value.
- */
-#ifdef __MINGW64__
-# undef LCS_sRGB
-# define LCS_sRGB 0x73524742
-#endif
-
- BITMAPV4HEADER hdr = { sizeof( BITMAPV4HEADER ),
- 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0,
- 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
- LCS_sRGB };
-
-
if ( !icon )
return s[1];
else if ( icon->mode != gr_pixel_mode_rgb32 )
@@ -281,20 +264,14 @@ gr_win32_surface_set_icon( grWin32Surface* surface,
else
return 0;
- ici.hbmMask = CreateBitmap( icon->width, icon->rows, 1, 1, NULL);
-
- hdr.bV4Width = icon->width;
- hdr.bV4Height = -icon->rows;
-
- hDC = GetDC( NULL );
- ici.hbmColor = CreateDIBSection( hDC, (LPBITMAPINFO)&hdr,
- DIB_RGB_COLORS, &bts, NULL, 0 );
- ReleaseDC( NULL, hDC );
-
- memcpy( bts, icon->buffer, icon->rows * icon->width * 4 );
+ ici.hbmMask = CreateBitmap( icon->width, icon->rows, 1, 1, NULL );
+ ici.hbmColor = CreateBitmap( icon->width, icon->rows, 1, 32, icon->buffer );
hIcon = CreateIconIndirect( &ici );
+ DeleteObject( ici.hbmMask );
+ DeleteObject( ici.hbmColor );
+
PostMessage( surface->window, WM_SETICON, wParam, (LPARAM)hIcon );
switch( wParam )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 2b08052 2/2: [graph/win32] Simplify icon setting.,
Werner Lemberg <=