to.etc.sjit
Class ImageSubsampler

java.lang.Object
  extended by to.etc.sjit.ImageSubsampler

public class ImageSubsampler
extends java.lang.Object

Subsamples an image to create a smaller (or larger(!)) image. This can use several sampling filters.

Credits:

The algorithms and methods used in this library are based on the article "General Filtered Image Rescaling" by Dale Schumacher which appeared in the book Graphics Gems III, published by Academic Press, Inc.

Performance enhancements: (all in milliseconds)

OneTenWhat was done?
2047 19,812 Initial, slow version sans opt
765 6,719Using direct-access to BufferedImage's INT RBG buffer for the row sampler only
4063,531Using direct-access for the COLUMN resampler..

Author:
Frits Jalvingh

Method Summary
static void main(java.lang.String[] args)
           
static java.awt.image.BufferedImage resample(java.awt.image.BufferedImage srci, ResamplerFilter f, int ow, int oh)
          The actual sampler code which converts a source image to a destination image, reducing or enlarging the image.
static java.awt.Point resizeWithAspect(int w, int h, int iw, int ih)
          Does a resize of an object with size (iw, ih) to fit within a rectangle of (w, h) while keeping the same aspect ratio
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resample

public static java.awt.image.BufferedImage resample(java.awt.image.BufferedImage srci,
                                                    ResamplerFilter f,
                                                    int ow,
                                                    int oh)
The actual sampler code which converts a source image to a destination image, reducing or enlarging the image. The size reduction does NOT obey aspect ratio rules.


resizeWithAspect

public static java.awt.Point resizeWithAspect(int w,
                                              int h,
                                              int iw,
                                              int ih)
Does a resize of an object with size (iw, ih) to fit within a rectangle of (w, h) while keeping the same aspect ratio


main

public static void main(java.lang.String[] args)