Index: dlls/user/cursoricon.c
===================================================================
RCS file: /home/wine/wine/dlls/user/cursoricon.c,v
retrieving revision 1.25
diff -u -r1.25 cursoricon.c
--- dlls/user/cursoricon.c	10 Jan 2006 20:15:41 -0000	1.25
+++ dlls/user/cursoricon.c	26 Jan 2006 22:50:25 -0000
@@ -2305,19 +2305,114 @@
     {
         case IMAGE_BITMAP:
         {
-            HBITMAP res;
-            BITMAP bm;
+	    HBITMAP res = NULL;
+	    HDC hScreenDC;
+	    HDC hMemDC_dst,hMemDC_src;
 
-            if (!GetObjectW( hnd, sizeof(bm), &bm )) return 0;
-            bm.bmBits = NULL;
-            if ((res = CreateBitmapIndirect(&bm)))
-            {
-                char *buf = HeapAlloc( GetProcessHeap(), 0, bm.bmWidthBytes * bm.bmHeight );
-                GetBitmapBits( hnd, bm.bmWidthBytes * bm.bmHeight, buf );
-                SetBitmapBits( res, bm.bmWidthBytes * bm.bmHeight, buf );
-                HeapFree( GetProcessHeap(), 0, buf );
-            }
-            return (HICON)res;
+	    if((flags & LR_CREATEDIBSECTION) != LR_CREATEDIBSECTION)
+	    {
+		BITMAP bm;
+
+		if (!GetObjectW( hnd, sizeof(bm), &bm )) return 0;
+		bm.bmBits = NULL;
+		if(desiredx == 0)
+		    desiredx = bm.bmWidth;
+		if(desiredy == 0)
+		    desiredy = bm.bmHeight;
+
+		hScreenDC = GetDC(0);
+		hMemDC_dst = CreateCompatibleDC(hScreenDC);
+		hMemDC_src = CreateCompatibleDC(hScreenDC);
+
+		if((res = CreateCompatibleBitmap(hScreenDC,bm.bmWidth,bm.bmHeight)))
+		{
+		    HGDIOBJ hDstOldBmp,hSrcOldBmp;
+		    hDstOldBmp = SelectObject(hMemDC_dst,res);
+		    hSrcOldBmp = SelectObject(hMemDC_src,hnd);
+		    if(desiredx == bm.bmWidth && desiredy == bm.bmHeight)
+		    {
+			
+			BitBlt(hMemDC_dst,0,0,bm.bmWidth,bm.bmHeight,hMemDC_src,0,0,SRCCOPY);
+		    }
+		    else
+		    {
+			StretchBlt(hMemDC_dst,0,0,desiredx,desiredy,hMemDC_src,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
+		    }
+		    SelectObject(hMemDC_dst,hDstOldBmp);
+		    SelectObject(hMemDC_src,hSrcOldBmp);
+		    DeleteDC(hMemDC_dst);
+		    DeleteDC(hMemDC_src);
+		}
+
+		ReleaseDC(0,hScreenDC);
+	    }
+	    else
+	    {
+		BITMAPINFO* pbmi;
+		DIBSECTION dib;
+		int size;
+		char *bmibuf;
+		int nColor;
+
+		if (!(size = GetObjectW( hnd, sizeof(dib), &dib ))) return 0;
+		if(desiredx == 0)
+		    desiredx = dib.dsBm.bmWidth;
+		if(desiredy == 0)
+		    desiredy = dib.dsBm.bmHeight;
+		
+		hScreenDC = GetDC(0);
+		hMemDC_dst = CreateCompatibleDC(hScreenDC);
+		hMemDC_src = CreateCompatibleDC(hScreenDC);
+		
+		nColor=0;
+		if(size == sizeof(BITMAP)) // No DIB section in source.
+		{
+		    bmibuf = HeapAlloc( GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER));
+		    pbmi = (BITMAPINFO*)bmibuf;
+		    ZeroMemory(pbmi,sizeof(BITMAPINFOHEADER)+nColor*sizeof(RGBQUAD));
+		    pbmi->bmiHeader.biSize = sizeof(pbmi->bmiHeader);
+		    pbmi->bmiHeader.biWidth = dib.dsBm.bmWidth;
+		    pbmi->bmiHeader.biHeight = dib.dsBm.bmHeight;
+		    pbmi->bmiHeader.biPlanes = dib.dsBm.bmPlanes;
+		    pbmi->bmiHeader.biBitCount = dib.dsBm.bmBitsPixel;
+		    pbmi->bmiHeader.biCompression = BI_RGB;
+		}
+		else
+		{
+		    nColor = dib.dsBmih.biClrUsed;
+
+		    bmibuf = HeapAlloc( GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER)+nColor*sizeof(RGBQUAD));
+		    pbmi = (BITMAPINFO*)bmibuf;
+
+		    CopyMemory(&pbmi->bmiHeader,&dib.dsBmih,sizeof(BITMAPINFOHEADER));
+		    if(nColor > 0)
+			GetDIBColorTable(hScreenDC,0,nColor,pbmi->bmiColors);
+		}
+		
+
+		if((res = CreateDIBSection(hScreenDC,pbmi,DIB_RGB_COLORS,NULL,NULL,0)))
+		{
+		    HGDIOBJ hDstOldBmp,hSrcOldBmp;
+		    hDstOldBmp = SelectObject(hMemDC_dst,res);
+		    hSrcOldBmp = SelectObject(hMemDC_src,hnd);
+		    if(desiredx == dib.dsBm.bmWidth && desiredy == dib.dsBm.bmHeight)
+		    {
+			BitBlt(hMemDC_dst,0,0,dib.dsBm.bmWidth,dib.dsBm.bmHeight,hMemDC_src,0,0,SRCCOPY);
+		    }
+		    else
+		    {
+			StretchBlt(hMemDC_dst,0,0,desiredx,desiredy,hMemDC_src,0,0,dib.dsBm.bmWidth,dib.dsBm.bmHeight,SRCCOPY);
+		    }
+		    SelectObject(hMemDC_dst,hDstOldBmp);
+		    SelectObject(hMemDC_src,hSrcOldBmp);
+		    DeleteDC(hMemDC_dst);
+		    DeleteDC(hMemDC_src);
+		}
+		HeapFree( GetProcessHeap(), 0, bmibuf );
+
+		ReleaseDC(0,hScreenDC);
+	    }
+	    return (HICON)res;
         }
         case IMAGE_ICON:
                 return CURSORICON_ExtCopy(hnd,type, desiredx, desiredy, flags);
