2, save into a transparent PNG file,
3, how to operate? Or ideas? Feel only use Gdi + is difficult, but with libpng and too much trouble, a little small wheel with feeling,
4, simple point, how to open a PNG image, saved as a PNG file after cut? Shear function has been achieved, the use of Gdi + DrawImage and DrawImageRectRectI
CodePudding user response:
Create a new bitmap, and then draw lines, and then saved as a PNG:Private Type GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type
Private Declare Function GdiplusStartup Lib "gdiplus" (token, As Long As inputbuf GdiplusStartupInput, Optional ByVal outputbuf As Long=0) As Long
Private Declare Function GdipCreateBitmapFromScan0 Lib "gdiplus" (ByVal Width As Long, ByVal Height As Long, ByVal stride As Long, ByVal PixelFormat As Long, scan0 As Any, bitmap As Long) As Long
Private Declare Function GdipCreatePen1 Lib "gdiplus" (ByVal color As Long, ByVal Width As Single, ByVal unit As Long, pen As Long) As Long
Private Declare Function GdipGetImageGraphicsContext Lib "gdiplus" (ByVal Image As Long, graphics As Long) As Long
Private Declare Function GdipDrawLine Lib "gdiplus" (ByVal graphics As Long, ByVal pen As Long, ByVal x1 As Single, ByVal y1 As Single, ByVal x2 As Single, ByVal y2 As Single) As Long
Private Declare Function CLSIDFromString Lib "ole32" (ByVal LPSZ As Long, pclsid As Any) As Long
Private Declare Function GdipSaveImageToFile Lib "gdiplus" (ByVal Image As Long, ByVal filename As Long, clsidEncoder As Any, encoderParams As Any) As Long
Private Declare Function GdipDeletePen Lib "gdiplus" (ByVal pen As Long) As Long
Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As Long
Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal Image) As Long As Long
Private Declare Function GdiplusShutdown Lib "gdiplus" (ByVal token As Long) As Long
Private Sub Command1_Click ()
Const PNGFile As String="D: \ 1. PNG"
Const PixelFormat32bppARGB As Long=& amp; H26200A
Const CLSID_PNG As String="{a04 cf406 557-1-11 d3-9 - a73-0000 f81ef32e}"
Dim token As Long
Dim GpInput As GdiplusStartupInput
Dim ReturnValue As Long
Dim bitmap As Long
Dim graphics As Long
Dim pen As Long
Dim PngClsid (15) As Byte
Dim Params (7) As Long
'initialize GDI
GpInput. GdiplusVersion=1
The ReturnValue=https://bbs.csdn.net/topics/GdiplusStartup (token, GpInput)
If the ReturnValue & lt;> 0 Then MsgBox "GDI failed to initialize" : the Exit Sub
'new Bitmap
GdipCreateBitmapFromScan0 100, 100, 0, PixelFormat32bppARGB, ByVal 0, bitmap
'new pen
GdipCreatePen1 & amp; H80FF0000, 10, 0, translucent red pen '
Draw a line '
GdipGetImageGraphicsContext bitmap, graphics
GdipDrawLine graphics, pen, 10, 20, 60, 70
'is saved as a PNG
CLSIDFromString StrPtr (CLSID_PNG), PngClsid (0)
GdipSaveImageToFile bitmap, StrPtr (PNGFile), PngClsid (0), Params (0)
'sweeping work
GdipDeletePen pen
GdipDeleteGraphics graphics
GdipDisposeImage bitmap
GdiplusShutdown token
End Sub
CodePudding user response:
to learn 1/f,CodePudding user response:
On the 1st floor, how to put the PICTUREBOX is saved as a PNG?