Добрый день. У меня такой вопрос, я пользовался механизмом сохранения битмапов, описанном здесь
http://www.rsdn.ru/forum/Message.aspx?mid=15085
но, потом в связи с изменением задачи пришлось перейти на сохранение иконок в файл bmp. Я передела код с учетом этого в
BOOL SaveIcon(IPicture* pPicture,LPCTSTR szPath)
{ HRESULT hr; int size = strlen(szPath);
#ifdef _UNICODE
BSTR bstrPath = SysAllocString(szPath);
if (bstrPath == NULL) return FALSE;
#else
int len = strlen(szPath);
BSTR bstrPath = SysAllocStringLen(NULL, len);
if (bstrPath == NULL) return FALSE;
MultiByteToWideChar(CP_ACP, 0, szPath, -1, bstrPath, len + 1);
#endif
hr = OleSavePictureFile((LPDISPATCH)pPicture,bstrPath);
SysFreeString(bstrPath);
return SUCCEEDED(hr);
}
BOOL SaveIconIndirect(PICTDESC pDesc,LPCTSTR szPath)
{ IPicture* pPicture = NULL;
BOOL bResult = TRUE;
OleCreatePictureIndirect(&pDesc,IID_IPicture,FALSE,(void**)&pPicture);
if(pPicture == NULL) bResult = FALSE;
else bResult = SaveIcon(pPicture,szPath);
if(pPicture != NULL) pPicture->Release();
return bResult;
}
BOOL SaveBitmapIcon(HICON hIcon,HPALETTE hPal,LPCTSTR szPath)
{ PICTDESC pDesc;
pDesc.cbSizeofstruct = sizeof(PICTDESC);
pDesc.picType=PICTYPE_ICON;
pDesc.icon.hicon = hIcon;
//pDesc.bmp.hpal = hPal;
//pDesc.picType = PICTYPE_BITMAP;
return SaveIconIndirect(pDesc,szPath);
}
Однако, они сохраняются только как 256 цветов. Можноли как-то вернуть им полную цветовую гамму (24-бита)