Usage (original) (raw)

Quick start

To start using the library, just call RgbYuv.hqxInit() first, to initialize the color lookup table needed for the magnification, and then call Hqx_[234]x.hq[234]x_rb(...) for a 2, 3 or 4 magnification of your image.

Example

// Load an image BufferedImage bi = ImageIO.read("image.png"); if (bi != null) { // Convert image to ARGB if on another format if (bi.getType() != BufferedImage.TYPE_INT_ARGB && bi.getType() != BufferedImage.TYPE_INT_ARGB_PRE) { final BufferedImage temp = new BufferedImage(bi.getWidth(), bi.getHeight(), BufferedImage.TYPE_INT_ARGB); temp.getGraphics().drawImage(bi, 0, 0, null); bi = temp; } // Obtain pixel data for source image final int[] data = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();

// Initialize lookup tables
RgbYuv.hqxInit();

// Create the destination image, twice as large for 2x algorithm
final BufferedImage biDest2 = new BufferedImage(bi.getWidth() * 2, bi.getHeight() * 2, BufferedImage.TYPE_INT_ARGB);
// Obtain pixel data for destination image
final int[] dataDest2 = ((DataBufferInt) biDest2.getRaster().getDataBuffer()).getData();
// Resize it
Hqx_2x.hq2x_32_rb(data, dataDest2, bi.getWidth(), bi.getHeight());
// Save our result
ImageIO.write(biDest2, "PNG", new File("image2x.png"));

// More calls to hq[234]x_32_rb() methods
// ....

// Release the lookup table
RgbYuv.hqxDeinit();

}

Add a custom footer