Click here to Skip to main content

C / C++ / MFC

    RSS: RSS Feed

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page  Show 
  Refresh
GeneralRe: What is the handle count for a process in windows? PinmemberGupta Suraj3:50 11 Jan '07  
GeneralRe: What is the handle count for a process in windows? Pinmemberbrahmma3:57 11 Jan '07  
GeneralRe: What is the handle count for a process in windows? PinmemberMaximilien4:41 11 Jan '07  
GeneralRe: What is the handle count for a process in windows? Pinmemberbrahmma18:57 11 Jan '07  
AnswerRe: What is the handle count for a process in windows? PinmemberDavid Leyva11:24 11 Jan '07  
AnswerRe: What is the handle count for a process in windows? PinmemberWhiteSky21:58 11 Jan '07  
GeneralRe: What is the handle count for a process in windows? PinmemberGupta Suraj23:33 11 Jan '07  
QuestionCreating .ico file from HICON Pinmemberneilsolent3:22 11 Jan '07  
In a previous post I was attempting to "serialize" an HICON, i.e. save it as a blob in a file or database: the opposite operation to the ExtractIcon() operation. I have since learned how to do this (see routine below).
 
BUT now my problem is, this routine loses color information. When the routine is run against a true-color icon, and the buffer is saved as a .ico file, and the .ico file is reloaded with ExtractIcon(), the resulting icon has reduced to 256 colors.
 
I think this must be a limitation of OleCreatePictureIndirect(). How can I fix my routine?
 
------------------------------------------------
 
void SerializeIcon(const HICON icon, DWORD* size, BYTE** data)
{
     LPPICTURE pPicture;
     PICTDESC   rPD;
     rPD.cbSizeofstruct = sizeof(PICTDESC);
     rPD.picType = PICTYPE_ICON;
     rPD.icon.hicon = icon;
     IStream* pStream = NULL;
     HGLOBAL   hMem = NULL;
     BYTE* pMem = NULL;
     long lActual;
 
     OleCreatePictureIndirect(&rPD, IID_IPicture, FALSE, (void**) &pPicture);
     CreateStreamOnHGlobal(0, TRUE, &pStream);
     pPicture->SaveAsFile(pStream, TRUE, &lActual);
     pPicture->Release();
     GetHGlobalFromStream(pStream, &hMem);
     pMem = (BYTE*) GlobalLock(hMem);
     *size = GlobalSize(hMem);
     *data = (BYTE*) malloc(*size);
     CopyMemory(*data, pMem, *size);
     GlobalUnlock(hMem);
     GlobalFree(hMem);
}
 
------------------------------------------------
 
<div class="ForumSig">
cheers,
Neil</div>
AnswerRe: Creating .ico file from HICON PinmembertomW862:17 10 Dec '10  
QuestionWhat's wrong.... [modified] PinmemberAstricks3:01 11 Jan '07  
AnswerRe: What's wrong.... Pinmemberprasad_som3:09 11 Jan '07  
GeneralRe: What's wrong.... PinmemberAstricks1:03 12 Jan '07  
AnswerRe: What's wrong.... PinmemberCPallini3:10 11 Jan '07  
GeneralRe: What's wrong.... PinmemberAstricks1:03 12 Jan '07  
AnswerRe: What's wrong.... PinmemberVuNic3:11 11 Jan '07  
JokeRe: What's wrong.... PinmemberCPallini3:12 11 Jan '07  
GeneralRe: What's wrong.... PinmemberVuNic3:14 11 Jan '07  
GeneralRe: What's wrong.... Pinmemberbrahmma3:25 11 Jan '07  
GeneralRe: What's wrong.... PinmemberVuNic3:34 11 Jan '07  
GeneralRe: What's wrong.... PinmemberJohn R. Shaw15:54 11 Jan '07  
GeneralRe: What's wrong.... PinmemberVuNic20:36 11 Jan '07  
GeneralRe: What's wrong.... PinmemberWhiteSky21:57 11 Jan '07  
GeneralRe: What's wrong.... PinmemberAstricks1:04 12 Jan '07  
AnswerRe: What's wrong.... Pinmemberneilsolent3:12 11 Jan '07  
QuestionSocket Programming PinmemberSrikanthVinayak Ram2:48 11 Jan '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.5.120222.1 | Last Updated 23 Feb 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid