Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my project have a bitmap.but the bitmap is too big.i want it small.so i change the bitmap format from bmp to gif.than i add this gif to my project as a source.when my program is runing,i want change the picture format from gif to bmp agan.i write a function like tihs:


BOOL CLoadDlg::GIFToBMP(CString& strGIFFile,CString& strBMPFile)
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

CLSID encoderClsid;
GetEncoderClsid(L"image/bmp", &encoderClsid); //i copy the "GetEncoderClsid"function from GDI+ SDK.
//Image image(strGIFFile.AllocSysString());
HRSRC hrsc = FindResource(NULL, MAKEINTRESOURCE(IDR_GIF1), "GIF"); //"IDR_GIF1"is my source-id of GIF .
HGLOBAL hG = LoadResource(NULL, hrsc);
//hG = LockResource(hG);
IStream* pStmImage = NULL;
CreateStreamOnHGlobal(hG, TRUE, &pStmImage);
Image image(pStmImage);

Status stat = image.Save(strBMPFile.AllocSysString(),&encoderClsid,NULL);

GdiplusShutdown(gdiplusToken);
if(stat == Ok)
return TRUE;
else
return FALSE;
}

but when i call this function,it have no effect...
please help me,where is wrong.
Posted

I don't really understand - why do you even need to do this ? A bmp is uncompressed, but a gif, a jpeg, a bmp, etc, all take the same format when they have been loaded in memory.

What do you mean 'have no effect' ? Does the image not get saved ? Is it not a bitmap ? If you had a 24 bit image and you saved it to gif, it's now 8 bit, and so saving to bmp will create a smaller bmp, because of the information that was lost.
 
Share this answer
 
Please edit your post instead of posting answers that are really questions.

Have you stepped through the code in your debugger ? Is a file created at all ? Is your resource loading properly ? I would start by replacing your current handle to save with one you load from disc, of the same file. Then work backwards from there. That way you can isolate which piece of code is failing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900