Algoritm for scale an image!

Comments and discussions about 8bf plugins which can be use in various applications like Photoshop, Paint Shop Pro or Photo-Paint
Post Reply
bogho
Plugin Expert
Plugin Expert
Posts: 15
Joined: Mon Jun 28, 2004 9:13 am
Location: Romania
Contact:

Algoritm for scale an image!

Post 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

HaraldHeim
Plugin Guru
Plugin Guru
Posts: 3363
Joined: Fri Mar 08, 2002 1:00 am
Location: The Plugin Site
Contact:

Post 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.

Post Reply