Solved

Help using JAI 1.1 for image creation (JAI beginner)

Posted on 2001-09-11
4
276 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
Comment Utility
Your image object may in fact implement RenderedImage.
Check if your Image is actually a BufferedImage.
0
 

Author Comment

by:boomerang061797
Comment Utility
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
Comment Utility
> 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

763 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

6 Experts available now in Live!

Get 1:1 Help Now