Messages of subject
PJA with Domino 6.5 on Linux Redhat 7.3 ( JVM 1.3.1 ) |
bunoir
Location : London
Member since : Feb 2, 2004
Messages : 3
|
Feb 2, 2004 at 7:37 PM
I'm hoping you could give me some advice on how to continue with this. I've got this far but am a bit confused about what to do next - Domino is fixed at 1.3.1 JVM and I can get this working with Xfvb but would really love it to be native.
String inPath = iconPath + slash + originals + slash + "Winter.jpg" ;
Utils.debug ( "The icon path is " + inPath ) ;
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder ( new FileInputStream ( inPath ) );
BufferedImage image = decoder.decodeAsBufferedImage ();
ColorModel cm = image.getColorModel ();
Raster raster = image.getRaster ();
SampleModel sm = raster.getSampleModel ();
DataBuffer buffy = (DataBufferInt) raster.getDataBuffer ();
int dt = buffy.getDataType ();
System.out.println ( "The raster's data type is " + dt );
System.out.println ( "It's data size is " + buffy.getDataTypeSize ( dt ) );
DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer ();
int[] data = buffer.getData ();
// 1st thing: see if we can just write out the original image.
DataBuffer resultBuffer = new DataBufferInt ( data, data.length );
WritableRaster resultRaster = Raster.createWritableRaster ( sm, resultBuffer, null );
BufferedImage thumbImage = new BufferedImage ( cm, resultRaster, false, null );
BufferedOutputStream out = new BufferedOutputStream ( new FileOutputStream ( iconPath + slash + "buster2.jpg" ) );
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder ( out );
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam ( thumbImage );
param.setQuality ( 1.0f, false);
encoder.setJPEGEncodeParam ( param );
encoder.encode ( thumbImage ) ;
So I can get a buffered image, bypassing the toolkit but am uncertain now of how to proceed. I wouls normally call now:
// create a new image of the desired size
Graphics2D graphics2D = thumbImage.createGraphics();
graphics2D.setRenderingHint( RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR );
graphics2D.drawImage( image,
0,
0,
resizedWidth,
resizedHeight,
null );
thereby creating a new image of the size I want and then writing it out.
what I don't understand is how this is done differently with the toolkit, it may not be possible with Domino but I'd be grateful if someone knows better than I do.
MTIA, George :)
|
Manu
Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
|
Feb 3, 2004 at 2:21 AM
From JDK 1.2, drawing with PJA Toolkit is done with the same library as default Java Toolkit, so an image will be rendered the same way with both toolkits. The only thing you'll need is to install some basic X11 libs (as described in the subject http://www.eteks.com/pja/en/forum/viewSubject.jsp?subjectId=38#45 ) and change a few JVM properties.
com.eteks.awt.PJAGraphics and com.eteks.awt.PJAImage classes where most of PJA Toolkit code is, are usefull only with JDK <= 1.1 or if you don't want to install any X11 lib on your system. In the latter case, you will be able to create offscreen images but only if you explicitly use PJA Toolkit classes. --- Manu (moderator/modérateur)
|
bunoir
Location : London
Member since : Feb 2, 2004
Messages : 3
|
Feb 3, 2004 at 9:58 AM
Merci Manu - this is one of the problems I think. To date I have not been able to change the property in Domino, I've question pending about this but I think it may be entwined in their security model - they are quite touchy about people messing with the JVM - if you do they remove support...
Is it possible to make calls without changing the properties?
Merci beaucoup! Georges :)
|
Manu
Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
|
Feb 3, 2004 at 5:22 PM
If you can install basic X11 libs on you machine, you'll be able to read JPEG files with com.eteks.awt.PJAToolkit class and create JPEG files or streams with the JIMI library that you can download at http://java.sun.com/products/jimi/ . JIMI includes a JPEG encoder and image filters that should fit your needs. It also includes a JPEG decoder but this feature requires a X11 Display (or changing System properties), that's why you'll need PJAToolkit to load your image.
Here's an piece of code that works :
// Read an image using explicitly PJAToolkit class
// to avoid setting X11 Display or changing System properties
java.awt.Image image = new com.eteks.awt.PJAToolkit().getImage ("photo.jpg");
// Apply a filter on the image. You could also draw into it with the Graphics object
// returned by getGraphics (but without Java2D features)
java.awt.image.ImageProducer filteredImage = new java.awt.image.FilteredImageSource (image.getSource (),
new com.sun.jimi.core.filters.AreaAverageScaleFilter (150, 150));
// Encode the image with JIMI JPEG encoder
com.sun.jimi.core.Jimi.putImage ("image/jpeg", filteredImage, new java.io.FileOutputStream ("photo150x150.jpg"));
Bonne soirée ;-) --- Manu (moderator/modérateur)
|
bunoir
Location : London
Member since : Feb 2, 2004
Messages : 3
|
Feb 4, 2004 at 11:49 AM
Manu - c'est magnifique! Tout fonctionne parfaitement!
I also got the image in without using PJA - like this:
import com.sun.image.codec.jpeg.*;
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder ( new FileInputStream ( "/local/notesdata/domino/icons/Winter.jpg" ) );
Image image = decoder.decodeAsBufferedImage() ;
This confused me as well, because it's not a buffered image...
and then used JIMI as you suggested.
Merci beaucoup pour tout l'assistance.
Georges :)
|