VB如何使用PNG图片

我用了GIF控件,会把PNG图片上的透明状态破坏,把图片改成别的格式也是如此请问能告诉我像picturebox一样方便的方法吗?非常感谢!看了你的问题,你回答说你已经知道... 我用了GIF控件,会把PNG图片上的透明状态破坏,把图片改成别的格式也是如此

请问能告诉我像picturebox一样方便的方法吗?
非常感谢!
看了你的问题,你回答说你已经知道像picturebox一样方便的方法了
是怎么弄的啊?或者说把PNG图片怎么处理
反正跟你的问题一样背景要透明
麻烦你告诉我弄下,Thanks.
展开
 我来答
电脑爱好者1236
2012-09-22 · TA获得超过432个赞
知道小有建树答主
回答量:120
采纳率:0%
帮助的人:114万
展开全部
picturebox控件好像不能显示空白背景(.gif.png等),只有image可以加载gif的图片可以使图片透明。image好像不能加载png的图片。
追问
那请问有什么办法加载PNG图片么?我用的是精简版,没有控件!
追答
估计没有
博思aippt
2024-07-20 广告
**AI一键生成PPT免费版**为满足广大用户的需求,我们博思云创科技特推出AI一键生成PPT免费版。用户只需简单输入需求,AI技术便能智能分析并快速生成高质量PPT。此版本功能强大且易于操作,无需专业设计技能,即可轻松打造出令人满意的演示... 点击进入详情页
本回答由博思aippt提供
陕B4444
2012-09-22 · 超过70用户采纳过TA的回答
知道小有建树答主
回答量:207
采纳率:0%
帮助的人:79.1万
展开全部
API 加载 loadimage
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友5b1435d
2012-09-21 · TA获得超过203个赞
知道小有建树答主
回答量:259
采纳率:100%
帮助的人:103万
展开全部
PNG貌似不可以,我也没能成功 应用
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
时如r
2017-09-20
知道答主
回答量:4
采纳率:0%
帮助的人:3685
展开全部
Option Explicit
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type

Private Type PICTDESC
Size As Long
Type As Long
hPic As Long
hPal As Long
End Type

Private Type GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type

Private Declare Function GdiplusStartup Lib "GDIPlus" (token As Long, _
inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long
Private Declare Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal filename As Long, bitmap As Long) As Long
Private Declare Function GdipCreateHBITMAPFromBitmap Lib "GDIPlus" (ByVal bitmap As Long, _
hbmReturn As Long, ByVal background As Long) As Long
Private Declare Function GdipDisposeImage Lib "GDIPlus" (ByVal image As Long) As Long
Private Declare Function GdiplusShutdown Lib "GDIPlus" (ByVal token As Long) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PICTDESC, _
RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long

Public Function LoadImage(ByVal strFName As String) As IPicture
Dim uGdiInput As GdiplusStartupInput
Dim hGdiPlus As Long
Dim hGdiImage As Long
Dim hBitmap As Long

uGdiInput.GdiplusVersion = 1

If GdiplusStartup(hGdiPlus, uGdiInput) = 0 Then
If GdipCreateBitmapFromFile(StrPtr(strFName), hGdiImage) = 0 Then
GdipCreateHBITMAPFromBitmap hGdiImage, hBitmap, 0
Set LoadImage = ConvertToIPicture(hBitmap)
GdipDisposeImage hGdiImage
End If
GdiplusShutdown hGdiPlus
End If

End Function

Public Function ConvertToIPicture(ByVal hPic As Long) As IPicture

Dim uPicInfo As PICTDESC
Dim IID_IDispatch As GUID
Dim IPic As IPicture

Const PICTYPE_BITMAP = 1

With IID_IDispatch
.Data1 = &H7BF80980
.Data2 = &HBF32
.Data3 = &H101A
.Data4(0) = &H8B
.Data4(1) = &HBB
.Data4(2) = &H0
.Data4(3) = &HAA
.Data4(4) = &H0
.Data4(5) = &H30
.Data4(6) = &HC
.Data4(7) = &HAB
End With

With uPicInfo
.Size = Len(uPicInfo)
.Type = PICTYPE_BITMAP
.hPic = hPic
.hPal = 0
End With

OleCreatePictureIndirect uPicInfo, IID_IDispatch, True, IPic

Set ConvertToIPicture = IPic
End Function
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式