| 网站首页 | JAVA文章 | AppServers | Web开发 | 应用开发 | 资源下载 | 论坛
    想学好编程,学好外语很重要  [enadd  2006年12月25日]        
设为首页 加入收藏 联系站长
您现在的位置: 编程笔记网 >> 应用开发 >> vb >> 图形 >> 文章正文
取得PictureBox内BitMap图的各个Byte            【字体:
取得PictureBox内BitMap图的各个Byte
作者:-    文章来源:-    点击数:    更新时间:2006-6-8

'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

[1]

文章录入:enadd    责任编辑:enadd 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
  • 用VB编写DirectX7.0游戏(下…

  • 用VB编写DirectX7.0游戏(上…

  • 使用OLE DB和ADO调用返回记录…

  • 使用VB调用Oracle程序包内的…

  • VB中用ADO对象动态创建数据库…

  • fffff

  • 如何用MSComm Control传Bina…

  • MultiLink的WinSock Server程…

  • 用VB制作浏览器

  • 用VB编写网络寻呼机

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 管理登录 |