通过套接字发送HBITMAP

通过套接字发送HBITMAP

本文介绍了如何使用WIN32和C ++通过套接字发送HBITMAP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个应用程序,我需要通过Socket发送图像的裁剪部分。我已经裁剪图像使用StretchBlt(),我也能够显示和保存裁剪图像到位图文件。



接下来,我想发送这个裁剪图像通过Socket连接。 socket之间的连接建立,我的问题是如何通过Socket发送/接收这个图像,因为send()和recv()函数需要一个char *。



,如果我选择HBITMAP到一个memDC对象,我可以直接发送memDC到远程socket吗?



请帮助我,并建议我一个更简单的方法

解决方案

不能将HBITMAP(这是一个HANDLE,内存中的引用指针)传递给另一台机器。您可以使用将HBITMAP转换为字节数组,并使用send()发送这个字节数组。



另一方面,你必须创建另一个兼容的位图, =http://msdn.microsoft.com/en-us/library/dd162962%28VS.85%29.aspx =nofollow> SetBitmapBits函数之后的recv()。


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 ?

Please help me out of this and suggest me an easier way to achieve this task..

thanks in advacne

解决方案

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().

这篇关于如何使用WIN32和C ++通过套接字发送HBITMAP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 07:55