怎么样才能直接在Image控件提取图片

wenyang 2005-07-05 04:35:06
怎么样才能用取到image.picture的数据,
且把image.picture存存储成byte()数据返回或者是二进制数据返回,最好在VB代码下
...全文
173 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zlt982001 2005-07-05
  • 打赏
  • 举报
回复
注释:Form 中有PictureBox并指定好图形,另一CommandBox

Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" _

(ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) _

As Long

Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, _

ByVal dwCount As Long, lpBits As Any) As Long

Private Type BITMAP

bmType As Long

bmWidth As Long

bmHeight As Long

bmWidthBytes As Long

bmPlanes As Integer

bmBitsPixel As Integer

bmBits As Long

End Type

Private Sub Command1_Click()

Dim hBitmap As Long

Dim res As Long

Dim bmp As BITMAP

Dim byteAry() As Byte

Dim totbyte As Long, i As Long

hBitmap = Picture1.Picture.Handle

res = GetObject(hBitmap, Len(bmp), bmp) 注释:取得BitMap的结构

totbyte = bmp.bmWidthBytes * bmp.bmHeight 注释:总共要多少个Byte来存图

ReDim byteAry(totbyte - 1)

注释:将该图全放进ByteAry中

res = GetBitmapBits(hBitmap, totbyte, byteAry(0))

Debug.Print "Total Bytes Copied :"; res

Debug.Print "bmp.bmBits "; bmp.bmBits

Debug.Print "bmp.bmBitsPixel "; bmp.bmBitsPixel 注释:每个Pixel需多少Bits来表现

Debug.Print "bmp.bmHeight "; bmp.bmHeight 注释:bitmap图的高是多少Pixels

Debug.Print "bmp.bmPlanes "; bmp.bmPlanes

Debug.Print "bmp.bmType "; bmp.bmType

Debug.Print "bmp.bmWidth "; bmp.bmWidth 注释:BitMap图宽为多少pixels

Debug.Print "bmp.bmWidthBytes "; bmp.bmWidthBytes 注释:每条扫描线需多少Byte来存

End Sub

简易无忌 2005-07-05
  • 打赏
  • 举报
回复

在窗体上隐藏放置一个PICTURE,
同时读入图片到image1与PICTURE1 , ...
DooDu 2005-07-05
  • 打赏
  • 举报
回复
用picture控件就可以了
lan_yanjing 2005-07-05
  • 打赏
  • 举报
回复
要看你怎么用了,实在不行,用剪贴板也行
clipboard.setdata image1.picture
在你需要用到地方,再使用
clipboard.getdata
例如:
image2.picture = clipboard.getdata
wwqna 2005-07-05
  • 打赏
  • 举报
回复
用selectobject吧
lizhigao1 2005-07-05
  • 打赏
  • 举报
回复
用PICTURE控件吧
conrad_wan 2005-07-05
  • 打赏
  • 举报
回复
关注~

7,763

社区成员

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

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