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
将它绘制成位图,旋转位图。 –