Shrink an image to a thumbnail? |
ChiefGoFor | 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 |
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 |
DevlinSE | 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. [:D]
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 [url="http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4214&lngWId=1"]PSCode[/url].
Maybe you can reverse it to do shrinking [:)] |
Sr. Guapo | 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.
[img]http://www.vbgamer.com/msgboard/uploaded/Sr. Guapo/2004112511485_pixels.png[/img] |
DevlinSE | 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 [:D]. It's not so bad...I think.
More info and Examples @ [url="http://www.mentalis.org/agnet/apiguide.shtml"]API Guide[/url]
|
ChiefGoFor | I'm not stretching it, I am shrinking it. I was thinking using some kind of "Bicubic" algorithm. Anythoughts?!?!?!
Kenneth Crowder
AIM: ChiefGoFor |