BufferedImage raster data in Java

Most of the time, the abstraction you get in Java is brilliant. It hides the complexity and lets you get on with real-life problem solving. This is especially true of the Image classes where you can forget about Tiffs, PNGs and Jpegs and just work with images. Occasionally though you need to dig deeper and…

Read More

PDF to image quality

The PDF file format was designed as much as possible to be Vector graphics. The problem with bitmaps and pixels is that pixels can only be on or off. While you can use some clever tricks such as anti-aliasing and hinting to smooth lines, you can’t draw fractions of a pixel. If a line is…

Read More

Saving Java images as Tifs wth JAI

Java makes it very easy to create images as BufferedImages which¬† can then be saved out in standard image file formats. Here is the code to save an image as a Tif image using the JAI image (a free library from Sun). com.sun.media.jai.codec.TIFFEncodeParam params = new com.sun.media.jai.codec.TIFFEncodeParam(); FileOutputStream os = new FileOutputStream(outputDir + imageName+”.tif”); javax.media.jai.JAI.create(“encode”,…

Read More

Odd coloured JPEGs in Java with ImageIO

One of the best features about Java is the amount of low-level complexity it removes, allowing you to focus on developing the application. However, this does sometimes hide some important issues. We found one of these with the ImageIO class which offers a whole series of methods to save an image as a Tiff, a…

Read More