Modifying with GDIplus library to display png graphics

boroangel
01-09-2005, 03:58 AM
Can anyone help me modify this code so that I can use the Gdiplus library to display the png files? I click on references on add the libraries but dont know which code to add to my existing code.

This is my code:

Option Explicit

Private Sub Form_Load()
On Error Resume Next

'ADDED THIS LINE
set imgBOX.Picture = LoadPicture("PATH TO YOUR IMAGE")

picBOX.AutoRedraw = True
scrVERT.Max = ScaleY(imgBOX.Picture.Height, vbHimetric, vbPixels) - ScaleY(picBOX.ScaleHeight, vbTwips, vbPixels)
scrHOR.Max = ScaleX(imgBOX.Picture.Width, vbHimetric, vbPixels) - ScaleX(picBOX.ScaleWidth, vbTwips, vbPixels)

'just setting these to larger values to have faster scroll
scrVERT.SmallChange = 50
scrVERT.LargeChange = 100
scrHOR.SmallChange = 50
scrHOR.LargeChange = 100

'paint the top left of the picture to the size of the picture box
picBOX.PaintPicture imgBOX.Picture, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight
End Sub
Private Sub scrHOR_Change()
On Error Resume Next
MovePic
End Sub
Private Sub scrVERT_Change()
On Error Resume Next
MovePic
End Sub
Private Sub MovePic()
On Error Resume Next
picBOX.Cls
picBOX.PaintPicture imgBOX.Picture, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight, ScaleX(scrHOR.Value, vbPixels, vbTwips), ScaleY(scrVERT.Value, vbPixels, vbTwips), picBOX.ScaleWidth, picBOX.ScaleHeight
End Sub
Private Sub scrVERT_Scroll()
On Error Resume Next
MovePic
End Sub
Private Sub scrHOR_Scroll()
On Error Resume Next
MovePic
End Sub

I have attached the gdiplus library

OnErr0r
01-09-2005, 09:48 AM
You'll want to use the newest class wrappers available for Gdiplus 1.0 (Don't use the 1.1 version posted unless you want to target gdiplus 1.1). I have an example already posted which will display a PNG with transparency.

See post #4 of this thread (http://www.visualbasicforum.com/showthread.php?t=98285).

boroangel
01-09-2005, 09:56 AM
Hi Onerror, so u mean I should use this GDIPlus instead?
the problem is I m new in VB and I dont understand a lot of the code , thats y I asked this in the newbie section and I need someone to modify it for me...

OnErr0r
01-09-2005, 10:27 AM
the problem is I m new in VB and I dont understand a lot of the code , thats y I asked this in the newbie section and I need someone to modify it for me...

"Legacy VB" in this section refers to the older vb versions 4, 5 and 6. It has nothing to do with the skill level of the coder.

The code I have provided is a working sample. This board exists for code discussion and help. When you have a particular problem with some code you've written or some algorithm, then we'll help with that. However, it does not exist to write/alter code for people. Study some VB books and when you become more proficient at coding you will be able to use/alter more complex code.

boroangel
01-09-2005, 10:34 AM
Yes I get your point completely...its just that I need this in a few hours time and I only realised I had this problem just now...anyway I will try to see what I can do...thanks for your help anyway...

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum