|
本帖最后由 aman1516 于 2024-11-23 21:38 编辑
是原罪吗,PNG格式图片在不少编程、控件中不受见地,
问题一:能否将工作表中的透明图片导出成真正的PNG图片?
- Sub ExpPng() '问题一:能否将工作表中的透明图片导出成真正的PNG图片?
- Dim shp As Shape
- For Each shp In ActiveSheet.Shapes
- shp.Copy
- With ActiveSheet.ChartObjects.Add(0, 0, shp.Width, shp.Height).Chart
- '.Parent.Select
- Application.Wait Now + TimeValue("00:00:02")
- .ChartArea.Select
- .Paste
- .Export ThisWorkbook.Path & "\Test_" & shp.Name & ".png" '并非真正的PNG文件
- .Parent.Delete
- End With
- Next
- End Sub
复制代码
问题二:能否将工作表透明图片读入到WIA数组中?(当然,如果问题一能解决,问题二就解决了,或另有方法)
- Sub WiaShp() '问题二:能否将工作表透明图片读入到WIA数组中?
- Dim Img 'As ImageFile
- Dim IP 'As ImageProcess
- Dim v 'As Vector
- Dim i 'As Long
- Dim ofile As String, sflie As String
- Set Img = CreateObject("WIA.ImageFile")
- Set IP = CreateObject("WIA.ImageProcess")
- Set shp = ActiveSheet.Shapes("图片 2")
-
- 'call ExpPng '上面问题一方法,将Shp导出为本地PNG,再读入到WIA
-
- '方法二,直接将Shp生成WIA格式的 Img.ARGBData
-
- ofile = ThisWorkbook.Path & "\Bliss.png"
- Img.LoadFile ofile
- Set v = Img.ARGBData
- For i = 1 To v.Count
- 'Debug.Print v(i) 'ARGB (A=xxxx,R=xxx,G=xxx,B=xxx)
- '.......
- Next
- '......
- End Sub
复制代码 详见附件,望各位老师赐教:
生成真正的PNG图片.rar
(476.25 KB, 下载次数: 7)
|
|