从内存中加载 Picturebox 图像?
我似乎不知道如何从内存中的位图加载 pictureBox 图像。是否可能或者我必须为位图创建临时文件?
I can't seem to figure out how to load a pictureBox image from a bitmap in memory. Is it possible or do I have to create temp file for the bitmap?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
内存中的图像是什么格式?
如果您有一个实际的 Bitmap 对象,只需将其分配给 PictureBox,如 dtb 所建议的:
如果您将图像作为一系列字节保存在流中,则需要从流中加载图像:
如果您改为有一个位图的 Windows GDI 句柄,使用
本质上,当您没有告诉我们您的位图采用什么格式时,很难用更多的建议来回答您的问题。
What format is the image in memory?
If you have an actual Bitmap object, just assign it to the PictureBox, as suggested by dtb:
If you have the image as a series of bytes held in a stream, you'll need to load the image from the stream:
If you instead have a windows GDI handle to the bitmap, use
Essentially, it's hard to answer your question with more than suggestions when you haven't told us what format the Bitmap you have is held in.
您可以从 MemoryStream 创建位图:
You can create a Bitmap from a MemoryStream: