Page 1 of 1

Algoritm for scale an image!

Posted: Tue Jul 13, 2004 10:38 am
by bogho
Hi!
Does any one know an algoritm to scale an image, by keeping the aspect ratio.
The image has dimension (PWidth, PHeight), and I want to scale it to the dimension (DimWidth, DimHeight).
If the (PWidth, PHeight) are less then (DimWidth, DimHeight) than don't do any scale
otherwise scale the image to (DimWidth, DimHeight).
This meean that the (DimWidth, DimHeigh) are always less then (PWidth, PHeight).
The original image is given as a matrix of pixels.

Bogdan

Posted: Tue Jul 13, 2004 5:23 pm
by HaraldHeim
There are various image resizing algorithms, e.g. Nearest Neighbor, Bilinear, Bicubic, Lancosz and so on. The more complex and calculation intensive, the better the result.

If you do a search in Google you will find several places with source code that demonstrates how to do that.