[udig-devel] dpi issues

Vince Darley vince.darley at eurobios.com
Wed Mar 26 08:28:26 PDT 2008


At 15:16 26/03/2008, andrea antonello wrote:
>You are telling me that if you zoom in one of your BIRT created pdfs
>you do not see grained curves and so on?

Oh I certainly do, but in a '300 dpi' output the blockiness is only 
seen by zooming in 4x more than in a '72 dpi' output.

I should say that the method I'm using, which was based on code from 
some udig snippet somewhere (and feedback from this list) effectively 
allocates a much bigger BufferedImage for the 300 dpi case - the 
image needs, of course, to have one pixel for each 'dot' in the 
dpi.  That image is handed over to BIRT and BIRT creates the report 
(it has a choice of pdf, postscript, html, doc, ppt, etc).  I've only 
really used html, pdf outputs.

Here's the basic code:

mult = ((double) dpi) / 72.0;

/**
  * Note: TYPE_INT_ARGB produces colour-inverted PDF images for some 
reason. Since we prefer
  * nice pdf reports to worrying about transparency, we use TYPE_INT_RGB.
  */
int type = BufferedImage.TYPE_INT_RGB;
BufferedImage image = new BufferedImage((int) (width * mult), (int) 
(height * mult), type);

Graphics2D g = image.createGraphics();

[snip]

DrawMapParameter dmp = new DrawMapParameter(g, new 
java.awt.Dimension((int) (width * mult),
(int) (height * mult)), map, bs, dpi, style, new NullProgressMonitor());
try {
ApplicationGIS.drawMap(dmp);
}
catch (RenderException e) {
logger.log(Level.WARNING, "Problem drawing Map:" + e);
}
finally {
g.dispose();
}

try {
mapImageFile = File.createTempFile("ewo", "." + getImageExtensionType());
ImageIO.write(image, getImageExtensionType(), mapImageFile);
fis = new FileInputStream(mapImageFile.getPath());
}
catch (IOException e) {
logger.log(Level.WARNING, "Problem writing Map report image " + e);
}

return fis;

// and 'fis' is used by BIRT.

Vince.

Vince Darley
CEO, Eurobios UK Ltd
Tel: +44 207 921 0445
Mobile: +44 794 154 8527
www.eurobios.com



More information about the udig-devel mailing list