1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 1998-2002 Tor Lillqvist
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 #define GDK_PIXBUF_ENABLE_BACKEND /* Ugly? */
23 #include "gdkdisplay.h"
24 #include "gdkscreen.h"
25 #include "gdkcursor.h"
26 #include "gdkprivate-win32.h"
34 #if (defined(__MINGW32__) && __W32API_MAJOR_VERSION <= 3 && __W32API_MINOR_VERSION < 8) || (defined(_MSC_VER) && (WINVER < 0x0500))
43 LONG bV5XPelsPerMeter;
44 LONG bV5YPelsPerMeter;
46 DWORD bV5ClrImportant;
52 CIEXYZTRIPLE bV5Endpoints;
64 _gdk_win32_data_to_wcursor (GdkCursorType cursor_type)
69 guchar *and_plane, *xor_plane;
71 for (i = 0; i < G_N_ELEMENTS (cursors); i++)
72 if (cursors[i].type == cursor_type)
75 if (i >= G_N_ELEMENTS (cursors) || !cursors[i].name)
78 w = GetSystemMetrics (SM_CXCURSOR);
79 h = GetSystemMetrics (SM_CYCURSOR);
81 and_plane = g_malloc ((w/8) * h);
82 memset (and_plane, 0xff, (w/8) * h);
83 xor_plane = g_malloc ((w/8) * h);
84 memset (xor_plane, 0, (w/8) * h);
86 #define SET_BIT(v,b) (v |= (1 << b))
87 #define RESET_BIT(v,b) (v &= ~(1 << b))
89 for (j = 0, y = 0; y < cursors[i].height && y < h ; y++)
92 j = y * cursors[i].width;
94 for (x = 0; x < cursors[i].width && x < w ; x++, j++)
96 gint pofs = ofs + x / 8;
97 guchar data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
98 gint bit = 7 - (j % cursors[i].width) % 8;
102 RESET_BIT (and_plane[pofs], bit);
104 SET_BIT (xor_plane[pofs], bit);
112 rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
113 w, h, and_plane, xor_plane);
115 WIN32_API_FAILED ("CreateCursor");
123 _gdk_win32_cursor_new_from_hcursor (HCURSOR hcursor, GdkCursorType cursor_type)
125 GdkCursorPrivate *private;
128 private = g_new (GdkCursorPrivate, 1);
129 private->hcursor = hcursor;
130 cursor = (GdkCursor*) private;
131 cursor->type = cursor_type;
132 cursor->ref_count = 1;
138 gdk_cursor_new_for_display (GdkDisplay *display,
139 GdkCursorType cursor_type)
143 g_return_val_if_fail (display == _gdk_display, NULL);
145 hcursor = _gdk_win32_data_to_wcursor (cursor_type);
148 g_warning ("gdk_cursor_new_for_display: no cursor %d found", cursor_type);
150 GDK_NOTE (MISC, g_print ("gdk_cursor_new_for_display: %d: %p\n",
151 cursor_type, hcursor));
153 return _gdk_win32_cursor_new_from_hcursor (hcursor, cursor_type);
157 color_is_white (const GdkColor *color)
159 return (color->red == 0xFFFF
160 && color->green == 0xFFFF
161 && color->blue == 0xFFFF);
165 gdk_cursor_new_from_pixmap (GdkPixmap *source,
172 GdkPixmapImplWin32 *source_impl, *mask_impl;
173 guchar *source_bits, *mask_bits;
174 gint source_bpl, mask_bpl;
176 guchar *p, *q, *xor_mask, *and_mask;
177 gint width, height, cursor_width, cursor_height;
180 const gboolean bg_is_white = color_is_white (bg);
182 g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
183 g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
184 g_return_val_if_fail (fg != NULL, NULL);
185 g_return_val_if_fail (bg != NULL, NULL);
187 source_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (source)->impl);
188 mask_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (mask)->impl);
190 g_return_val_if_fail (source_impl->width == mask_impl->width
191 && source_impl->height == mask_impl->height,
193 width = source_impl->width;
194 height = source_impl->height;
195 cursor_width = GetSystemMetrics (SM_CXCURSOR);
196 cursor_height = GetSystemMetrics (SM_CYCURSOR);
198 g_return_val_if_fail (width <= cursor_width && height <= cursor_height,
201 residue = (1 << ((8-(width%8))%8)) - 1;
203 source_bits = source_impl->bits;
204 mask_bits = mask_impl->bits;
206 g_return_val_if_fail (GDK_PIXMAP_OBJECT (source)->depth == 1
207 && GDK_PIXMAP_OBJECT (mask)->depth == 1,
210 source_bpl = ((width - 1)/32 + 1)*4;
211 mask_bpl = ((mask_impl->width - 1)/32 + 1)*4;
213 #ifdef G_ENABLE_DEBUG
214 if (_gdk_debug_flags & GDK_DEBUG_CURSOR)
216 g_print ("gdk_cursor_new_from_pixmap: source=%p:\n",
217 source_impl->parent_instance.handle);
218 for (iy = 0; iy < height; iy++)
223 p = source_bits + iy*source_bpl;
224 for (ix = 0; ix < width; ix++)
228 g_print ("%c", ".X"[((*p)>>(7-(ix%8)))&1]);
234 g_print ("...mask=%p:\n", mask_impl->parent_instance.handle);
235 for (iy = 0; iy < height; iy++)
240 p = mask_bits + iy*source_bpl;
241 for (ix = 0; ix < width; ix++)
245 g_print ("%c", ".X"[((*p)>>(7-(ix%8)))&1]);
254 /* Such complex bit manipulation for this simple task, sigh.
255 * The X cursor and Windows cursor concepts are quite different.
256 * We assume here that we are always called with fg == black and
257 * bg == white, *or* the other way around. Random colours won't work.
258 * (Well, you will get a cursor, but not in those colours.)
261 /* Note: The comments below refer to the case fg==black and
262 * bg==white, as that was what was implemented first. The fg==white
263 * (the "if (fg->pixel)" branches) case was added later.
266 /* First set masked-out source bits, as all source bits matter on Windoze.
267 * As we invert them below, they will be clear in the final xor_mask.
269 for (iy = 0; iy < height; iy++)
271 p = source_bits + iy*source_bpl;
272 q = mask_bits + iy*mask_bpl;
274 for (ix = 0; ix < ((width-1)/8+1); ix++)
281 /* XOR mask is initialized to zero */
282 xor_mask = g_malloc0 (cursor_width/8 * cursor_height);
284 for (iy = 0; iy < height; iy++)
286 p = source_bits + iy*source_bpl;
287 q = xor_mask + iy*cursor_width/8;
289 for (ix = 0; ix < ((width-1)/8+1); ix++)
295 q[-1] &= ~residue; /* Clear left-over bits */
298 /* AND mask is initialized to ones */
299 and_mask = g_malloc (cursor_width/8 * cursor_height);
300 memset (and_mask, 0xFF, cursor_width/8 * cursor_height);
302 for (iy = 0; iy < height; iy++)
304 p = mask_bits + iy*mask_bpl;
305 q = and_mask + iy*cursor_width/8;
307 for (ix = 0; ix < ((width-1)/8+1); ix++)
310 q[-1] |= residue; /* Set left-over bits */
313 hcursor = CreateCursor (_gdk_app_hmodule, x, y, cursor_width, cursor_height,
316 GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: "
317 "%p (%dx%d) %p (%dx%d) = %p (%dx%d)\n",
318 GDK_PIXMAP_HBITMAP (source),
319 source_impl->width, source_impl->height,
320 GDK_PIXMAP_HBITMAP (mask),
321 mask_impl->width, mask_impl->height,
322 hcursor, cursor_width, cursor_height));
327 return _gdk_win32_cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
330 /* The named cursors below are presumably not really useful, as the
331 * names are Win32-specific. No GTK+ application developed on Unix
332 * (and most cross-platform GTK+ apps are developed on Unix) is going
333 * to look for cursors under these Win32 names anyway.
335 * Would the following make any sense: The ms-windows theme engine
336 * calls some (to-be-defined private) API here in gdk/win32 to
337 * register the relevant cursors used by the currently active XP
338 * visual style under the names that libgtk uses to look for them
339 * ("color-picker", "dnd-ask", "dnd-copy", etc), and then when libgtk
340 * asks for those we return the ones registered by the ms-windows
341 * theme engine, if any.
347 } _default_cursors[] = {
348 { "appstarting", IDC_APPSTARTING },
349 { "arrow", IDC_ARROW },
350 { "cross", IDC_CROSS },
352 { "hand", IDC_HAND },
354 { "help", IDC_HELP },
355 { "ibeam", IDC_IBEAM },
356 { "sizeall", IDC_SIZEALL },
357 { "sizenesw", IDC_SIZENESW },
358 { "sizens", IDC_SIZENS },
359 { "sizenwse", IDC_SIZENWSE },
360 { "sizewe", IDC_SIZEWE },
361 { "uparrow", IDC_UPARROW },
366 gdk_cursor_new_from_name (GdkDisplay *display,
369 HCURSOR hcursor = NULL;
372 g_return_val_if_fail (display == _gdk_display, NULL);
374 for (i = 0; i < G_N_ELEMENTS(_default_cursors); i++)
376 if (0 == strcmp(_default_cursors[i].name, name))
377 hcursor = LoadCursor (NULL, _default_cursors[i].id);
379 /* allow to load named cursor resources linked into the executable */
381 hcursor = LoadCursor (_gdk_app_hmodule, name);
384 return _gdk_win32_cursor_new_from_hcursor (hcursor, GDK_X_CURSOR);
390 _gdk_cursor_destroy (GdkCursor *cursor)
392 GdkCursorPrivate *private;
394 g_return_if_fail (cursor != NULL);
395 private = (GdkCursorPrivate *) cursor;
397 GDK_NOTE (MISC, g_print ("_gdk_cursor_destroy: %p\n",
398 (cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->hcursor : 0));
400 if (GetCursor () == private->hcursor)
403 if (!DestroyCursor (private->hcursor))
404 WIN32_API_FAILED ("DestroyCursor");
410 gdk_cursor_get_display (GdkCursor *cursor)
412 return gdk_display_get_default ();
416 gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon)
418 GdkPixbuf *pixbuf = NULL;
426 gchar *pixels, *bits, buf[32];
427 gint rowstride, x, y, w, h;
429 if (!GDI_CALL (GetIconInfo, (hicon, &ii)))
432 if (!(hdc = CreateCompatibleDC (NULL)))
434 WIN32_GDI_FAILED ("CreateCompatibleDC");
438 memset (&bmi, 0, sizeof (bmi));
439 bmi.bi.biSize = sizeof (bmi.bi);
441 if (ii.hbmColor != NULL)
447 if (!GDI_CALL (GetDIBits, (hdc, ii.hbmColor, 0, 1, NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS)))
453 bmi.bi.biBitCount = 32;
454 bmi.bi.biCompression = BI_RGB;
455 bmi.bi.biHeight = -h;
457 bits = g_malloc0 (4 * w * h);
460 if (!GDI_CALL (GetDIBits, (hdc, ii.hbmColor, 0, h, bits, (BITMAPINFO *)&bmi, DIB_RGB_COLORS)))
463 pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w, h);
464 pixels = gdk_pixbuf_get_pixels (pixbuf);
465 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
467 for (y = 0; y < h; y++)
469 for (x = 0; x < w; x++)
471 pixels[2] = bits[(x+y*w) * 4];
472 pixels[1] = bits[(x+y*w) * 4 + 1];
473 pixels[0] = bits[(x+y*w) * 4 + 2];
474 pixels[3] = bits[(x+y*w) * 4 + 3];
475 if (no_alpha && pixels[3] > 0)
479 pixels += (w * 4 - rowstride);
484 GDI_CALL (GetDIBits, (hdc, ii.hbmMask, 0, h, bits, (BITMAPINFO *)&bmi, DIB_RGB_COLORS)))
486 pixels = gdk_pixbuf_get_pixels (pixbuf);
487 for (y = 0; y < h; y++)
489 for (x = 0; x < w; x++)
491 pixels[3] = 255 - bits[(x + y * w) * 4];
494 pixels += (w * 4 - rowstride);
504 if (!GDI_CALL (GetDIBits, (hdc, ii.hbmMask, 0, 0, NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS)))
508 h = ABS (bmi.bi.biHeight) / 2;
510 bits = g_malloc0 (4 * w * h);
513 if (!GDI_CALL (GetDIBits, (hdc, ii.hbmMask, 0, h*2, bits, (BITMAPINFO *)&bmi, DIB_RGB_COLORS)))
516 pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w, h);
517 pixels = gdk_pixbuf_get_pixels (pixbuf);
518 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
519 bpl = ((w-1)/32 + 1)*4;
521 for (y = 0; y < h*2; y++)
523 for (x = 0; x < w; x++)
525 const gint bit = 7 - (x % 8);
526 printf ("%c ", ((bits[bpl*y+x/8])&(1<<bit)) ? ' ' : 'X');
532 for (y = 0; y < h; y++)
534 const guchar *andp, *xorp;
535 if (bmi.bi.biHeight < 0)
538 xorp = bits + bpl*(h+y);
542 andp = bits + bpl*(h-y-1);
543 xorp = bits + bpl*(h+h-y-1);
545 for (x = 0; x < w; x++)
547 const gint bit = 7 - (x % 8);
548 if ((*andp) & (1<<bit))
550 if ((*xorp) & (1<<bit))
551 pixels[2] = pixels[1] = pixels[0] = 0xFF;
553 pixels[2] = pixels[1] = pixels[0] = 0;
558 pixels[2] = pixels[1] = pixels[0] = 0;
568 pixels += (w * 4 - rowstride);
572 g_snprintf (buf, sizeof (buf), "%ld", ii.xHotspot);
573 gdk_pixbuf_set_option (pixbuf, "x_hot", buf);
575 g_snprintf (buf, sizeof (buf), "%ld", ii.yHotspot);
576 gdk_pixbuf_set_option (pixbuf, "y_hot", buf);
578 /* release temporary resources */
584 DeleteObject (ii.hbmColor);
585 DeleteObject (ii.hbmMask);
591 gdk_cursor_get_image (GdkCursor *cursor)
593 g_return_val_if_fail (cursor != NULL, NULL);
595 return gdk_win32_icon_to_pixbuf_libgtk_only (((GdkCursorPrivate *) cursor)->hcursor);
599 gdk_cursor_new_from_pixbuf (GdkDisplay *display,
606 g_return_val_if_fail (display == _gdk_display, NULL);
607 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
608 g_return_val_if_fail (0 <= x && x < gdk_pixbuf_get_width (pixbuf), NULL);
609 g_return_val_if_fail (0 <= y && y < gdk_pixbuf_get_height (pixbuf), NULL);
611 hcursor = _gdk_win32_pixbuf_to_hcursor (pixbuf, x, y);
614 return _gdk_win32_cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
618 gdk_display_supports_cursor_alpha (GdkDisplay *display)
620 g_return_val_if_fail (display == _gdk_display, FALSE);
622 return _gdk_win32_pixbuf_to_hicon_supports_alpha ();
626 gdk_display_supports_cursor_color (GdkDisplay *display)
628 g_return_val_if_fail (display == _gdk_display, FALSE);
634 gdk_display_get_default_cursor_size (GdkDisplay *display)
636 g_return_val_if_fail (display == _gdk_display, 0);
638 return MIN (GetSystemMetrics (SM_CXCURSOR), GetSystemMetrics (SM_CYCURSOR));
642 gdk_display_get_maximal_cursor_size (GdkDisplay *display,
646 g_return_if_fail (display == _gdk_display);
649 *width = GetSystemMetrics (SM_CXCURSOR);
651 *height = GetSystemMetrics (SM_CYCURSOR);
655 /* Convert a pixbuf to an HICON (or HCURSOR). Supports alpha under
656 * Windows XP, thresholds alpha otherwise. Also used from
657 * gdkwindow-win32.c for creating application icons.
661 create_alpha_bitmap (gint size,
668 ZeroMemory (&bi, sizeof (BITMAPV5HEADER));
669 bi.bV5Size = sizeof (BITMAPV5HEADER);
670 bi.bV5Height = bi.bV5Width = size;
673 bi.bV5Compression = BI_BITFIELDS;
674 /* The following mask specification specifies a supported 32 BPP
675 * alpha format for Windows XP (BGRA format).
677 bi.bV5RedMask = 0x00FF0000;
678 bi.bV5GreenMask = 0x0000FF00;
679 bi.bV5BlueMask = 0x000000FF;
680 bi.bV5AlphaMask = 0xFF000000;
682 /* Create the DIB section with an alpha channel. */
686 WIN32_GDI_FAILED ("GetDC");
689 hBitmap = CreateDIBSection (hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS,
690 (PVOID *) outdata, NULL, (DWORD)0);
692 WIN32_GDI_FAILED ("CreateDIBSection");
693 ReleaseDC (NULL, hdc);
699 create_color_bitmap (gint size,
704 BITMAPV4HEADER bmiHeader;
705 RGBQUAD bmiColors[2];
710 ZeroMemory (&bmi, sizeof (bmi));
711 bmi.bmiHeader.bV4Size = sizeof (BITMAPV4HEADER);
712 bmi.bmiHeader.bV4Height = bmi.bmiHeader.bV4Width = size;
713 bmi.bmiHeader.bV4Planes = 1;
714 bmi.bmiHeader.bV4BitCount = bits;
715 bmi.bmiHeader.bV4V4Compression = BI_RGB;
717 /* when bits is 1, these will be used.
718 * bmiColors[0] already zeroed from ZeroMemory()
720 bmi.bmiColors[1].rgbBlue = 0xFF;
721 bmi.bmiColors[1].rgbGreen = 0xFF;
722 bmi.bmiColors[1].rgbRed = 0xFF;
727 WIN32_GDI_FAILED ("GetDC");
730 hBitmap = CreateDIBSection (hdc, (BITMAPINFO *)&bmi, DIB_RGB_COLORS,
731 (PVOID *) outdata, NULL, (DWORD)0);
733 WIN32_GDI_FAILED ("CreateDIBSection");
734 ReleaseDC (NULL, hdc);
740 pixbuf_to_hbitmaps_alpha_winxp (GdkPixbuf *pixbuf,
744 /* Based on code from
745 * http://www.dotnet247.com/247reference/msgs/13/66301.aspx
747 HBITMAP hColorBitmap, hMaskBitmap;
748 guchar *indata, *inrow;
749 guchar *colordata, *colorrow, *maskdata, *maskbyte;
750 gint width, height, size, i, i_offset, j, j_offset, rowstride;
751 guint maskstride, mask_bit;
753 width = gdk_pixbuf_get_width (pixbuf); /* width of icon */
754 height = gdk_pixbuf_get_height (pixbuf); /* height of icon */
756 /* The bitmaps are created square */
757 size = MAX (width, height);
759 hColorBitmap = create_alpha_bitmap (size, &colordata);
762 hMaskBitmap = create_color_bitmap (size, &maskdata, 1);
765 DeleteObject (hColorBitmap);
769 /* MSDN says mask rows are aligned to "LONG" boundaries */
770 maskstride = (((size + 31) & ~31) >> 3);
772 indata = gdk_pixbuf_get_pixels (pixbuf);
773 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
778 j_offset = (width - height) / 2;
782 i_offset = (height - width) / 2;
786 for (j = 0; j < height; j++)
788 colorrow = colordata + 4*(j+j_offset)*size + 4*i_offset;
789 maskbyte = maskdata + (j+j_offset)*maskstride + i_offset/8;
790 mask_bit = (0x80 >> (i_offset % 8));
791 inrow = indata + (height-j-1)*rowstride;
792 for (i = 0; i < width; i++)
794 colorrow[4*i+0] = inrow[4*i+2];
795 colorrow[4*i+1] = inrow[4*i+1];
796 colorrow[4*i+2] = inrow[4*i+0];
797 colorrow[4*i+3] = inrow[4*i+3];
798 if (inrow[4*i+3] == 0)
799 maskbyte[0] |= mask_bit; /* turn ON bit */
801 maskbyte[0] &= ~mask_bit; /* turn OFF bit */
811 *color = hColorBitmap;
818 pixbuf_to_hbitmaps_normal (GdkPixbuf *pixbuf,
822 /* Based on code from
823 * http://www.dotnet247.com/247reference/msgs/13/66301.aspx
825 HBITMAP hColorBitmap, hMaskBitmap;
826 guchar *indata, *inrow;
827 guchar *colordata, *colorrow, *maskdata, *maskbyte;
828 gint width, height, size, i, i_offset, j, j_offset, rowstride, nc, bmstride;
830 guint maskstride, mask_bit;
832 width = gdk_pixbuf_get_width (pixbuf); /* width of icon */
833 height = gdk_pixbuf_get_height (pixbuf); /* height of icon */
835 /* The bitmaps are created square */
836 size = MAX (width, height);
838 hColorBitmap = create_color_bitmap (size, &colordata, 24);
841 hMaskBitmap = create_color_bitmap (size, &maskdata, 1);
844 DeleteObject (hColorBitmap);
848 /* rows are always aligned on 4-byte boundarys */
850 if (bmstride % 4 != 0)
851 bmstride += 4 - (bmstride % 4);
853 /* MSDN says mask rows are aligned to "LONG" boundaries */
854 maskstride = (((size + 31) & ~31) >> 3);
856 indata = gdk_pixbuf_get_pixels (pixbuf);
857 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
858 nc = gdk_pixbuf_get_n_channels (pixbuf);
859 has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
864 j_offset = (width - height) / 2;
868 i_offset = (height - width) / 2;
872 for (j = 0; j < height; j++)
874 colorrow = colordata + (j+j_offset)*bmstride + 3*i_offset;
875 maskbyte = maskdata + (j+j_offset)*maskstride + i_offset/8;
876 mask_bit = (0x80 >> (i_offset % 8));
877 inrow = indata + (height-j-1)*rowstride;
878 for (i = 0; i < width; i++)
880 if (has_alpha && inrow[nc*i+3] < 128)
882 colorrow[3*i+0] = colorrow[3*i+1] = colorrow[3*i+2] = 0;
883 maskbyte[0] |= mask_bit; /* turn ON bit */
887 colorrow[3*i+0] = inrow[nc*i+2];
888 colorrow[3*i+1] = inrow[nc*i+1];
889 colorrow[3*i+2] = inrow[nc*i+0];
890 maskbyte[0] &= ~mask_bit; /* turn OFF bit */
901 *color = hColorBitmap;
908 pixbuf_to_hicon (GdkPixbuf *pixbuf,
920 if (_gdk_win32_pixbuf_to_hicon_supports_alpha() && gdk_pixbuf_get_has_alpha (pixbuf))
921 success = pixbuf_to_hbitmaps_alpha_winxp (pixbuf, &ii.hbmColor, &ii.hbmMask);
923 success = pixbuf_to_hbitmaps_normal (pixbuf, &ii.hbmColor, &ii.hbmMask);
931 icon = CreateIconIndirect (&ii);
932 DeleteObject (ii.hbmColor);
933 DeleteObject (ii.hbmMask);
938 _gdk_win32_pixbuf_to_hicon (GdkPixbuf *pixbuf)
940 return pixbuf_to_hicon (pixbuf, TRUE, 0, 0);
944 _gdk_win32_pixbuf_to_hcursor (GdkPixbuf *pixbuf,
948 return pixbuf_to_hicon (pixbuf, FALSE, x_hotspot, y_hotspot);
952 _gdk_win32_pixbuf_to_hicon_supports_alpha (void)
954 static gboolean is_win_xp=FALSE, is_win_xp_checked=FALSE;
956 if (!is_win_xp_checked)
958 OSVERSIONINFO version;
960 is_win_xp_checked = TRUE;
962 memset (&version, 0, sizeof (version));
963 version.dwOSVersionInfoSize = sizeof (version);
964 is_win_xp = GetVersionEx (&version)
965 && version.dwPlatformId == VER_PLATFORM_WIN32_NT
966 && (version.dwMajorVersion > 5
967 || (version.dwMajorVersion == 5 && version.dwMinorVersion >= 1));
973 gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf)
975 return _gdk_win32_pixbuf_to_hicon (pixbuf);