problems with WIA / PNG's

vb6 , wia , gif , image , manipulation United Kingdom
  • 12 years ago
    Hi there , a while ago i wrote some image manipulation functions using microsofts WIA mainly because it allows you to easily load png images and modify them on a perpixel basis. So i then wrote a GUI (the program was a button editor) but when ive come to use the functions in the main program im now having problems with transparent pixels being saved as black. Ive gone back and checked all the old test bits of code i made when i first made the functions and they are giving me the same results. Hers an example of the code ive been using [code] Private Sub Modify() Dim Img As ImageFile Dim ImgB As ImageFile Dim IP As ImageProcess Dim vA As Vector Dim vB As Vector Dim i As Long Set ImgB = CreateObject("WIA.ImageFile") Set Img = CreateObject("WIA.ImageFile") Set IP = CreateObject("WIA.ImageProcess") MakePic ImgB, 40, 40 Img.LoadFile "C:\Test.png" Set vA = Img.ARGBData Set vB = ImgB.ARGBData For i = 1 To vA.Count vB(i) = vA(i) Next IP.Filters.Add IP.FilterInfos("ARGB").FilterID Set IP.Filters(1).Properties("ARGBData") = vB Set ImgB = IP.Apply(ImgB) ImgB.SaveFile "C:\done.png" End Sub Public Function MakePic(ImgBlank As ImageFile, W As Long, H As Long) Dim WiaImgProcessRes As ImageProcess Dim nVec As Vector Dim nCol As Long nCol = -1 '=============== Create 2x2 blank pic Set nVec = CreateObject("WIA.Vector") nVec.Add nCol: nVec.Add nCol: nVec.Add nCol: nVec.Add nCol Set ImgBlank = nVec.ImageFile(2, 2) '=============== resize blank pic Set WiaImgProcessRes = CreateObject("WIA.ImageProcess") WiaImgProcessRes.Filters.Add WiaImgProcessRes.FilterInfos("Scale").FilterID WiaImgProcessRes.Filters(1).Properties!PreserveAspectRatio = False WiaImgProcessRes.Filters(1).Properties("MaximumWidth") = W WiaImgProcessRes.Filters(1).Properties("MaximumHeight") = H Set ImgBlank = WiaImgProcessRes.Apply(ImgBlank) End Function [/code] Its simply loads in a png (with some transparent pixels) and puts it into an array, i then make a blank image(of transparent pixels) of the same size and put that into another array. Then copy from one array to the other and save. Normal this mixes the 2 images fine but now the transparent pixels are being saved as black for some reason ? Thanks

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The question of whether computers can think is just like the question of whether submarines can swim.” - Edsger W. Dijkstra