Tips For Success

Having the best tools for document imaging is only half of the equation. Our Tech Tips are designed to provide you with valuable information to help succeed by achieving faster results with RasterMaster SDKs or FlexSnap viewers. New time-saving tips are added monthly - you can receive them through Imaging News or our Tech Tips RSS feed.

Using the Java Library to Create a BufferedImage Object

This Tech Tip appeared in Imaging News February 2005

Many users of the RasterMaster Java imaging SDK have existing code that uses java.awt.Image and java.awt.image.BufferedImage objects to process image data. You can use RasterMaster to create BufferedImage objects from any of the file formats supported by RasterMaster. Here is an example:

/**

* @param filename The full path of the image file

* @param pageNumber The index of the page to load

*

* @return BufferedImage object with data loaded from the specified file

*/

public BufferedImage loadBufferedImage (String filename, int pageNumber)

{

Snowbnd snow = new Snowbnd();

int stat = snow.IMG_decompress_bitmap(filename, pageNumber);

int width = snow.getWidth();

int height = snow.getHeight();

BufferedImage bufImage = new BufferedImage(width,

height,

BufferedImage.TYPE_INT_RGB);

Graphics bufG = bufImage.getGraphics();

snow.IMG_display_bitmap_aspect(bufG, this, 0, 0, width, height, 0);

return bufImage;

}


Now, whenever you need an instance of java.awt.Image, you can make the following call:

Image myImage = loadBufferedImage ("c:/images/myImage.jpg", 0);