7,785
社区成员




'使用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