0
我想用gdi +繪製一個圖標。當直接從磁盤加載圖標文件時,我的工作正常,但如果可能,我想將圖標存儲在資源中。有沒有一種簡單的方法可以做到這一點而不會失去解決方案?Gdiplus ::圖標資源圖片?
// The image draws and looks exactly how I want it to
Gdiplus::Image indicator(L"\\Indicator.ico");
graphics->DrawImage(&indicator, 7, 7);
// The image draws, but looks bloated and pixel-y
const HICON hIcon = AfxGetApp()->LoadIcon(IDI_INDICATOR);
if (hIcon)
{
Gdiplus::Bitmap* bitmap = Gdiplus::Bitmap::FromHICON(hIcon);
graphics->DrawImage(bitmap, 7, 7);
}
你只是不想使用Bitmap :: FromHICON(),它將一個糟糕的工作映射到圖像。圖像將只有來自預先調色板的16種顏色。只需使用DrawIcon()。 –
感謝您的輸入。 DrawIcon()看起來比傳遞一個位圖到DrawImage()更好。圖像仍然不如圖標上的DrawImage()精確,但使用Gdiplus的重要原因是因爲我還需要將圖標旋轉到指定的角度。爲此,我相信我需要在DrawImage()之前調用graphics-> RotateTransform()。 – pates
將它繪製成位圖,旋轉位圖。 –