Solved

Help using JAI 1.1 for image creation (JAI beginner)

Posted on 2001-09-11
4
277 Views
Last Modified: 2012-05-04
I was wondering if someone could show me a small example of how to create a PNG (or TIFF) image file (on the file system) using Sun's JAI 1.1.API when my starting point is an java.awt.Image object.

From what I can see, to use the JAI.create() method(s), the image object must be an object that implements the RenderedImage interface which isn't the case for my java.awt.Image object.

Thanks
0
Comment
Question by:boomerang061797
  • 2
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 6475483
Your image object may in fact implement RenderedImage.
Check if your Image is actually a BufferedImage.
0
 

Author Comment

by:boomerang061797
ID: 6475977
Yes that actually seems to be the case. My image object is actually a sun.awt.image.OffScreenImage object. This seems to work.

However, I am experiencing some trouble when ending the program. It's as if the process won't quit on it's own when the program is finished and seems to hang.

Could you refer me to any simple examples of using the JAI API? I can't seem to find much information at Sun apart from some online applets. I only need to create a simple image and store it to file. I need no image processing techniques.

0
 
LVL 92

Expert Comment

by:objects
ID: 6476011
> won't quit on it's own when ..

How are u exitting your application?


> refer me to any simple examples

Sorry I haven't actually used it.
0
 

Author Comment

by:boomerang061797
ID: 6476058
My program looks like this. Just a test:

public static void main(String[] args) throws Exception {
  System.out.println("Start");    
  Frame f = new Frame();
  f.addNotify();
  f.setBackground(new Color(224, 224, 224));
  BufferedImage i = (BufferedImage) f.createImage(40, 30);
  Graphics2D g = (Graphics2D) img.getGraphics();
  g.drawLine(0, 0, 40, 30);
  String file = "testpic.png";
  String form = "png";
  RenderedOp op = JAI.create("filestore", i, file, form);
  System.out.println("End");
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now