在VB6中将图片框图像像素转换为字节数组 [英] Convert a Picture Box image pixels to a Byte Array in VB6

查看:389
本文介绍了在VB6中将图片框图像像素转换为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VB6图片框,可以从视频捕获设备获取图像.

I have a VB6 picture box that gets an image from a video capture device.

我试图弄清楚如何将图片框转换为字节数组.

I'm trying to figure out how to then convert the picture box to a byte array.

推荐答案

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 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 Sub GetPictureBytes()
  Dim PicBits() As Byte, PicInfo As BITMAP

  GetObject Picture1.Picture, Len(PicInfo), PicInfo

  ReDim PicBits((PicInfo.bmWidth * PicInfo.bmHeight * 3) - 1) As Byte

  GetBitmapBits Picture1.Picture, UBound(PicBits), PicBits(0)
End Sub

这篇关于在VB6中将图片框图像像素转换为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆