[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] fix to BufferedImage
From: |
graydon hoare |
Subject: |
[patch] fix to BufferedImage |
Date: |
16 Sep 2003 17:59:44 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Hi,
java.awt.image.BufferedImage has a small bug, where it assumes that
its sample model is a ComponentSampleModel when copying blocks of
pixels. This is not always true. The attached patch fixes this
problem.
ok to commit?
-graydon
2003-09-16 Graydon Hoare <address@hidden>
* java/awt/BufferedImage.java (setData): Support non-component
sample models.
(getData): Same.
--- java/awt/image/BufferedImage.java
+++ java/awt/image/BufferedImage.java
@@ -267,9 +267,17 @@
raster.createWritableChild(x, y, w, h, x, y,
null // same bands
);
-
- // Refer to ComponentDataBlitOp for optimized data blitting:
- ComponentDataBlitOp.INSTANCE.filter(src, dest);
+ if (src.getSampleModel () instanceof ComponentSampleModel &&
+ dest.getSampleModel () instanceof ComponentSampleModel)
+ // Refer to ComponentDataBlitOp for optimized data blitting:
+ ComponentDataBlitOp.INSTANCE.filter(src, dest);
+ else
+ {
+ // slower path
+ int samples[] = null;
+ samples = src.getPixels (x, y, w, h, samples);
+ dest.setPixels (x, y, w, h, samples);
+ }
return dest;
}
@@ -540,9 +548,19 @@
raster.createWritableChild(x, y, w, h, x, y,
null // same bands
);
-
- // Refer to ComponentDataBlitOp for optimized data blitting:
- ComponentDataBlitOp.INSTANCE.filter(src, dest);
+
+ if (src.getSampleModel () instanceof ComponentSampleModel &&
+ dest.getSampleModel () instanceof ComponentSampleModel)
+
+ // Refer to ComponentDataBlitOp for optimized data blitting:
+ ComponentDataBlitOp.INSTANCE.filter(src, dest);
+ else
+ {
+ // slower path
+ int samples[] = null;
+ samples = src.getPixels (x, y, w, h, samples);
+ dest.setPixels (x, y, w, h, samples);
+ }
}
public void setRGB(int x, int y, int argb)