'使用Gdiplus.tlb,將其放到system32中,然后添加對其的參考
'手動設定Form的AutoRedraw=True,ScaleMode=Pixels
Option Explicit
Dim lngGraphics As Long
Dim lngImageHandle As Long
Dim lngTextureBrush As Long
Dim gpP As GpStatus
Dim lngPen1 As Long
Dim lngToken As Long
Dim GpInput As GdiplusStartupInput
Private Sub Command1_Click()
Dim intP As Integer
gpP = GdipCreateFromHDC(Me.hDC, lngGraphics) '創建繪圖區域設備場景
gpP = GdipLoadImageFromFile(App.Path & "\啟動.png", lngImageHandle) '讀取圖片到記憶體
gpP = GdipDrawImage(lngGraphics, lngImageHandle, 0, 0) '等大小繪制
gpP = GdipDrawImageRect(lngGraphics, lngImageHandle, 200, 0, 300, 300) '在指定的區域內繪制(放大或縮小)
gpP = GdipDrawImageRectRectI(lngGraphics, lngImageHandle, 550, 0, 400, 400, 20, 20, 80, 80, UnitPixel) '在400*400的區域內顯示圖片部磁區域
gpP = GdipCreateTexture(lngImageHandle, WrapModeTile, lngTextureBrush) '設定一定排列方式的刷子 平鋪方式
gpP = GdipFillRectangle(lngGraphics, lngTextureBrush, 0, 300, 400, 300) '在指定區域內按指定的格式繪制圖片
If lngGraphics <> 0 Then GdipDeleteGraphics lngGraphics
If lngImageHandle <> 0 Then GdipDisposeImage lngImageHandle
If lngTextureBrush <> 0 Then GdipDeleteBrush lngTextureBrush
Me.Refresh
End Sub
Private Sub Form_Load()
Dim bolP As Boolean
With Me
.Caption = "GDIPlus范例"
.Width = 960 * 15
.Height = 720 * 15
.Left = (Screen.Width - .Width) * 0.5
.Top = (Screen.Height - .Height) * 0.5
End With
GpInput.GdiplusVersion = 1
If lngToken = 0 Then bolP = (GdiplusStartup(lngToken, GpInput) = Ok)
End Sub
uj5u.com熱心網友回復:
用GDI+繪圖之后,Me.Image屬性,就是“視窗內的影像”了吧?把它保存下來不就行了?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/69936.html
標籤:VB基礎類
上一篇:vba讀取DBF檔案出錯
