Using the Java Library to Create a BufferedImage Object

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);

Category:

Online Demo