Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help using JAI 1.1 for image creation (JAI beginner)

Posted on 2001-09-11
4
Medium Priority
?
288 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

963 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