Solved

Help using JAI 1.1 for image creation (JAI beginner)

Posted on 2001-09-11
4
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

696 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