vb 使用 Gdiplus.tlb 如何把图片保存下来 ??

rgbcn 2016-08-23 03:37:02
'使用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
...全文
811 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
舉杯邀明月 2016-08-23
  • 打赏
  • 举报
回复
用GDI+绘图之后,Me.Image属性,就是“窗口内的图像”了吧? 把它保存下来不就行了?

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧