VB6.0载入PNG格式图片
如题,求大神指教。不直接载入到窗口上,我需要放到frame或Picture中。有控件的大神麻烦上传一下,确定能使用后必定采纳。如果能用代码实现最好不过。各位大神不要藏着掖...
如题,求大神指教。
不直接载入到窗口上,我需要放到frame或Picture中。
有控件的大神麻烦上传一下,确定能使用后必定采纳。
如果能用代码实现最好不过。
各位大神不要藏着掖着,分享一下呗。
跪谢~~~~ 展开
不直接载入到窗口上,我需要放到frame或Picture中。
有控件的大神麻烦上传一下,确定能使用后必定采纳。
如果能用代码实现最好不过。
各位大神不要藏着掖着,分享一下呗。
跪谢~~~~ 展开
2个回答
展开全部
给你一个示例吧,显示PNG到FORM上,用GDI的:
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() ‘Form上显示
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
更多追问追答
追问
哥们,这段代码我知道,他是显示在窗体上的,不是我需要的。
最好是单独的一个控件,能够显示PNG图片
或者去掉JPG图片的背景白底
追答
如果不显示在窗体上,修改下就行了,下面是显示在picturebox1控件里:
Private Sub picturebox1_paint() ‘Form上显示
...
Call GdipCreateFromHDC(Me.picturebox1.hDC, pGraphics)
但去背景的话,要你自己定义背景的色,我再找找
博思aippt
2024-07-20 广告
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |