this example works fine with SCALE_REPLICATE or without PixelGrabber.
Is it known bug?
public static void main(String[] args) throws IOException {
//change to your favorite jpeg image
String s = "Portrait.jpg";
final Image image = Toolkit.getDefaultToolkit().createImage(s);
//ensure image loaded
/*ImageIcon icon = */new ImageIcon(image);
final int width = image.getWidth(null);
final int height = image.getHeight(null);
//****<grab pixels>*****************************
int[] pixels = new int[width * height];
PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height,
pixels, 0, width);
try {
pg.grabPixels();
}
catch (InterruptedException e) {
return;
}
if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
throw new RuntimeException("can't fetch pixels");
}
//***</grab pixels>*****************************
//with SCALE_REPLICATE everithing work fine
final Image img = image.getScaledInstance(w, h,
Image.SCALE_AREA_AVERAGING);
//ensure image loaded
new ImageIcon(img);
JFrame frame = new JFrame();
JPanel panel = new JPanel() {
protected void paintComponent(Graphics g) {
g.drawImage(image, 0, 0, this);
g.drawImage(img, 0, 0, this);
}
public Dimension getPreferredSize() {
return new Dimension(width, height);
}
};
frame.getContentPane().add(new JScrollPane(panel));
frame.pack();
frame.show();
}
===========================================================================
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".