在VB中如何将picturebox中的图片保存到字节数组中?

dusj 2000-05-28 11:27:00
已经在picturebox中显示出了一幅图像,如果将这幅图的像素信息放到一个自定义的字节数组中?
我不想用savepicture保存,然后再读出的方法,因为用磁盘交换太慢,要求速度快一些.
是不是要得到picturebox的hdc中的位图信息,再用memorycopy函数解决呢?可是hdc中的位图信息在哪里呢?
thank you.
my Email: dusj@263.net
...全文
363 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Un1 2000-06-07
  • 打赏
  • 举报
回复
其实也不是很慢。
Un1 2000-06-07
  • 打赏
  • 举报
回复

看看这两个函数:

Private Function SaveImage(Image As IPictureDisp) As Byte()
SavePicture Image, confile

ReDim SaveImage(FileLen(confile) - 1)

Dim l As Long
l = FreeFile()

Open confile For Binary Access Read As #l
Get #l, , SaveImage
Close #l

Kill confile
End Function

Private Function LoadImage(Data() As Byte) As IPictureDisp
Dim l As Long
l = FreeFile()
Open confile For Binary Access Write As #l
Put #l, , Data
Close #l

Set LoadImage = LoadPicture(confile)

Kill confile
End Function

sanhan 2000-05-28
  • 打赏
  • 举报
回复
用GetDIBits,其中的hbmp用CreateCompatibleBitmap得到,
这两个都是Win32SDK的函数。
qyx888 2000-05-28
  • 打赏
  • 举报
回复
我想应该使用Api函数------
SetBitmapBits(hbmp,cbits,lpvbits)
hbitmap hbmp 位图句柄
long cbits 位图数组内的字节数
fat * lpvbits 具有位图数组的地址
此处hbmp不是hdc
此函数,我未用过,我是在一本vc的书上发现它的.

要不利用picturebox处理图象的象素,可利用api函数来处理,但需要掌握一些相关的知识,你有兴趣可Email给我,我可介绍你几本参考书.我已就"图象不用picturebox处理而用其他方法处理"的问题处理头疼了近两个月了,最近总算有初步的解决之道了.看来,你也在研究图象处理,我们可以共同研究这个问题.
Email :hareqian@sina.com

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧