0

Thanks in advance for your help :)

In my code, I load a bitmap from my local computer, receiving in the end an HBITMAP structure. I would like to convert this hBitmap to JPEG and send it to a distant server side socket.

By now, what I am able to fulfill, is to save my picture on disk with jpg format thanks to the CImage functions, and then send it through the network. However, i would like to do it cleanly, not having a temporary file written on disk. My first thought was to send a byte array of the JPEG data, but I don't know how to do it... Any thought?

Following is the snippet of code I use to generate my JPEG file.

hBitmap = (HBITMAP) LoadImage( NULL, "./myfile.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);  
CImage atlImage;
atlImage.Attach(hBitmap);
atlImage.Save(L"./filename.jpg");

Thanks a lot for any help.

Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
David Labay
  • 3
  • 1
  • 4
  • Create a class that implements the [`IStream`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380034(v=vs.85).aspx) interface and handles storing data in a vector then create an instance of it and pass it to [`CImage::Save`](https://msdn.microsoft.com/en-us/library/d06f3fhw.aspx) – Captain Obvlious Apr 19 '16 at 17:58
  • Or look at the WIC Encoder API. – Adrian McCarthy Apr 19 '16 at 18:28

0 Answers0