ImgSource Sample CodeJPG to BMP C/C++ sample using the ImgSource API JPG to BMPsample using the CISImageEx C++ wrapper class
JPG to BMP using the ImgSource APIThis is how you read a JPG and save as BMP, using the ImgSource API directly.
// create the source manager.
// this opens the file for reading.
HISSRC hSource = IS40_OpenFileSource(DPIX"dawnwed.jpg");
// did it work?
if (hSource == NULL)
{
// no. what happened?
UINT32 err = IS40_GetLastError();
return 0;
}
// read the file to a 24-bit RGB bu6ffer
UINT32 uWidth, uHeight;
// this will set uWidth and uHeight
HGLOBAL hImg = IS40_ReadJPG(hSource, &uWidth, &uHeight, 24,0);
// close the source
IS40_CloseSource(hSource);
// did the file read work?
if (hImg!=NULL)
{
// yes! Get a pointer to the image
BYTE *pRGB = (BYTE *)hImg;
// save as BMP
// open the destination manager.
HISDEST hDest = IS40_OpenFileDest("lala.bmp", FALSE);
if (hDest!=NULL)
{
// write the RGB image to a 24-bit BMP
IS40_WriteBMP(hDest, pRGB, uWidth, uHeight, 24, uWidth * 3, 0, NULL, NULL, 0);
// close the destination manager
IS40_CloseDest(hDest);
}
// clean up
GlobalFree(hImg);
}
else
{
// no. what happened?
UINT32 err = IS40_GetLastError();
return 0;
}
JPG to BMP using the CISImageEx C++ WrapperThis is wrapper class handles 1, 8, 24 and 32 bit images in an easy to use C++ class. It is fully extensible and all the source is included.
// declare a CISImageEx object
CISImageEx img;
// load the image
UINT32 res = img.LoadImage("C:\\input.jpg");
if (res!=IS_ERR_OK)
{
... an error occurred}
}
// save it
res = img.SaveImage("C:\\output.bmp", eFmtBMP);
if (res!=IS_ERR_OK)
{
... an error occurred
}
Copyright © 2010, Smaller Animals Software, Inc. |
Site Stuff
Smaller Animals NewsImgSource
ThumbNailer 10
|