ChiefGoFor |
Posted - Nov 25 2004 : 09:43:07 AM 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 |
DevlinSE |
Posted - Nov 29 2004 : 04:15:06 AM 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 |
Brykovian |
Posted - Nov 28 2004 : 8:12:34 PM "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 |
ChiefGoFor |
Posted - Nov 25 2004 : 11:18:16 PM I'm not stretching it, I am shrinking it. I was thinking using some kind of "Bicubic" algorithm. Anythoughts?!?!?!
Kenneth Crowder AIM: ChiefGoFor |
DevlinSE |
Posted - Nov 25 2004 : 4:05:46 PM 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
|
Sr. Guapo |
Posted - Nov 25 2004 : 11:39:55 AM 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.
|
|
|