T
TallGuy63
Guest
Im trying to translate my 32-bit PB code for converting JPGs to BMP files to 64-bit C++ and it doesnt want to work. Its not reporting any errors, just never gets past the Save->
I put notes in the code below showing where it gets to and where it never gets to
Any ideas?
INT getencoderclsid(const WCHAR* format,CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes
Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL;
Gdiplus::GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure
pImageCodecInfo=(Gdiplus::ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure
GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
}
free(pImageCodecInfo);
return -1; // Failure
}
BOOL convertimage(std::string loadflname,std::string saveflname,std::string smimetype)
{
std::string b;
std::wstring wtxt;
BOOL retval;
ULONG_PTR hgdiplus;
Gdiplus::GdiplusStartupInput gpinput;
Gdiplus::Image* lpimage;
CLSID sencoderclsid;
if((trim(loadflname) == "") || (trim(saveflname) == ""))
return FALSE;
// Initialize GDI+.
gpinput.GdiplusVersion=1;
Gdiplus::GdiplusStartup(&hgdiplus,&gpinput,NULL);
if(left(smimetype,4) == "jpg/")
smimetype="jpeg"+right(smimetype,(long)(smimetype.length()-3));
if(right(smimetype,4) == "/jpg")
smimetype=left(smimetype,(long)(smimetype.length()-3))+"jpeg";
wtxt=strtowstr(smimetype);
if(getencoderclsid(wtxt.c_str(),&sencoderclsid) == (-1))
{
msgbox("Error "+str(GetLastError()));
return FALSE;
}
wtxt=strtowstr(loadflname);
lpimage=Gdiplus::Image::FromFile(wtxt.c_str());
wtxt=strtowstr(saveflname);
//Got Here !!
if(img->Save(wtxt.c_str(),&sencoderclsid,NULL) == Gdiplus::Status::Ok)
retval=TRUE;
else
retval=FALSE;
//never gets here !!
delete lpimage;
lpimage=0;
Gdiplus::GdiplusShutdown(hgdiplus);
return retval;
}
Continue reading...
I put notes in the code below showing where it gets to and where it never gets to
Any ideas?
INT getencoderclsid(const WCHAR* format,CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes
Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL;
Gdiplus::GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure
pImageCodecInfo=(Gdiplus::ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure
GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
}
free(pImageCodecInfo);
return -1; // Failure
}
BOOL convertimage(std::string loadflname,std::string saveflname,std::string smimetype)
{
std::string b;
std::wstring wtxt;
BOOL retval;
ULONG_PTR hgdiplus;
Gdiplus::GdiplusStartupInput gpinput;
Gdiplus::Image* lpimage;
CLSID sencoderclsid;
if((trim(loadflname) == "") || (trim(saveflname) == ""))
return FALSE;
// Initialize GDI+.
gpinput.GdiplusVersion=1;
Gdiplus::GdiplusStartup(&hgdiplus,&gpinput,NULL);
if(left(smimetype,4) == "jpg/")
smimetype="jpeg"+right(smimetype,(long)(smimetype.length()-3));
if(right(smimetype,4) == "/jpg")
smimetype=left(smimetype,(long)(smimetype.length()-3))+"jpeg";
wtxt=strtowstr(smimetype);
if(getencoderclsid(wtxt.c_str(),&sencoderclsid) == (-1))
{
msgbox("Error "+str(GetLastError()));
return FALSE;
}
wtxt=strtowstr(loadflname);
lpimage=Gdiplus::Image::FromFile(wtxt.c_str());
wtxt=strtowstr(saveflname);
//Got Here !!
if(img->Save(wtxt.c_str(),&sencoderclsid,NULL) == Gdiplus::Status::Ok)
retval=TRUE;
else
retval=FALSE;
//never gets here !!
delete lpimage;
lpimage=0;
Gdiplus::GdiplusShutdown(hgdiplus);
return retval;
}
Continue reading...