Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Shrink an image to a thumbnail?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ChiefGoFor
Neophyte

USA
3 Posts

Posted - Nov 25 2004 :  09:43:07 AM  Show Profile  Visit ChiefGoFor's Homepage  Send ChiefGoFor an AOL message  Reply with Quote
Hello All,
I am attempting to shrink an image down to a thumbnail, but when I do, I lose quality. The result just looks like crap. Does anyone know Algorithm I should use? Also, do you know where I could find a sample of the code to test? Thanks a lot!

Kenneth
AIM: ChiefGoFor

Sr. Guapo
Swordmaster

USA
272 Posts

Posted - Nov 25 2004 :  11:39:55 AM  Show Profile  Reply with Quote
How are you doing it now? The easiet way I could think of is to just average all of the pixels in a square (of however many pixels), then use that as one pixel in the thumbnail.




Edited by - Sr. Guapo on Nov 25 2004 11:48:47 AM
Go to Top of Page

DevlinSE
Squire

19 Posts

Posted - Nov 25 2004 :  4:05:46 PM  Show Profile  Click to see DevlinSE's MSN Messenger address  Send DevlinSE a Yahoo! Message  Reply with Quote
I'm don't know if there is a way to shrink/stretch an image without distorting it very much. But if you're not stretching it too much and not using it in DX you can try using StretchBlit api:

Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

Anyway, that's what I used for my crummy mapeditor . It's not so bad...I think.

More info and Examples @ API Guide


Just remember to keep smiling while you're programming or your code won't work. There's no sense in cursing the code...further...
Go to Top of Page

ChiefGoFor
Neophyte

USA
3 Posts

Posted - Nov 25 2004 :  11:18:16 PM  Show Profile  Visit ChiefGoFor's Homepage  Send ChiefGoFor an AOL message  Reply with Quote
I'm not stretching it, I am shrinking it. I was thinking using some kind of "Bicubic" algorithm. Anythoughts?!?!?!

Kenneth Crowder
AIM: ChiefGoFor
Go to Top of Page

Brykovian
Bryk the Cheese Slayer!

USA
58 Posts

Posted - Nov 28 2004 :  8:12:34 PM  Show Profile  Visit Brykovian's Homepage  Click to see Brykovian's MSN Messenger address  Reply with Quote
"StretchBlt" does all kinds of resizing ... even though it's called *stretch*, it will shrink just as well. Otherwise, you're left with having to do pixel-by-pixel averaging, like Sr. Guapo suggested.

-Bryk

www.mwgames.com
Go to Top of Page

DevlinSE
Squire

19 Posts

Posted - Nov 29 2004 :  04:15:06 AM  Show Profile  Click to see DevlinSE's MSN Messenger address  Send DevlinSE a Yahoo! Message  Reply with Quote
quote:
Originally posted by Brykovian

"StretchBlt" does all kinds of resizing ... even though it's called *stretch*, it will shrink just as well. Otherwise, you're left with having to do pixel-by-pixel averaging, like Sr. Guapo suggested.

-Bryk



Yeah, what he said.

But bicubic and bilinear still looks better, I can't find any code thought.
I just found a bicubic sample source which only literally "Stretches" an image from PSCode.
Maybe you can reverse it to do shrinking

Just remember to keep smiling while you're programming or your code won't work. There's no sense in cursing the code...further...
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.11 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.