2012-07-05 11 views

답변

5

방금 ​​몇 시간을 낭비했습니다.

내가 이전에 여러 번 낭비 한 양과 합치면 네, 실망 스럽습니다.

GDI +에서 문제가 있음을 알 수 있습니다. 해결책은 here입니다. 도움이 될만한 코드는 다음과 같습니다.

HICON hIcon = ...; 

ICONINFO ii; GetIconInfo(hIcon, &ii); 
BITMAP bmp; GetObject(ii.hbmColor, sizeof(bmp), &bmp); 

Gdiplus::Bitmap temp(ii.hbmColor, NULL); 
Gdiplus::BitmapData lockedBitmapData; 
Gdiplus::Rect rc(0, 0, temp.GetWidth(), temp.GetHeight()); 

temp.LockBits(&rc, Gdiplus::ImageLockModeRead, temp.GetPixelFormat(), &lockedBitmapData); 

Gdiplus::Bitmap image(
    lockedBitmapData.Width, lockedBitmapData.Height, lockedBitmapData.Stride, 
    PixelFormat32bppARGB, reinterpret_cast<BYTE *>(lockedBitmapData.Scan0)); 

temp.UnlockBits(&lockedBitmapData); 

// Now 'image' has the icon, with transparency 
+1

많은 감사합니다. 나는 검은 선과 같은 문제를 겪고 있었다. 나는 당신의 해결책을 시도했고 또 다른 문제가 있었다 : 몇몇 선들과 픽셀들이 빠져 있었다. BITMAP을 사용하여이 코드를 적용하려고 시도했지만 이미지가 완벽하게 렌더링되었습니다. – sergiol

+0

위의 코드에서'data' 변수는 무엇입니까? – hackjutsu

+0

@hackjutsu :'lockedBitmapData'라고 생각했습니다. – Mehrdad