|
-
Jan 23rd, 2003, 01:00 PM
#1
Thread Starter
Frenzied Member
Resizing a PNG to fit a static picturebox exactly[RESOLVED]
hello boys and girls.
Can anyone lend a hand with resizing a PNG to fit inside a picture box? Ive got the PNG file loaded and it displays it in my picture box but it doesnt do it to fit. I have a maximum available width and height and would ideally like the png file to fit to the largest dimension whilst keeping the aspect ratio.
Anyone know anything about how to do it? Thanks
I can post my code so far if need be its only small but needs the zlib.dll PNG library which i can also attach
Last edited by Blobby; Jan 25th, 2003 at 10:40 AM.
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Jan 23rd, 2003, 01:09 PM
#2
Good Ol' Platypus
Search for "bilinear interpolation" on Google. There should be some C code in your results, just adapt it to fit your needs (ex. to resize a byte array). There is also the StretchDIBits method that you can use.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jan 23rd, 2003, 01:21 PM
#3
Thread Starter
Frenzied Member
Sastraxi, thanks for those big words 
Ill look them up in the dictonary and check them out Thanks a lot
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Jan 25th, 2003, 10:20 AM
#4
Bilinear interpolation is a good resizing algorithm (though I think bicubic is even better). The problem of such algorithms is that nearly all code you'll find is either C/C++, Pascal or ASM. Image resizing is calculation and data intensive, so it's exactly the thing VB is NOT suited for.
StretchDIBits (or StretchBlt) is quite nice, but you need a way to fix the image into the picture box.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 25th, 2003, 10:39 AM
#5
Thread Starter
Frenzied Member
CornedBee, thanks for that....ive just finished the resize/repostion code in Vb as i type this. Ill change the topic to resolved. What did you mean when you said 'fix' the image into the picture box? Ive used stretchblt to redraw and resize the image and it seems to work fine so im puzzled as to why it needs 'fix'ing.
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Jan 25th, 2003, 07:20 PM
#6
I don't know much about the inner workings of VB. I was concerned that if you simply StretchBlt an image to the picturebox it might get erased as soon as the picturebox gets redrawn.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 25th, 2003, 07:24 PM
#7
Thread Starter
Frenzied Member
Well, im not sure as its displaying 98% of the images perfect but there a couple of images that refuse to draw and just give me a blank screen. i can scroll up 50 others and the work fine but going back to the troublesome one still refuses to display. The next time i run the prog however the pic displays fine so its not the pic. Im confused....it may be libpng error or zlib...i just dont know!
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|