> On 27 Apr 2015, at 14:03, Tilman Hausherr <[email protected]> wrote: > > Am 27.04.2015 um 20:08 schrieb John Hewson: >>> On 27 Apr 2015, at 08:52, Tilman Hausherr <[email protected]> wrote: >>> >>> PDImageXObject pdImage; >>> if (imagePath.toLowerCase().endsWith(".jpg")) >>> { >>> pdImage = JPEGFactory.createFromStream(doc, new >>> FileInputStream(imagePath)); >>> } >>> else if (imagePath.toLowerCase().endsWith(".tif") || >>> imagePath.toLowerCase().endsWith(".tiff")) >>> { >>> pdImage = CCITTFactory.createFromFile(doc, new >>> File(imagePath)); >>> } >>> else if (imagePath.toLowerCase().endsWith(".gif") || >>> imagePath.toLowerCase().endsWith(".bmp") || >>> imagePath.toLowerCase().endsWith(".png")) >>> { >>> BufferedImage bim = ImageIO.read(new File(imagePath)); >>> pdImage = LosslessFactory.createFromImage(doc, bim); >>> } >>> else >>> { >>> throw new IOException("Image type not supported: " + >>> imagePath); >>> } >> Tilman, maybe we could encapsulate this code in a static factory method, >> e.g. PDImageXObject.load(File)? > > Yes, that's a good idea... the only thing that irritates me is that if we > replace the above code with load(), the example will no longer show how to > create an XImage from a BufferedImage. >
Maybe we could have both in the example, or PDImageXObject.load(BufferedImage) too? — John > Tilman > >> >> — John > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > <mailto:[email protected]> > For additional commands, e-mail: [email protected] > <mailto:[email protected]>

