You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by de...@apache.org on 2001/05/01 00:01:06 UTC
cvs commit: xml-batik/sources/org/apache/batik/ext/awt/image/rendered AbstractRed.java GaussianBlurRed8Bit.java PadRed.java
deweese 01/04/30 15:01:06
Modified: samples batik70.svg
sources/org/apache/batik/bridge SVGFilterElementBridge.java
sources/org/apache/batik/ext/awt
MultipleGradientPaintContext.java
sources/org/apache/batik/ext/awt/image GraphicsUtil.java
sources/org/apache/batik/ext/awt/image/renderable
FilterColorInterp.java FilterResRable8Bit.java
sources/org/apache/batik/ext/awt/image/rendered
AbstractRed.java GaussianBlurRed8Bit.java
PadRed.java
Log:
1) Fixed bug in SVGFilterElementBridge where it didn't return
the FiterChainRable, this ment that filterRes was ignored.
2) Fixed a bug where the number of tiles was off by one in very
particular cases of tile grid alignment. This fixes a bug
Stephane reported ages ago for Batik70.svg when zoomed and
panning around (it only took me 8hrs to track this one down :).
3) Fixed a few bugs in the fallback implementation of
GraphicsUtil.coerceData reported by Paul Tea.
4) Several other small tweaks and improvements in the filter code
as I was busy taking care of #2.
5) Batik70.svg the top of the 'i' and 'k' shadow are no longer clipped.
Revision Changes Path
1.6 +2 -2 xml-batik/samples/batik70.svg
Index: batik70.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/batik70.svg,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- batik70.svg 2001/01/19 04:20:20 1.5
+++ batik70.svg 2001/04/30 22:00:58 1.6
@@ -14,7 +14,7 @@
<!-- Test description here -->
<!-- -->
<!-- @author vincent.hardy@eng.sun.com -->
-<!-- @version $Id: batik70.svg,v 1.5 2001/01/19 04:20:20 vhardy Exp $ -->
+<!-- @version $Id: batik70.svg,v 1.6 2001/04/30 22:00:58 deweese Exp $ -->
<!-- ========================================================================= -->
<svg id="body" width="450" height="500" viewBox="0 0 450 500">
@@ -64,7 +64,7 @@
L203.22,0h3.459c2.316,0,4.285,0.348,5.906,1.039c1.621,0.693,2.896,2.002,3.824,3.926z"/>
</g>
- <filter id="shadow" filterRes="200" x="-.2" y="0">
+ <filter id="shadow" filterRes="200" x="-.2" y="-.1">
<feGaussianBlur stdDeviation="3 3" />
<feOffset dx="-10" dy="10" />
</filter>
1.9 +2 -2 xml-batik/sources/org/apache/batik/bridge/SVGFilterElementBridge.java
Index: SVGFilterElementBridge.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFilterElementBridge.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SVGFilterElementBridge.java 2001/03/26 12:37:24 1.8
+++ SVGFilterElementBridge.java 2001/04/30 22:00:59 1.9
@@ -34,7 +34,7 @@
* Bridge class for the <filter> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGFilterElementBridge.java,v 1.8 2001/03/26 12:37:24 tkormann Exp $
+ * @version $Id: SVGFilterElementBridge.java,v 1.9 2001/04/30 22:00:59 deweese Exp $
*/
public class SVGFilterElementBridge implements FilterBridge,
SVGConstants,
@@ -90,7 +90,7 @@
return null; // no filter primitives found, disable the filter.
} else {
filterChain.setSource(in);
- return in;
+ return filterChain;
}
}
1.6 +2 -2 xml-batik/sources/org/apache/batik/ext/awt/MultipleGradientPaintContext.java
Index: MultipleGradientPaintContext.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/MultipleGradientPaintContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MultipleGradientPaintContext.java 2001/04/27 19:53:40 1.5
+++ MultipleGradientPaintContext.java 2001/04/30 22:01:00 1.6
@@ -23,7 +23,7 @@
*
* @author Nicholas Talian, Vincent Hardy, Jim Graham, Jerry Evans
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: MultipleGradientPaintContext.java,v 1.5 2001/04/27 19:53:40 deweese Exp $
+ * @version $Id: MultipleGradientPaintContext.java,v 1.6 2001/04/30 22:01:00 deweese Exp $
*
*/
abstract class MultipleGradientPaintContext implements PaintContext {
@@ -660,7 +660,7 @@
//(modulo behavior discards integer component)
position = position - (int)position;
- //position should now be between -1 and 1
+ //position now be between -1 and 1
if (position < 0) {
position = position + 1; //force it to be in the range 0-1
1.15 +25 -12 xml-batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java
Index: GraphicsUtil.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- GraphicsUtil.java 2001/04/27 19:53:43 1.14
+++ GraphicsUtil.java 2001/04/30 22:01:02 1.15
@@ -70,7 +70,7 @@
* implementations.
*
* @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id: GraphicsUtil.java,v 1.14 2001/04/27 19:53:43 deweese Exp $
+ * @version $Id: GraphicsUtil.java,v 1.15 2001/04/30 22:01:02 deweese Exp $
*/
public class GraphicsUtil {
@@ -212,6 +212,7 @@
}
Rectangle gcR = getDestinationBounds(g2d);
+ // System.out.println("ClipRects: " + clipR + " -> " + gcR);
if (gcR != null) {
if (clipR.intersects(gcR) == false)
return; // Nothing to draw...
@@ -998,14 +999,20 @@
else if (is_INT_PACK_Data(wr.getSampleModel(), true))
mult_INT_PACK_Data(wr);
else {
- norm = 1/255;
- for (int y=0; y<wr.getHeight(); y++)
- for (int x=0; x<wr.getWidth(); x++) {
+ norm = 1f/255f;
+ int x0, x1, y0, y1, a, b;
+ float alpha;
+ x0 = wr.getMinX();
+ x1 = x0+wr.getWidth();
+ y0 = wr.getMinY();
+ y1 = y0+wr.getHeight();
+ for (int y=y0; y<y1; y++)
+ for (int x=x0; x<x1; x++) {
pixel = wr.getPixel(x,y,pixel);
- int a = pixel[bands-1];
+ a = pixel[bands-1];
if ((a >= 0) && (a < 255)) {
- float alpha = a*norm;
- for (int b=0; b<bands-1; b++)
+ alpha = a*norm;
+ for (b=0; b<bands-1; b++)
pixel[b] = (int)(pixel[b]*alpha+0.5f);
wr.setPixel(x,y,pixel);
}
@@ -1017,13 +1024,19 @@
else if (is_INT_PACK_Data(wr.getSampleModel(), true))
divide_INT_PACK_Data(wr);
else {
- for (int y=0; y<wr.getHeight(); y++)
- for (int x=0; x<wr.getWidth(); x++) {
+ int x0, x1, y0, y1, a, b;
+ float ialpha;
+ x0 = wr.getMinX();
+ x1 = x0+wr.getWidth();
+ y0 = wr.getMinY();
+ y1 = y0+wr.getHeight();
+ for (int y=y0; y<y1; y++)
+ for (int x=x0; x<x1; x++) {
pixel = wr.getPixel(x,y,pixel);
- int a = pixel[bands-1];
+ a = pixel[bands-1];
if ((a > 0) && (a < 255)) {
- float ialpha = 255/(float)a;
- for (int b=0; b<bands-1; b++)
+ ialpha = 255/(float)a;
+ for (b=0; b<bands-1; b++)
pixel[b] = (int)(pixel[b]*ialpha+0.5f);
wr.setPixel(x,y,pixel);
}
1.2 +2 -2 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterColorInterp.java
Index: FilterColorInterp.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterColorInterp.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilterColorInterp.java 2001/03/29 13:52:32 1.1
+++ FilterColorInterp.java 2001/04/30 22:01:03 1.2
@@ -16,9 +16,9 @@
* operation should take place in.
*
* @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id: FilterColorInterp.java,v 1.1 2001/03/29 13:52:32 deweese Exp $
+ * @version $Id: FilterColorInterp.java,v 1.2 2001/04/30 22:01:03 deweese Exp $
*/
-public interface FilterColorInterp extends Filter{
+public interface FilterColorInterp extends Filter {
/**
* Returns true if this operation is to be performed in
1.4 +3 -1 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterResRable8Bit.java
Index: FilterResRable8Bit.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/FilterResRable8Bit.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FilterResRable8Bit.java 2001/02/23 20:29:29 1.3
+++ FilterResRable8Bit.java 2001/04/30 22:01:03 1.4
@@ -24,7 +24,7 @@
* Interface for implementing filter resolution.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: FilterResRable8Bit.java,v 1.3 2001/02/23 20:29:29 deweese Exp $
+ * @version $Id: FilterResRable8Bit.java,v 1.4 2001/04/30 22:01:03 deweese Exp $
*/
public class FilterResRable8Bit extends AbstractRable
implements FilterResRable{
@@ -115,6 +115,8 @@
// Else, return the source as is.
float filterResolutionX = this.filterResolutionX;
float filterResolutionY = this.filterResolutionY;
+ // System.out.println("FilterResRable: " + filterResolutionX + "x" +
+ // filterResolutionY);
// Find out the renderable area
Rectangle2D imageRect = getBounds2D();
1.7 +11 -21 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/AbstractRed.java
Index: AbstractRed.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/AbstractRed.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractRed.java 2001/03/26 13:57:24 1.6
+++ AbstractRed.java 2001/04/30 22:01:05 1.7
@@ -48,7 +48,7 @@
* the subclass implementation.
*
* @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id: AbstractRed.java,v 1.6 2001/03/26 13:57:24 deweese Exp $
+ * @version $Id: AbstractRed.java,v 1.7 2001/04/30 22:01:05 deweese Exp $
*/
public abstract class AbstractRed implements CachableRed {
@@ -344,30 +344,20 @@
this.tileWidth = sm.getWidth();
this.tileHeight = sm.getHeight();
- int x0, y0, x1, y1;
+ int x1, y1, maxTileX, maxTileY;
- // In the following code I use (x+y-1)/y as an all integer
- // form of Math.ceil(x/(double)y).
-
// This computes and caches important information about the
// structure of the tile grid in general.
+ minTileX = getXTile(bounds.x);
+ minTileY = getYTile(bounds.y);
- x0 = bounds.x-tileGridXOff; // left edge in tile coords;
- if (x0 > 0) minTileX = x0/tileWidth;
- else minTileX = -(((-x0)+tileWidth-1)/tileWidth);
-
- y0 = bounds.y-tileGridYOff; // top edge in tile coords;
- if (y0 > 0) minTileY = y0/tileHeight;
- else minTileY = -(((-y0)+tileHeight-1)/tileHeight);
-
-
- x0 = minTileX*tileWidth+tileGridXOff; // X loc of min tile...
- x1 = bounds.x + bounds.width-1; // Xloc of right edge
- numXTiles = ((x1-x0)+tileWidth-1)/tileWidth;
-
- y0 = minTileY*tileHeight+tileGridYOff; // Y loc of min tile...
- y1 = bounds.y + bounds.height-1; // Yloc of bottom edge
- numYTiles = ((y1-y0)+tileHeight-1)/tileHeight;
+ x1 = bounds.x + bounds.width-1; // Xloc of right edge
+ maxTileX = getXTile(x1);
+ numXTiles = maxTileX-minTileX+1;
+
+ y1 = bounds.y + bounds.height-1; // Yloc of right edge
+ maxTileY = getYTile(y1);
+ numYTiles = maxTileY-minTileY+1;
}
1.2 +7 -7 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/GaussianBlurRed8Bit.java
Index: GaussianBlurRed8Bit.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/GaussianBlurRed8Bit.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GaussianBlurRed8Bit.java 2001/02/15 14:03:05 1.1
+++ GaussianBlurRed8Bit.java 2001/04/30 22:01:05 1.2
@@ -34,7 +34,7 @@
* GraphicsNode on demand for tiles.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: GaussianBlurRed8Bit.java,v 1.1 2001/02/15 14:03:05 deweese Exp $
+ * @version $Id: GaussianBlurRed8Bit.java,v 1.2 2001/04/30 22:01:05 deweese Exp $
*/
public class GaussianBlurRed8Bit extends AbstractRed {
@@ -165,11 +165,10 @@
//compute d
int diam = (int)Math.floor(DSQRT2PI*stdDev+0.5f);
- int r = diam/2;
if (diam%2 == 0)
- return 3*r-1; // even case
+ return diam-1 + diam/2; // even case
else
- return 3*r; // Odd case
+ return diam-2 + diam/2; // Odd case
}
/*
@@ -251,7 +250,7 @@
tmpR1 = tmpR2;
tmpR2 = tmp;
} else {
- if (dX%2 == 0){
+ if ((dX&0x01) == 0){
tmpR1 = boxFilterH(tmpR1, tmpR1, 0, 0, dX, dX/2);
tmpR1 = boxFilterH(tmpR1, tmpR1, dX/2, 0, dX, dX/2-1);
tmpR1 = boxFilterH(tmpR1, tmpR1, dX-1, 0, dX+1, dX/2);
@@ -271,7 +270,7 @@
}
tmpR2 = convOp[1].filter(tmpR1, tmpR2);
} else {
- if (dY%2 == 0){
+ if ((dY&0x01) == 0){
tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, 0, dY, dY/2);
tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, dY/2, dY, dY/2-1);
tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, dY-1, dY+1, dY/2);
@@ -286,7 +285,8 @@
// System.out.println("Rasters WR :" + wr.getBounds());
// System.out.println(" tmp:" + tmpR2.getBounds());
// System.out.println(" bounds:" + getBounds());
- // System.out.println(" dx:" + dX + " Dy: " + dY);
+ // System.out.println(" skipX:" + skipX +
+ // " dx:" + dX + " Dy: " + dY);
tmpR2 = tmpR2.createWritableTranslatedChild(r.x, r.y);
GraphicsUtil.copyData(tmpR2, wr);
1.8 +19 -11 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/PadRed.java
Index: PadRed.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/PadRed.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PadRed.java 2001/03/26 21:27:35 1.7
+++ PadRed.java 2001/04/30 22:01:05 1.8
@@ -32,7 +32,7 @@
* This is an implementation of a Pad operation as a RenderedImage.
*
* @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id: PadRed.java,v 1.7 2001/03/26 21:27:35 deweese Exp $ */
+ * @version $Id: PadRed.java,v 1.8 2001/04/30 22:01:05 deweese Exp $ */
public class PadRed extends AbstractRed {
static final boolean DEBUG=false;
@@ -125,6 +125,8 @@
final int base;
final int scanStride;
final int pixels[];
+ final int zeros[];
+ final int x0, y0;
public ZeroRecter_INT_PACK(WritableRaster wr) {
super(wr);
@@ -134,32 +136,38 @@
scanStride = sppsm.getScanlineStride();
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
+ x0 = wr.getMinY();
+ y0 = wr.getMinX();
base = (db.getOffset() +
- sppsm.getOffset(0-wr.getSampleModelTranslateX(),
- 0-wr.getSampleModelTranslateY()));
+ sppsm.getOffset(x0-wr.getSampleModelTranslateX(),
+ y0-wr.getSampleModelTranslateY()));
pixels = db.getBankData()[0];
+ if (wr.getWidth() > 10)
+ zeros = new int[wr.getWidth()];
+ else
+ zeros = null;
}
public void zeroRect(Rectangle r) {
- final int rbase = base+r.x + r.y*scanStride;
+ final int rbase = base+(r.x-x0) + (r.y-y0)*scanStride;
- if ((r.width > 10) && (r.height>5)) {
+ if (r.width > 10) {
// Longer runs use arraycopy...
- int [] zeros = new int[r.width];
-
- // Access the pixel data array
for (int y=0; y<r.height; y++) {
int sp = rbase + y*scanStride;
- System.arraycopy(zeros, 0, pixels, sp, zeros.length);
+ System.arraycopy(zeros, 0, pixels, sp, r.width);
}
} else {
// Small runs quicker to avoid func call.
+ int sp = rbase;
+ int end = sp +r.width;
+ int adj = scanStride-r.width;
for (int y=0; y<r.height; y++) {
- int sp = rbase + y*scanStride;
- final int end = sp + r.width;
while (sp < end)
pixels[sp++] = 0;
+ sp += adj;
+ end += scanStride;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org