>>There is an ImageObserver parameter on the drawImage calls, but it can be null.

Jim, that's the first thing I tried when I started this project.  If that's so then 
why doesn't this work...

import java.io.*;
import java.awt.*;
import java.awt.image.*;
import com.sun.image.codec.jpeg.*;

public class JR {
        static final void main(String[] args) {
                Image input_image = 
Toolkit.getDefaultToolkit().createImage("c:\\input_image.jpg");
                Image scaled_image = input_image.getScaledInstance(320, 240, 
Image.SCALE_DEFAULT);
                BufferedImage buff_image = new BufferedImage(320, 240, 
BufferedImage.TYPE_INT_RGB);
                Graphics2D g = buff_image.createGraphics();
                g.drawImage(scaled_image, null, null);
                try {
                        FileOutputStream fos = new 
FileOutputStream("c:\\output_image.jpg");
                        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos);
                        encoder.encode(buff_image);
                        fos.flush();
                        fos.close();
                        }
                catch(Exception e) { System.out.println("Error: " + e); }
        System.out.println("Resize complete.");
                }
        }

Two things happen:  first, the application hangs at the DOS prompt and never completes 
although the final println _does_ happen.  Strange.  Second, the output file that's 
created is sized properly but contains nothing but black pixels.

>>The java.awt.MediaTracker object can help you to make sure that the image is 
>completely loaded before you do the conversion so that the ImageObserver is then 
>essentially irrelevant.

Can you point me to a simple code example for MediaTracker?  I think my problem might 
be that the input image is not initially loaded by the time I'm doing the drawImage() 
so I'm drawing nothing into the Graphics2D object.  Either that or I'm not writing out 
the JPG correctly with all needd JPG params.  Either way the program is still hanging 
at completion so my money's on a file loading/timing issue.

Darren

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to