There was a mistake in CairoGraphics2D texture painting, which made the
Metal patterns look strange. This is fixed by the attached patch.
2006-07-24 Roman Kennke <[EMAIL PROTECTED]>
* gnu/java/awt/peer/gtk/CairoGraphics2D.java
(setPaint): Fixed scaleX and scaleY.
/Roman
Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.30
diff -u -1 -2 -r1.30 CairoGraphics2D.java
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java 12 Jul 2006 20:28:43 -0000 1.30
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java 24 Jul 2006 10:57:37 -0000
@@ -674,26 +674,26 @@
{
setColor((Color) paint);
}
else if (paint instanceof TexturePaint)
{
TexturePaint tp = (TexturePaint) paint;
BufferedImage img = tp.getImage();
// map the image to the anchor rectangle
int width = (int) tp.getAnchorRect().getWidth();
int height = (int) tp.getAnchorRect().getHeight();
- double scaleX = (width+1) / (double) img.getWidth();
- double scaleY = (height+1) / (double) img.getHeight();
+ double scaleX = (width) / (double) img.getWidth();
+ double scaleY = (height) / (double) img.getHeight();
AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0);
AffineTransformOp op = new AffineTransformOp(at, getRenderingHints());
BufferedImage texture = op.filter(img, null);
int[] pixels = texture.getRGB(0, 0, width, height, null, 0, width);
setTexturePixels(nativePointer, pixels, width, height, width);
}
else if (paint instanceof GradientPaint)
{
GradientPaint gp = (GradientPaint) paint;
Point2D p1 = gp.getPoint1();
Point2D p2 = gp.getPoint2();
@@ -1229,24 +1229,27 @@
{
return hints;
}
///////////////////////// IMAGE. METHODS ///////////////////////////////////
protected boolean drawImage(Image img, AffineTransform xform,
Color bgcolor, ImageObserver obs)
{
if (img == null)
return false;
+ if (xform == null)
+ xform = new AffineTransform();
+
// In this case, xform is an AffineTransform that transforms bounding
// box of the specified image from image space to user space. However
// when we pass this transform to cairo, cairo will use this transform
// to map "user coordinates" to "pixel" coordinates, which is the
// other way around. Therefore to get the "user -> pixel" transform
// that cairo wants from "image -> user" transform that we currently
// have, we will need to invert the transformation matrix.
AffineTransform invertedXform;
try
{
invertedXform = xform.createInverse();
@@ -1327,25 +1330,27 @@
public void drawRenderableImage(RenderableImage image, AffineTransform xform)
{
drawRenderedImage(image.createRendering(new RenderContext(xform)), xform);
}
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
{
return drawImage(img, xform, null, obs);
}
public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
{
- Image filtered = op.filter(image, null);
+ Image filtered = image;
+ if (op != null)
+ filtered = op.filter(image, null);
drawImage(filtered, new AffineTransform(1f, 0f, 0f, 1f, x, y), null, null);
}
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
{
return drawImage(img, new AffineTransform(1f, 0f, 0f, 1f, x, y), null,
observer);
}
public boolean drawImage(Image img, int x, int y, Color bgcolor,
ImageObserver observer)
{