Image conversion

zhaozj2021-02-11  180

Image conversion

'********************************************************** ******************** * refreshes the Picture object of the PictureBox control. For any drawing operation in Picturebox, '* can be converted to a Picture object' * Use this function to edit the image of the image in PictureBox Permanently update to the Picture Object '* Parameters: PicBox PictureBox Control Name' * LWIDTH Need to update Image width (according to your needs, not limited to the actual size of the '* icon), is also the image width of the Picture object to be formed (unit: pixels)' * Lheight needs to update the image height, Other class with lwidth (unit: pixels) '********************************************** *************************************** Function UpdatePict, Optional Byval LWIDTH AS long = -1, _ Optional BYVAL LHEIGHT As long = -1) as boolean on error Goto Errhandle

DIM Oldscmode AS INTEGER DIM HNEWDC AS Long Dim Holdbit AS Long Dim Hnewbit As Long

oldScMode = -1 oldScMode = PicBox.ScaleMode If lWidth = -1 Then lWidth = PicBox.ScaleX (PicBox.Picture.Width, 8, vbPixels) End If If lHeight = -1 Then lHeight = PicBox.ScaleY (PicBox.Picture.Height , 8, vbpixels) End IF

HNEWDC = CreateCompatibleDC (Picbox.hdc) Hnewbit = CreateCompatibleBitmap (Picbox.hdc, Lwidth, Lheight) Holdbit = SelectObject (HnewDC, Hnewbit)

Bitblt Hnewdc, 0, 0, Lwidth, Lheight, Picbox.hdc, 0, 0, VBSRCCopy SelectObject HnewDC, Holdbit

Picbox.Picture = Bitmaptopicture (HNEWbit)

DeleteObject hnewdc deletedc hnewdc if iltscmode <> -1 Then Picbox.scalemode = oldscmode updatePicture = true

EXIT functionerrhandle: updatePicture = false if oldscmode <> -1 kilobox.scalemode = OldscModeEnd Function related API function declaration

Option expedition

Public const hnull = 0

PUBLIC TYPE IID DATA1 As Long Data4 (0 to 7) as Byteend Typepublic Type PictypeOfstruct As Long Pictype As Long Hgdiobj As Long Hpalorxyext As Longend Type

Public Declare Sub OleCreatePictureIndirect Lib "olepro32.dll" (_ lpPictDesc As PICTDESC, _ riid As IID, _ ByVal fPictureOwnsHandle As Long, _ ipic As IPicture) Public Declare Function CreateCompatibleDC & Lib "gdi32" (ByVal hdc As Long) Public Declare Function CreateCompatibleBitmap & lib "gdi32" (_ ByVal hdc As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long) Public Declare Function DeleteDC & lib "gdi32" (ByVal hdc As Long) Public Declare Function SelectObject & lib "gdi32" (_ ByVal hdc As Long, _ Byval Hobject As Long) Public Declare Function DeleteObject & Lib "GDI32" (BYVAL HOBJECT AS "

The above code from: the source code database (SourceDataBase) Current Version: 1.0.436 Author: Shawls profile: Http://Shawls.Yeah.Net E-Mail: ShawFile@163.Net QQ: 9181729

转载请注明原文地址:https://www.9cbs.com/read-4845.html

New Post(0)