I have created an application where I am required to send the cropped part of an image over a Socket. I have cropped the image using StretchBlt(), I am also able to display and save the cropped image to a bitmap file.
Next, I want to send this cropepd image over a Socket connection. The connection between socket is established, My problem is how to send/ receive this image over Socket since send() and recv() functions require a char *.
One idea, is if I select the HBITMAP to a memDC object than can I send the memDC directly to the remote socket ?
Any easier way to achieve this task?
You can’t pass an HBITMAP (which is a HANDLE, a reference pointer in memory) to another machine. You can use the GetBitmapBits Function to transform the HBITMAP into a byte array and send this byte array using send().
On the other side, you’ll have to create another compatible bitmap, and use SetBitmapBits Function after the recv().