diff options
Diffstat (limited to 'win/tkWinWm.c')
-rw-r--r-- | win/tkWinWm.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/win/tkWinWm.c b/win/tkWinWm.c index e089985..2b6fde3 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWm.c,v 1.116 2007/05/04 21:29:23 patthoyts Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.116.2.1 2007/06/12 16:22:45 dgp Exp $ */ #include "tkWinInt.h" @@ -4327,7 +4327,8 @@ WmIconphotoCmd( TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */ Tk_PhotoHandle photo; Tk_PhotoImageBlock block; - int i, width, height, startObj = 3; + int i, width, height, idx, bufferSize, startObj = 3; + unsigned char *bgraPixelPtr; BlockOfIconImagesPtr lpIR; WinIconPtr titlebaricon = NULL; HICON hIcon; @@ -4380,11 +4381,20 @@ WmIconphotoCmd( Tk_PhotoGetImage(photo, &block); /* - * Encode the image data into an HICON. + * Convert the image data into BGRA format (RGBQUAD) and then + * encode the image data into an HICON. */ - + bufferSize = height * width * block.pixelSize; + bgraPixelPtr = ckalloc(bufferSize); + for (idx = 0 ; idx < bufferSize ; idx += 4) { + bgraPixelPtr[idx] = block.pixelPtr[idx+2]; + bgraPixelPtr[idx+1] = block.pixelPtr[idx+1]; + bgraPixelPtr[idx+2] = block.pixelPtr[idx+0]; + bgraPixelPtr[idx+3] = block.pixelPtr[idx+3]; + } hIcon = CreateIcon(Tk_GetHINSTANCE(), width, height, 1, 32, - NULL, (BYTE *) block.pixelPtr); + NULL, (BYTE *) bgraPixelPtr); + ckfree(bgraPixelPtr); if (hIcon == NULL) { /* * XXX should free up created icons. |