Dim sth() As Byte
Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As LongPrivate Sub Command1_Click()
Open "c:\fy.jpg" For Binary As #1
i = FileLen("c:\sth.bmp")
ReDim sth(i - 1) As Byte
Get #1, , sth
Close #1
a = SetBitmapBits(Picture1.hDC, i, sth(0)) '不能这样用吧
End Sub
我想把图片通过SetBitmapBits放到picture1上
应该怎么使用
请指教
Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As LongPrivate Sub Command1_Click()
Open "c:\fy.jpg" For Binary As #1
i = FileLen("c:\sth.bmp")
ReDim sth(i - 1) As Byte
Get #1, , sth
Close #1
a = SetBitmapBits(Picture1.hDC, i, sth(0)) '不能这样用吧
End Sub
我想把图片通过SetBitmapBits放到picture1上
应该怎么使用
请指教
解决方案 »
- 请问:如何得到文本焦点和执行键盘事件?
- 是不是数据库查询功能需要在建立数据库的mdb文件中也建个查询表才能实现
- 大家谈谈用ACCESS做数据库,VB作前台,多用户登录采用什么方法比较安全?分不够可以再给。
- 关于注册表重命名操作?
- 怎样动态改变数据环境连接路径,在线等待........
- 如何将程序运行时鼠标固定在某一个控件大小的范围内不让它出去
- 比较难!我用VB编程映射了一个网络驱动器,如何让系统认为它是一个光驱呢?
- 我的
- ADO访问Access,如果field.item的值为NULL,怎么显示?
- 小弟问:如何设公用变量?(就是在所有情况下值不会丢的那种?)
- 关于用VB连接硬件的问题
- 怎样实现远程复制文件
'Paste this code into Form1
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 Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Dim PicBits() As Byte, PicInfo As BITMAP
Dim Cnt As Long, BytesPerLine as Long
Private Sub Command1_Click() 'Get information (such as height and width) about the picturebox
GetObject Picture1.Image, Len(PicInfo), PicInfo
'reallocate storage space
BytesPerLine = (PicInfo.bmWidth * 3 + 3) And &HFFFFFFFC
ReDim PicBits(1 To BytesPerLine * PicInfo.bmHeight * 3) As Byte
'Copy the bitmapbits to the array
GetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
'Invert the bits
For Cnt = 1 To UBound(PicBits)
PicBits(Cnt) = 255 - PicBits(Cnt)
Next Cnt
'Set the bits back to the picture
SetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
'refresh
Picture1.Refresh
End Sub
SHANNON
----------------
[email protected]
Public Declare Function SetBitmapBits Lib "gdi32" Alias "SetBitmapBits" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
【说明】
将来自缓冲区的二进制位复制到一幅位图
【返回值】
Long,执行成功则返回字节数量,零表示失败
【参数表】
hBitmap -------- Long,位图的句柄 dwCount -------- Long,欲复制的字节数量 lpBits --------- Any,指向一个缓冲区的指针。这个缓冲区包含了为位图正确格式化的位图位
【其它】
在Win32中,应使用与设备无关位图