In one of my previous questions, I asked how to take a screenshot and save it in JPEG format without using GDI + due to restrictions on using only C. At the end, I myself answered the question with some comments. Using a very sophisticated version of C GDI + (loaded at runtime), I can take a screenshot and save it as a JPEG to a file. Now, how would I save the same screenshot not to a file, but to a buffer? unsigned char * buffer? here is the code that needs to be converted.
int SaveJpeg(HBITMAP hBmp, LPCWSTR lpszFilename, ULONG uQuality) { ULONG *pBitmap = NULL; CLSID imageCLSID; EncoderParameters encoderParams; int iRes = 0; typedef Status (WINAPI *pGdipCreateBitmapFromHBITMAP)(HBITMAP, HPALETTE, ULONG**); pGdipCreateBitmapFromHBITMAP lGdipCreateBitmapFromHBITMAP; typedef Status (WINAPI *pGdipSaveImageToFile)(ULONG *, const WCHAR*, const CLSID*, const EncoderParameters*); pGdipSaveImageToFile lGdipSaveImageToFile;
Thanks for the help.
source share