It's in the SVN, thank you.
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Bill Ensley
> Sent: Wednesday, June 20, 2007 5:31 AM
> To: 'Post all your questions about iText here'
> Subject: [iText-questions] JPEG Image Update for PdfGraphics2D
>
> Hello All
>
> Recently a request was made to update PdfGraphics2D using
> Java's ImageIO
> library instead of relying on com.sun classes.
>
> I have made the updates and included them below.
>
> My apologies for the format of this patch, I am unaccustomed
> to submitting
> code.
>
> Below are the relevent changes:
>
> Line #180
>
> super();
>
> /*
> * Below can be safely removed
> */
>
> /*try {
> Class.forName("com.sun.image.codec.jpeg.JPEGCodec");
> }
> catch (Throwable t) {
> convertImagesToJPEG = false;
> }*/
>
> Line # 1257
>
> BufferedImage scaled = new BufferedImage(img.getWidth(null),
> img.getHeight(null), BufferedImage.TYPE_INT_RGB);
> Graphics2D g3 = scaled.createGraphics();
> g3.setColor(Color.WHITE);
> g3.fillRect(0,0,img.getWidth(null), img.getHeight(null));
> g3.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null),
> null);
> g3.dispose();
> img.flush();
> img = null;
>
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
>
>
> /*
> * Below comments can be safely removed
> */
>
> /*com.sun.image.codec.jpeg.JPEGImageEncoder encoder =
> com.sun.image.codec.jpeg.JPEGCodec.createJPEGEncoder(baos);
> com.sun.image.codec.jpeg.JPEGEncodeParam param =
> com.sun.image.codec.jpeg.JPEGCodec.getDefaultJPEGEncodeParam(scaled);
> param.setQuality(jpegQuality, true);
> encoder.encode(scaled, param);*/
>
> /*
> * End removal
> */
>
> ImageWriteParam iwparam = new
> JPEGImageWriteParam(Locale.getDefault());
> iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
> iwparam.setCompressionQuality(jpegQuality);//Set here your
> compression rate
> ImageWriter iw =
> ImageIO.getImageWritersByFormatName("jpg").next();
> ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
> iw.setOutput(ios);
> iw.write(null, new IIOImage(scaled, null, null), iwparam);
> iw.dispose();
> ios.close();
>
> scaled.flush();
> scaled = null;
> image = com.lowagie.text.Image.getInstance(baos.toByteArray());
> baos.flush();
> baos.close();
>
>
> Sincerely,
>
> Bill Ensley
> Phone: 503.244.4738
> Fax: 503.244.5235
>
> <http://www.bearprinting.com>
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/