Solved

Help using JAI 1.1 for image creation (JAI beginner)

Posted on 2001-09-11
4
278 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to add new optional parameter to JSP 1 40
oracle 11g 23 73
How to determine if a string is a valid SHA value 7 28
Chrome and Firefox Java 5 23
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

816 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

7 Experts available now in Live!

Get 1:1 Help Now