Private Declare Function GdiplusStartup Lib "gdiplus" (token As Long,
inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As
GpStatus
Private Declare Sub GdiplusShutdown Lib "gdiplus"
(ByVal token As Long)
Private Declare Function
GdipCreateFromHDC Lib "gdiplus" (ByVal hwnd As Long, graphics As Long) As
GpStatus
Private Declare Function GdipDeleteGraphics Lib
"gdiplus" (ByVal graphics As Long) As GpStatus
Private Declare
Function GdipDrawImageRect Lib "gdiplus" (ByVal graphics As Long, ByVal image As
Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height
As Single) As GpStatus
Private Declare Function
GdipLoadImageFromFile Lib "gdiplus" (ByVal filename As String, image As Long) As
GpStatus
Private Declare Function GdipGetImageWidth Lib
"gdiplus" (ByVal image As Long, Width As Long) As
GpStatus
Private Declare Function GdipGetImageHeight Lib
"gdiplus" (ByVal image As Long, Height As Long) As
GpStatus
Private Declare Function GdipDisposeImage Lib "gdiplus"
(ByVal image As Long) As GpStatus
Private Type
GdiplusStartupInput
GdiplusVersion As
Long
DebugEventCallback As
Long
SuppressBackgroundThread As
Long
SuppressExternalCodecs As
Long
End Type
Private Enum
GpStatus
Ok =
0
GenericError =
1
InvalidParameter =
2
OutOfMemory =
3
ObjectBusy =
4
InsufficientBuffer =
5
NotImplemented =
6
Win32Error =
7
WrongState =
8
Aborted =
9
FileNotFound =
10
ValueOverflow =
11
AccessDenied =
12
UnknownImageFormat =
13
FontFamilyNotFound =
14
FontStyleNotFound =
15
NotTrueTypeFont =
16
UnsupportedGdiplusVersion =
17
GdiplusNotInitialized =
18
PropertyNotFound =
19
PropertyNotSupported =
20
End
Enum
‘主要代码就下面这几句而已.
Private Const
c_pngPath As String = "c:\1.png"
Dim m_token As
Long
Private Sub
Form_paint()
Dim pImg As
Long
Dim pGraphics As
Long
Dim w As Long, h As
Long
Call GdipCreateFromHDC(Me.hDC,
pGraphics)
Call
GdipLoadImageFromFile(StrConv(c_pngPath, vbUnicode),
pImg)
Call GdipGetImageWidth(pImg,
w)
Call GdipGetImageHeight(pImg,
h)
Call GdipDrawImageRect(pGraphics,
pImg, 0, 0, w,
h)
Call GdipDisposeImage(pImg)
Call
GdipDeleteGraphics(pGraphics)
End
Sub
Private Sub
Form_Load()
Dim StartupInput As
GdiplusStartupInput
StartupInput.GdiplusVersion = 1
If
GdiplusStartup(m_token, StartupInput, ByVal 0)
Then
MsgBox "Error initializing
GDI+"
Exit Sub
End If
End
Sub
Private Sub Form_Unload(Cancel As
Integer)
Call
GdiplusShutdown(m_token)
End Sub
相关文章
- 12-17JS查询页面是否被百度收录,没有收录则显示搜索链接
- 12-17源码安装git工具,显示/usr/local/lib64/libcrypto.a(dso_dlfcn.o) undefined reference to `dlopen'
- 12-17QT + VTK (QVTKWidget)显示点云,内存泄漏的解决方法
- 12-17如何在image加载的图片上再加载一个透明PNG水印图片
- 12-17没有显示器屏幕时ssh连接树莓派,路由器设置和账号配置
- 12-17树莓派在没有显示器、且不能管理员登录路由器 的情况下链接WiFi(在已有OLED的情况下)
- 12-17帝国cms 不能正常显示最新文章
- 12-17ffmpeg解码h265,并用Qt显示
- 12-17qt控件(checkbox为例)鼠标悬停显示文字
- 12-17利用cv与matplotlib.pyplot读图片与显示图片