VB 如何把picturebox中每个点的颜色保存到数组

请注意,不要point那种一个点一个点扫描的方法,太慢了,我这种好像有点问题PrivateDeclareFunctionGetBitmapBitsLib"gdi32"(B... 请注意,不要point那种一个点一个点扫描的方法,太慢了,我这种好像有点问题
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject 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 PicInof As BITMAP
Picture2.Picture = LoadPicture("C:\Documents and Settings\Administrator\My Documents\ptpic.php.gif")
GetObject (Picture1.Image), Len(PicInof), PicInof
BytesPerPixel = PicInof.bmBitsPixel
ReDim TImage(PicInof.bmWidthBytes * PicInof.bmHeight) As Long 'PicInof.bmWidth - 1, PicInof.bmHeight - 1)
GetBitmapBits Picture2.Image, PicInof.bmWidthBytes * PicInof.bmHeight, TImage(0)
End Sub
展开
 我来答
Zatans
2011-04-17 · 超过14用户采纳过TA的回答
知道答主
回答量:28
采纳率:0%
帮助的人:40.3万
展开全部
GetObject (Picture1.Image), Len(PicInof), PicInof
执行成功以后PicInof.bmBits就是图像数据的指针了,再根据PicInof.bmWidthBytes * PicInof.bmHeight算出长度,映射到SAFEARRAY 或者 CopyMemory到数组里.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
ljl88900
2011-04-17 · TA获得超过2661个赞
知道大有可为答主
回答量:2197
采纳率:100%
帮助的人:2634万
展开全部
修改如下:
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject 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 PicInof As BITMAP
Dim BytesPerPixel As Long
Picture2.Picture = LoadPicture("C:\Documents and Settings\Administrator\My Documents\ptpic.php.gif")
GetObject (Picture2.Image), Len(PicInof), PicInof
BytesPerPixel = PicInof.bmBitsPixel
ReDim TImage(PicInof.bmWidthBytes * PicInof.bmHeight) As Byte 'PicInof.bmWidth - 1, PicInof.bmHeight - 1)
GetBitmapBits Picture2.Image.Handle, PicInof.bmWidthBytes * PicInof.bmHeight, TImage(0)
End Sub
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式