Actually, I discovered a more elegant way to accomplish what I've been trying to do,
which is open a JPG, resize it, and save it out as a JPG....
--------------------------------
import java.io.*;
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import com.sun.image.codec.jpeg.*;
public class JR {
static final void main(String[] args) {
try {
FileInputStream fis = new
FileInputStream("c:\\input_image.jpg");
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(fis);
BufferedImage buff_image = decoder.decodeAsBufferedImage();
fis.close();
AffineTransformOp op = new
AffineTransformOp(AffineTransform.getScaleInstance(.5, .5), null);
buff_image = op.filter(buff_image, null);
FileOutputStream fos = new
FileOutputStream("c:\\output_image.jpg");
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos);
JPEGEncodeParam param =
encoder.getDefaultJPEGEncodeParam(buff_image);
param.setQuality(1.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(buff_image);
fos.flush();
fos.close();
}
catch(Exception e) { System.out.println("Error: " + e); }
}
}
------------------------------------
but thanks to everyone for their suggestions.
Darren
>>> "James C. Clover" <[EMAIL PROTECTED]> 02/01/00 11:50AM >>>
> g.drawImage(scaled_image, null, null);
Here's your problem. I'm not sure why you're trying to use a null kernel op
(getting all black pixels from a null kernel op actually sounds correct to
me), but try using a different paint method from Graphics:
boolean drawImage(Image img, int x,int y, ImageObserver observer)
Draws as much of the specified image as is currently available. The image is
drawn with its top-left corner at (x, y) in this graphics context's
coordinate space. Transparent pixels in the image do not affect whatever
pixels are already there.
so that your call would be g.drawImage(scaled_image, 0, 0, null)
James
===========================================================================
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".
===========================================================================
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".