|
雨滴式的显示图片 (cloud 转贴)(3) ByVal dwRop As Long) As Integer Const SRCCOPY = &HCC0020
3. Add a Command Button control to Form1. Command1 is created by default. Set its Caption property to "Shrink Icon". 4. Add the following code to the Click event for Command1:
Private Sub Command1_Click() Dim X As Integer Dim Y As Integer Dim W As Integer Dim H As Integer Dim Ret As Integer
Image1 = LoadPicture("c:\vb\icons\misc\binoculr.ico") Image1.Width = 0.75 * Image1.Width Image1.Height = 0.75 * Image1.Height Picture1.Width = Image1.Width Picture1.Height = Image1.Height
X = Image1.Left / Screen.TwipsPerPixelX Y = Image1.Top / Screen.TwipsPerPixelY
W = Picture1.Width / Screen.TwipsPerPixelX H = Picture1.Height / Screen.TwipsPerPixelY
Ret = BitBlt(Picture1.hDC, 0, 0, W, H, Form1.hDC, X, Y, SRCCOPY) Picture1.Refresh End Sub
5. Add an Image control to Form1. Image1 is created by default. Set its Stretch property to True. 6. Add a Picture Box control to Form1. Picture1 is created by default. Set its AutoRedraw property to True. 返回
获得位图文件的信息 在Form中添加一个Picture控件和一个CommandButton控件,在Picture控件中加入一个位图文件,将下面代码加入其中: 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来存图
|