Issue with jpg file format

i want to save image as jpg file in toradex module. i am using some gdiplus libraries functions but in toradex SDKs that lib file like GdiPlus.lib and supported header files of gdiplus are not available. so pls help me to find out some solution

GDIplus functions are not part of our current images, and so they are not available in the SDK. You need to build your own custom image and generate an SDK to use those functions.
Consider also that this API is not available in Windows Embedded Compact 2013, so if you are considering a migration to this release in the future this may be an issue.

thanks for replay. i completelly understand your answer. but i have really requaire to create jpg image on wince so is there any solution for that?can i use OPENGL?i am fresher in this work so any help will be apprecieated.

On Windows Embedded Compact 7 you can use imaging APIs.
You can use IImagingFactory::GetInstalledCodecs
https://msdn.microsoft.com/en-us/library/aa452233.aspx
And then use the CreateImageEncoderToFile function:
https://msdn.microsoft.com/en-us/library/aa452209.aspx
If you have platform builder installed you can find some samples:
https://msdn.microsoft.com/en-us/library/ms932698.aspx
To create an object that may be used to save data in your image file.
Only Windows Embedded Compact 2013 only WIC (Windows Imaging Component) is supported:
https://msdn.microsoft.com/en-us/library/gg158899.aspx

Hii valter.tx
thanks for help.i applied all this things in my code.its completely work.but there is some little things missing.because of that i cant complete my task. the problem is that code generates black jpg bitmap . whats the problem in my code . plss help.is anyone know plss guide me. i am fresher.code is as below:

Imaging_SaveToFile(hbmBuffer2 , L"\FlashDisk\data\ArthH5.jpg", L"jpg");

HRESULT Imaging_SaveToFile(HBITMAP handle, LPTSTR filename, LPCTSTR format)
{
HRESULT res;
HRESULT c_bm;
HRESULT c_bm1;

	res = CoInitializeEx(NULL, COINIT_MULTITHREADED);
	if ((res == S_OK) || (res == S_FALSE)) {
	 IImagingFactory* factory=NULL;
	 if (CoCreateInstance(CLSID_ImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IImagingFactory, (void**)&factory) == S_OK) {
    UINT count;
    ImageCodecInfo* imageCodecInfo=NULL;
    if (factory->GetInstalledEncoders(&count, &imageCodecInfo) == S_OK) {

        LPTSTR formatString;
        if (wcscmp(format, L"png") == 0) {
            formatString = _T("image/png");
        } else if (wcscmp(format, L"jpg") == 0) {
            formatString = _T("image/jpeg");
        } else if (wcscmp(format, L"gif") == 0) {
            formatString = _T("image/gif");
        } else if (wcscmp(format, L"bmp") == 0) {
            formatString = _T("image/bmp");
        } else {
            CoUninitialize();
            return S_FALSE;
        }
        CLSID encoderClassId;
        if (count == 0) {
            CoUninitialize();
            return S_FALSE;
        }
        for(int i=0; i < (int)count; i++) {
            if (wcscmp(imageCodecInfo[i].MimeType, formatString) == 0) {
                encoderClassId= imageCodecInfo[i].Clsid;
                free(imageCodecInfo);
                break;
            } else {
                continue;
            }
            CoUninitialize();
            return S_FALSE;
        } 
        IImageEncoder* imageEncoder=NULL;
        if (factory->CreateImageEncoderToFile(&encoderClassId, filename, &imageEncoder) == S_OK) {
            IImageSink* imageSink = NULL;
            res = imageEncoder->GetEncodeSink(&imageSink);

            if (res != S_OK) {
                CoUninitialize();
                return res;
            }

            BITMAP bm;				
            GetObject (handle, sizeof(BITMAP), &bm);
            PixelFormatID pixelFormat;
            switch (bm.bmBitsPixel) {
                case 1: {
                    pixelFormat = PixelFormat1bppIndexed;
                    break;
                }
                case 4: {
                    pixelFormat = PixelFormat4bppIndexed;
                    break;
                }
                case 8: {
                    pixelFormat = PixelFormat8bppIndexed;
                    break;
                }
			    /*case 16: {
                    pixelFormat = PixelFormat16bppRGB555;
                    break;
                }*/
                case 24: {
                    pixelFormat = PixelFormat24bppRGB;
                    break;
                }
                default: {
                    pixelFormat = PixelFormat32bppARGB;
                    break;
                }
            }

           BitmapData *bmData = new BitmapData();
          /* bmData->Height = bm.bmHeight;
           bmData->Width = bm.bmWidth;
           bmData->Scan0 = bm.bmBits;*/
           bmData->PixelFormat = pixelFormat;

            UINT bitsPerLine = bm.bmWidth * bm.bmBitsPixel;
            UINT bitAlignment = sizeof(LONG) * 8;
            UINT bitStride = bitAlignment * (bitsPerLine / bitAlignment);   // The image buffer is always padded to LONG boundaries
            if ((bitsPerLine % bitAlignment) != 0) bitStride += bitAlignment; // Add a bit more for the leftover values
            bmData->Stride = (bitStride / 8);

            IBitmapImage* pBitmap;
           /* factory->CreateBitmapFromBuffer(bmData, &pBitmap);*/
			 c_bm = factory->CreateNewBitmap(   bm.bmWidth,  bm.bmHeight ,  pixelFormat,   &pBitmap);
			
          IImage* pImage;
          c_bm1 =  pBitmap->QueryInterface(IID_IImage, (void**)&pImage); 
            res = pImage->PushIntoSink(imageSink);
            if (res != S_OK) {
                CoUninitialize();
                return res;
            }

            pBitmap->Release();
            pImage->Release();
            imageSink->Release();
            imageEncoder->TerminateEncoder();
            imageEncoder->Release();
        }
    }
}
CoUninitialize();

} else {
return res;
}
return res;
}

I see that in your code you are creating an empty bitmap (that by default is all 0) and then saving it. I think it’s normal that you end-up with a black jpg.
CreateBitmapFromBuffer should create an imaging bitmap from an OS one and should save some meaningful data.

yes i have already tried createbitmapfrombuffer function. you can see in code that commented part . but when i remove comments there are some errors related to that function …like… BitmapData class undefined…bmdata is not a member of class…nd here BitmapData class has been defined in SDK fies.so because of i cant access class i have to replace that function to createnewbitmap. is there any solution?

Declaration of BitmapData is not commented out, so if the code builds (I can’t check right now) should be defined. Can you provide a code sample with project etc.? You may upload it on share.toradex.com and post a link here.
I can’t grant we can fix that (it’s application level issue), but we may look into it.

thanks a lots for help valter.tx. i found my mistake .now its work perfectly.