如何使用WIN32和C ++通过套接字发送HBITMAP?

编程入门 行业动态 更新时间:2024-10-21 13:41:16
本文介绍了如何使用WIN32和C ++通过套接字发送HBITMAP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

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

解决方案

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

另一方面,你必须创建另一个兼容的位图, =msdn.microsoft/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?

本文发布于:2023-11-06 06:45:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562974.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   HBITMAP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!