|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
jai.create operationshello.
i'm newbe to java, so bare with me.. i need to do the following operations: read tiff file crop a part of it change its dpi to 200 resize it to H*W save it back what i'v got so far is this base on code from - https://jaistuff.dev.java.net: public static void func(String fn, float x,float y,float w,float h) throws IOException { //read the file PlanarImage input = JAI.create("fileload",fn); ParameterBlock pb = new ParameterBlock(); //set cropping area pb.addSource(input); pb.add(x); pb.add(y); pb.add(w); pb.add(h); //crop the area into new image PlanarImage output = JAI.create("crop",pb,null); pb = new ParameterBlock(); pb.addSource(output); //offset back the image coordinate pb.add(-x); pb.add(-y); output = JAI.create("translate",pb,null); // save the image JAI.create("filestore",output,"c:\\tost.tif","TIFF"); // show the image JFrame frame = new JFrame(); frame.setTitle("Cropping image "+fn+ " starting at ("+x+","+y+"), size "+w+" x "+h); frame.getContentPane().add(new JScrollPane(new DisplayJAI(output))); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } few questions: 1) the cropping image is shown good on the jframe but when saving the image it get a cropped image but from 0,0 to w,h and not from x,y to w+x,h+y.what is wrong here ?? 2) i still need to change DPi and resize it.... 3) where do i find all the allowable operation for jai.create (like "crop","fileload","translate" etc.) ? [Message sent by forum member 'shukig' (shukig)] http://forums.java.net/jive/thread.jspa?messageID=281243 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: jai.create operationsi just checked the same code with jpeg file type and it was saved good, but i need to work with tiff
here's the replace code JAI.create("filestore",output,"c:\\tost.jpg","JPEG"); [Message sent by forum member 'shukig' (shukig)] http://forums.java.net/jive/thread.jspa?messageID=281274 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: jai.create operations> 1) the cropping image is shown good on the jframe but
> when saving the image it get a cropped image but from > 0,0 to w,h and not from x,y to w+x,h+y.what is wrong > here ?? The TIFF encoder saves the image in the rectangle [x,y,x+w,y+h]. If I am not mistaken the com.sun.media.jai.codec encoders for all formats should do the same. > 2) i still need to change DPi and resize it.... Check the archives. Resizing you have to handle yourself. Saving the DPI is a matter of passing the correct TIFFField object to the encoder. > 3) where do i find all the allowable operation for > jai.create (like "crop","fileload","translate" etc.) ? All operations are defined by OperationDescriptor instances in javax.media.jai.operator. See also this example in the jai-demos project: https://jai-demos.dev.java.net/source/browse/jai-demos/jai-samples/src/OperationRefGuideExample/ I should note that we recommend that you use JAI Image I/O Tools https://jai-imageio.dev.java.net in preference to the codecs in com.sun.media.jai.codec which are used by the Stream/FileLoad/URL/Encode/FileStore operations. JAI Image I/O Tools defines two operations ImageRead/ImageWrite which subsume all the capabilities of the aforementioned JAI operations. Brian [Message sent by forum member 'bpb' (bpb)] http://forums.java.net/jive/thread.jspa?messageID=281407 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
| Free Forum Powered by Nabble | Forum Help |