Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.gui.image
Class SubpixAA

java.lang.Object
  extended by ch.randelshofer.gui.image.SubpixAA

public class SubpixAA
extends java.lang.Object

Scales an image down and applies Subpixel antialiasing to it.

Version:
1.0 2009-12-11 Created.
Author:
Werner Randelshofer

Field Summary
static java.lang.Object HBGR
           
static java.lang.Object HRGB
           
static java.lang.Object VBGR
           
static java.lang.Object VRGB
           
 
Constructor Summary
SubpixAA()
           
 
Method Summary
static void aa(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst, java.lang.Object m)
          Scales down an image using the specified antialiasing method.
static void aaHBGR(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
          Scales down an image using HBGR antia-aliasing.
static void aaHRGB(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
          Scales down an image using HRGB antia-aliasing.
static void aaVBGR(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
          Scales down an image using VBGR antia-aliasing.
static void aaVRGB(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
          Scales down an image using VRGB antia-aliasing.
 void drawAA(java.awt.Graphics gr, java.awt.image.BufferedImage img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
          Renders an image with subpixel antialiasing.
 void drawAA(java.awt.Graphics gr, java.awt.image.BufferedImage img, int x, int y, int width, int height, java.lang.Object method, java.awt.image.ImageObserver observer)
          Renders an image with subpixel antialiasing.
static java.awt.Dimension getSourceDimension(int width, int height, java.lang.Object method)
          Returns the dimensions needed of the source image for the desired destination image size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HBGR

public static final java.lang.Object HBGR

VBGR

public static final java.lang.Object VBGR

HRGB

public static final java.lang.Object HRGB

VRGB

public static final java.lang.Object VRGB
Constructor Detail

SubpixAA

public SubpixAA()
Method Detail

drawAA

public void drawAA(java.awt.Graphics gr,
                   java.awt.image.BufferedImage img,
                   int x,
                   int y,
                   int width,
                   int height,
                   java.awt.image.ImageObserver observer)
Renders an image with subpixel antialiasing. This method uses caching to improve the performance of subsequent calls. The image must be larger than the destination width and height.


drawAA

public void drawAA(java.awt.Graphics gr,
                   java.awt.image.BufferedImage img,
                   int x,
                   int y,
                   int width,
                   int height,
                   java.lang.Object method,
                   java.awt.image.ImageObserver observer)
Renders an image with subpixel antialiasing. This method uses caching to improve the performance of subsequent calls. The image must be larger than the destination width and height.


getSourceDimension

public static java.awt.Dimension getSourceDimension(int width,
                                                    int height,
                                                    java.lang.Object method)
Returns the dimensions needed of the source image for the desired destination image size.

Parameters:
width - The desired width of the destination image.
height - The desired height of the destination image.
method - The Antialiasing method to be used must be one of RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, ..._HBGR,

aa

public static void aa(java.awt.image.BufferedImage src,
                      java.awt.image.BufferedImage dst,
                      java.lang.Object m)
Scales down an image using the specified antialiasing method.

For methods HBGR and HRGB, the image width is scaled down by factor 3. For methods VBGR and VRGB, the image height is scaled down by factor 3.

Parameters:
src - The source image.
dst - The destination image.
m - The method.

aaHRGB

public static void aaHRGB(java.awt.image.BufferedImage src,
                          java.awt.image.BufferedImage dst)
Scales down an image using HRGB antia-aliasing.

Source and destination image must be of type BufferedImage.TYPE_RGB and have a data buffer of type DataBufferInt.

The height of source and destination image must be the same. The width of the source image must be 3 times the width of the destination image.

Intensity weights:


            1
            |
       +----+----+
       |    |    |
      1/3  1/3  1/3
            |
  +----+----+----+----+
  |    |    |    |    |
 1/9  2/9  3/9  2/9  1/9
 

Parameters:
src - The source image.
dst - The destination image.

aaHBGR

public static void aaHBGR(java.awt.image.BufferedImage src,
                          java.awt.image.BufferedImage dst)
Scales down an image using HBGR antia-aliasing.

Source and destination image must be of type BufferedImage.TYPE_RGB and have a data buffer of type DataBufferInt.

The height of source and destination image must be the same. The width of the source image must be 3 times the width of the destination image.

Intensity weights:


            1
            |
       +----+----+
       |    |    |
      1/3  1/3  1/3
            |
  +----+----+----+----+
  |    |    |    |    |
 1/9  2/9  3/9  2/9  1/9
 

Parameters:
src - The source image.
dst - The destination image.

aaVRGB

public static void aaVRGB(java.awt.image.BufferedImage src,
                          java.awt.image.BufferedImage dst)
Scales down an image using VRGB antia-aliasing.

Source and destination image must be of type BufferedImage.TYPE_RGB and have a data buffer of type DataBufferInt.

The width of source and destination image must be the same. The height of the source image must be 3 times the height of the destination image.

Intensity weights:


            1
            |
       +----+----+
       |    |    |
      1/3  1/3  1/3
            |
  +----+----+----+----+
  |    |    |    |    |
 1/9  2/9  3/9  2/9  1/9
 

Parameters:
src - The source image.
dst - The destination image.

aaVBGR

public static void aaVBGR(java.awt.image.BufferedImage src,
                          java.awt.image.BufferedImage dst)
Scales down an image using VBGR antia-aliasing.

Source and destination image must be of type BufferedImage.TYPE_RGB and have a data buffer of type DataBufferInt.

The width of source and destination image must be the same. The height of the source image must be 3 times the height of the destination image.

Intensity weights:


            1
            |
       +----+----+
       |    |    |
      1/3  1/3  1/3
            |
  +----+----+----+----+
  |    |    |    |    |
 1/9  2/9  3/9  2/9  1/9
 

Parameters:
src - The source image.
dst - The destination image.

Copyright 2011-01-06 Werner Randelshofer