Mercurial > hg > release > icedtea6-1.2
changeset 742:1cfcbb7b6e2e cacao
2008-03-04 Lillian Angel <langel@redhat.com>
* rt/gnu/*: Removed.
* Makefile.am: Removed icedtea-paths.patch.
* Makefile.in: Regenerated.
* patches/icedtea-paths.patch: Removed.
author | Lillian Angel <langel@redhat.com> |
---|---|
date | Tue, 04 Mar 2008 21:54:12 -0500 |
parents | 6bed63ab5869 |
children | 9b4a8b59ff29 |
files | ChangeLog Makefile.am patches/icedtea-paths.patch rt/gnu/java/awt/BitMaskExtent.java rt/gnu/java/awt/Buffers.java rt/gnu/java/awt/CubicSegment.java rt/gnu/java/awt/LineSegment.java rt/gnu/java/awt/QuadSegment.java rt/gnu/java/awt/Segment.java rt/gnu/java/awt/color/CieXyzConverter.java rt/gnu/java/awt/color/ClutProfileConverter.java rt/gnu/java/awt/color/ColorLookUpTable.java rt/gnu/java/awt/color/ColorSpaceConverter.java rt/gnu/java/awt/color/GrayProfileConverter.java rt/gnu/java/awt/color/GrayScaleConverter.java rt/gnu/java/awt/color/LinearRGBConverter.java rt/gnu/java/awt/color/ProfileHeader.java rt/gnu/java/awt/color/PyccConverter.java rt/gnu/java/awt/color/RgbProfileConverter.java rt/gnu/java/awt/color/SrgbConverter.java rt/gnu/java/awt/color/TagEntry.java rt/gnu/java/awt/color/ToneReproductionCurve.java |
diffstat | 22 files changed, 7 insertions(+), 3965 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Mar 04 16:30:11 2008 -0500 +++ b/ChangeLog Tue Mar 04 21:54:12 2008 -0500 @@ -1,3 +1,10 @@ +2008-03-04 Lillian Angel <langel@redhat.com> + + * rt/gnu/*: Removed. + * Makefile.am: Removed icedtea-paths.patch. + * Makefile.in: Regenerated. + * patches/icedtea-paths.patch: Removed. + 2008-03-04 Lillian Angel <langel@redhat.com> * rt/com/sun/image/codec/jpeg/*: Removed unneeded plugs.
--- a/Makefile.am Tue Mar 04 16:30:11 2008 -0500 +++ b/Makefile.am Tue Mar 04 21:54:12 2008 -0500 @@ -223,7 +223,6 @@ patches/icedtea-version.patch \ patches/icedtea-text-relocations.patch \ patches/icedtea-graphics.patch \ - patches/icedtea-paths.patch \ patches/icedtea-debuginfo.patch \ patches/icedtea-ssl.patch \ patches/icedtea-license-headers.patch \
--- a/patches/icedtea-paths.patch Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,646 +0,0 @@ -diff -urN openjdk.orig/jdk/src/share/classes/java/awt/BasicStroke.java openjdk/jdk/src/share/classes/java/awt/BasicStroke.java ---- openjdk.orig/jdk/src/share/classes/java/awt/BasicStroke.java 2007-10-12 04:02:07.000000000 -0400 -+++ openjdk/jdk/src/share/classes/java/awt/BasicStroke.java 2007-10-16 22:13:51.000000000 -0400 -@@ -1,5 +1,7 @@ - /* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. -+ * Portions Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -+ * see below for license notice. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it -@@ -25,6 +27,17 @@ - - package java.awt; - -+import gnu.java.awt.CubicSegment; -+import gnu.java.awt.LineSegment; -+import gnu.java.awt.QuadSegment; -+import gnu.java.awt.Segment; -+ -+import java.awt.geom.FlatteningPathIterator; -+import java.awt.geom.GeneralPath; -+import java.awt.geom.PathIterator; -+import java.awt.geom.Point2D; -+import java.util.Arrays; -+ - /** - * The <code>BasicStroke</code> class defines a basic set of rendering - * attributes for the outlines of graphics primitives, which are rendered -@@ -156,6 +169,8 @@ - float dash[]; - float dash_phase; - -+ private Segment start, end; -+ - /** - * Constructs a new <code>BasicStroke</code> with the specified - * attributes. -@@ -291,10 +307,12 @@ - * @return the <code>Shape</code> of the stroked outline. - */ - public Shape createStrokedShape(Shape s) { -- sun.java2d.pipe.RenderingEngine re = -- sun.java2d.pipe.RenderingEngine.getInstance(); -- return re.createStrokedShape(s, width, cap, join, miterlimit, -- dash, dash_phase); -+ PathIterator pi = s.getPathIterator(null); -+ -+ if( dash == null ) -+ return solidStroke(pi); -+ -+ return dashedStroke(pi); - } - - /** -@@ -439,4 +456,511 @@ - - return true; - } -+ -+/* -+ * This rest of this file is from GNU Classpath. -+ Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -+ -+ GNU Classpath is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2, or (at your option) -+ any later version. -+ -+ GNU Classpath is distributed in the hope that it will be useful, but -+ WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GNU Classpath; see the file COPYING. If not, write to the -+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -+ 02110-1301 USA. -+ -+ Linking this library statically or dynamically with other modules is -+ making a combined work based on this library. Thus, the terms and -+ conditions of the GNU General Public License cover the whole -+ combination. -+ -+ As a special exception, the copyright holders of this library give you -+ permission to link this library with independent modules to produce an -+ executable, regardless of the license terms of these independent -+ modules, and to copy and distribute the resulting executable under -+ terms of your choice, provided that you also meet, for each linked -+ independent module, the terms and conditions of the license of that -+ module. An independent module is a module which is not derived from -+ or based on this library. If you modify this library, you may extend -+ this exception to your version of the library, but you are not -+ obligated to do so. If you do not wish to do so, delete this -+ exception statement from your version. -+ */ -+ private Shape solidStroke(PathIterator pi) { -+ double[] coords = new double[6]; -+ double x, y, x0, y0; -+ boolean pathOpen = false; -+ GeneralPath output = new GeneralPath (); -+ Segment[] p; -+ x = x0 = y = y0 = 0; -+ -+ while (!pi.isDone()) { -+ switch (pi.currentSegment(coords)) { -+ case PathIterator.SEG_MOVETO: -+ x0 = x = coords[0]; -+ y0 = y = coords[1]; -+ if (pathOpen) { -+ capEnds(); -+ convertPath(output, start); -+ start = end = null; -+ pathOpen = false; -+ } -+ break; -+ -+ case PathIterator.SEG_LINETO: -+ p = (new LineSegment(x, y, coords[0], coords[1])). -+ getDisplacedSegments(width/2.0); -+ if (!pathOpen) { -+ start = p[0]; -+ end = p[1]; -+ pathOpen = true; -+ } else { -+ addSegments(p); -+ } -+ -+ x = coords[0]; -+ y = coords[1]; -+ break; -+ -+ case PathIterator.SEG_QUADTO: -+ p = (new QuadSegment(x, y, coords[0], coords[1], coords[2], -+ coords[3])).getDisplacedSegments(width/2.0); -+ if (!pathOpen) { -+ start = p[0]; -+ end = p[1]; -+ pathOpen = true; -+ } else { -+ addSegments(p); -+ } -+ -+ x = coords[2]; -+ y = coords[3]; -+ break; -+ -+ case PathIterator.SEG_CUBICTO: -+ p = new CubicSegment(x, y, coords[0], coords[1], -+ coords[2], coords[3], -+ coords[4], coords[5]).getDisplacedSegments(width/2.0); -+ if (!pathOpen) { -+ start = p[0]; -+ end = p[1]; -+ pathOpen = true; -+ } else { -+ addSegments(p); -+ } -+ -+ x = coords[4]; -+ y = coords[5]; -+ break; -+ -+ case PathIterator.SEG_CLOSE: -+ if (x == x0 && y == y0) { -+ joinSegments(new Segment[] { start.first, end.first }); -+ } else { -+ p = (new LineSegment(x, y, x0, y0)).getDisplacedSegments(width / 2.0); -+ addSegments(p); -+ } -+ convertPath(output, start); -+ convertPath(output, end); -+ start = end = null; -+ pathOpen = false; -+ output.setWindingRule(GeneralPath.WIND_EVEN_ODD); -+ break; -+ } -+ pi.next(); -+ } -+ -+ if (pathOpen) { -+ capEnds(); -+ convertPath(output, start); -+ } -+ return output; -+ } -+ -+ private Shape dashedStroke(PathIterator pi) -+ { -+ // The choice of (flatnessSq == width / 3) is made to be consistent with -+ // the flattening in CubicSegment.getDisplacedSegments -+ FlatteningPathIterator flat = new FlatteningPathIterator(pi, -+ Math.sqrt(width / 3)); -+ -+ // Holds the endpoint of the current segment (or piece of a segment) -+ double[] coords = new double[2]; -+ -+ // Holds end of the last segment -+ double x, y, x0, y0; -+ x = x0 = y = y0 = 0; -+ -+ // Various useful flags -+ boolean pathOpen = false; -+ boolean dashOn = true; -+ boolean offsetting = (dash_phase != 0); -+ -+ // How far we are into the current dash -+ double distance = 0; -+ int dashIndex = 0; -+ -+ // And variables to hold the final output -+ GeneralPath output = new GeneralPath(); -+ Segment[] p; -+ -+ // Iterate over the FlatteningPathIterator -+ while (! flat.isDone()) { -+ switch (flat.currentSegment(coords)) { -+ case PathIterator.SEG_MOVETO: -+ x0 = x = coords[0]; -+ y0 = y = coords[1]; -+ -+ if (pathOpen) { -+ capEnds(); -+ convertPath(output, start); -+ start = end = null; -+ pathOpen = false; -+ } -+ -+ break; -+ -+ case PathIterator.SEG_LINETO: -+ boolean segmentConsumed = false; -+ -+ while (! segmentConsumed) { -+ // Find the total remaining length of this segment -+ double segLength = Math.sqrt((x - coords[0]) * (x - coords[0]) -+ + (y - coords[1]) -+ * (y - coords[1])); -+ boolean spanBoundary = true; -+ double[] segmentEnd = null; -+ -+ // The current segment fits entirely inside the current dash -+ if ((offsetting && distance + segLength <= dash_phase) -+ || distance + segLength <= dash[dashIndex]) { -+ spanBoundary = false; -+ -+ } else { -+ // Otherwise, we need to split the segment in two, as this -+ // segment spans a dash boundry -+ segmentEnd = (double[]) coords.clone(); -+ -+ // Calculate the remaining distance in this dash, -+ // and coordinates of the dash boundary -+ double reqLength; -+ if (offsetting) -+ reqLength = dash_phase - distance; -+ else -+ reqLength = dash[dashIndex] - distance; -+ -+ coords[0] = x + ((coords[0] - x) * reqLength / segLength); -+ coords[1] = y + ((coords[1] - y) * reqLength / segLength); -+ } -+ -+ if (offsetting || ! dashOn) { -+ // Dash is off, or we are in offset - treat this as a -+ // moveTo -+ x0 = x = coords[0]; -+ y0 = y = coords[1]; -+ -+ if (pathOpen) { -+ capEnds(); -+ convertPath(output, start); -+ start = end = null; -+ pathOpen = false; -+ } -+ } else { -+ // Dash is on - treat this as a lineTo -+ p = (new LineSegment(x, y, coords[0], coords[1])).getDisplacedSegments(width / 2.0); -+ -+ if (! pathOpen) { -+ start = p[0]; -+ end = p[1]; -+ pathOpen = true; -+ } else { -+ addSegments(p); -+ } -+ -+ x = coords[0]; -+ y = coords[1]; -+ } -+ -+ // Update variables depending on whether we spanned a -+ // dash boundary or not -+ if (! spanBoundary) { -+ distance += segLength; -+ segmentConsumed = true; -+ } else { -+ if (offsetting) -+ offsetting = false; -+ dashOn = ! dashOn; -+ distance = 0; -+ coords = segmentEnd; -+ -+ if (dashIndex + 1 == dash.length) -+ dashIndex = 0; -+ else -+ dashIndex++; -+ -+ // Since the value of segmentConsumed is still false, -+ // the next run of the while loop will complete the segment -+ } -+ } -+ break; -+ -+ // This is a flattened path, so we don't need to deal with curves -+ } -+ flat.next(); -+ } -+ -+ if (pathOpen) { -+ capEnds(); -+ convertPath(output, start); -+ } -+ return output; -+ } -+ -+ /** -+ * Cap the ends of the path (joining the start and end list of segments) -+ */ -+ private void capEnds() { -+ Segment returnPath = end.last; -+ -+ end.reverseAll(); // reverse the path. -+ end = null; -+ capEnd(start, returnPath); -+ start.last = returnPath.last; -+ end = null; -+ -+ capEnd(start, start); -+ } -+ -+ /** -+ * Append the Segments in s to the GeneralPath p -+ */ -+ private void convertPath(GeneralPath p, Segment s) { -+ Segment v = s; -+ p.moveTo((float)s.P1.getX(), (float)s.P1.getY()); -+ -+ do { -+ if(v instanceof LineSegment) -+ p.lineTo((float)v.P2.getX(), (float)v.P2.getY()); -+ else if(v instanceof QuadSegment) -+ p.quadTo((float)((QuadSegment)v).cp.getX(), -+ (float)((QuadSegment)v).cp.getY(), -+ (float)v.P2.getX(), -+ (float)v.P2.getY()); -+ else if(v instanceof CubicSegment) -+ p.curveTo((float)((CubicSegment)v).cp1.getX(), -+ (float)((CubicSegment)v).cp1.getY(), -+ (float)((CubicSegment)v).cp2.getX(), -+ (float)((CubicSegment)v).cp2.getY(), -+ (float)v.P2.getX(), -+ (float)v.P2.getY()); -+ v = v.next; -+ } while(v != s && v != null); -+ -+ p.closePath(); -+ } -+ -+ /** -+ * Add the segments to start and end (the inner and outer edges of the stroke) -+ */ -+ private void addSegments(Segment[] segments) { -+ joinSegments(segments); -+ start.add(segments[0]); -+ end.add(segments[1]); -+ } -+ -+ private void joinSegments(Segment[] segments) { -+ double[] p0 = start.last.cp2(); -+ double[] p1 = new double[]{start.last.P2.getX(), start.last.P2.getY()}; -+ double[] p2 = new double[]{segments[0].first.P1.getX(), segments[0].first.P1.getY()}; -+ double[] p3 = segments[0].cp1(); -+ Point2D p; -+ -+ p = lineIntersection(p0[0],p0[1],p1[0],p1[1], -+ p2[0],p2[1],p3[0],p3[1], false); -+ -+ double det = (p1[0] - p0[0])*(p3[1] - p2[1]) - -+ (p3[0] - p2[0])*(p1[1] - p0[1]); -+ -+ if (det > 0) { -+ // start and segment[0] form the 'inner' part of a join, -+ // connect the overlapping segments -+ joinInnerSegments(start, segments[0], p); -+ joinOuterSegments(end, segments[1], p); -+ } else { -+ // end and segment[1] form the 'inner' part -+ joinInnerSegments(end, segments[1], p); -+ joinOuterSegments(start, segments[0], p); -+ } -+ } -+ -+ /** -+ * Make a cap between a and b segments, -+ * where a-->b is the direction of iteration. -+ */ -+ private void capEnd(Segment a, Segment b) { -+ double[] p0, p1; -+ double dx, dy, l; -+ Point2D c1,c2; -+ -+ switch (cap) { -+ case CAP_BUTT: -+ a.add(new LineSegment(a.last.P2, b.P1)); -+ break; -+ -+ case CAP_SQUARE: -+ p0 = a.last.cp2(); -+ p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()}; -+ dx = p1[0] - p0[0]; -+ dy = p1[1] - p0[1]; -+ l = Math.sqrt(dx * dx + dy * dy); -+ dx = 0.5*width*dx/l; -+ dy = 0.5*width*dy/l; -+ c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy); -+ c2 = new Point2D.Double(b.P1.getX() + dx, b.P1.getY() + dy); -+ a.add(new LineSegment(a.last.P2, c1)); -+ a.add(new LineSegment(c1, c2)); -+ a.add(new LineSegment(c2, b.P1)); -+ break; -+ -+ case CAP_ROUND: -+ p0 = a.last.cp2(); -+ p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()}; -+ dx = p1[0] - p0[0]; -+ dy = p1[1] - p0[1]; -+ if (dx != 0 && dy != 0) { -+ l = Math.sqrt(dx * dx + dy * dy); -+ dx = (2.0/3.0)*width*dx/l; -+ dy = (2.0/3.0)*width*dy/l; -+ } -+ -+ c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy); -+ c2 = new Point2D.Double(b.P1.getX() + dx, b.P1.getY() + dy); -+ a.add(new CubicSegment(a.last.P2, c1, c2, b.P1)); -+ break; -+ } -+ a.add(b); -+ } -+ -+ /** -+ * Returns the intersection of two lines, or null if there isn't one. -+ * @param infinite - true if the lines should be regarded as infinite, false -+ * if the intersection must be within the given segments. -+ * @return a Point2D or null. -+ */ -+ private Point2D lineIntersection(double X1, double Y1, -+ double X2, double Y2, -+ double X3, double Y3, -+ double X4, double Y4, -+ boolean infinite) { -+ double x1 = X1; -+ double y1 = Y1; -+ double rx = X2 - x1; -+ double ry = Y2 - y1; -+ -+ double x2 = X3; -+ double y2 = Y3; -+ double sx = X4 - x2; -+ double sy = Y4 - y2; -+ -+ double determinant = sx * ry - sy * rx; -+ double nom = (sx * (y2 - y1) + sy * (x1 - x2)); -+ -+ // lines can be considered parallel. -+ if (Math.abs(determinant) < 1E-6) -+ return null; -+ -+ nom = nom / determinant; -+ -+ // check if lines are within the bounds -+ if(!infinite && (nom > 1.0 || nom < 0.0)) -+ return null; -+ -+ return new Point2D.Double(x1 + nom * rx, y1 + nom * ry); -+ } -+ -+ /** -+ * Join a and b segments, where a-->b is the direction of iteration. -+ * -+ * insideP is the inside intersection point of the join, needed for -+ * calculating miter lengths. -+ */ -+ private void joinOuterSegments(Segment a, Segment b, Point2D insideP) { -+ double[] p0, p1; -+ double dx, dy, l; -+ Point2D c1,c2; -+ -+ switch (join) { -+ case JOIN_MITER: -+ p0 = a.last.cp2(); -+ p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()}; -+ double[] p2 = new double[]{b.P1.getX(), b.P1.getY()}; -+ double[] p3 = b.cp1(); -+ Point2D p = lineIntersection(p0[0],p0[1],p1[0],p1[1],p2[0],p2[1],p3[0],p3[1], true); -+ if( p == null || insideP == null ) -+ a.add(new LineSegment(a.last.P2, b.P1)); -+ else if((p.distance(insideP)/width) < miterlimit) { -+ a.add(new LineSegment(a.last.P2, p)); -+ a.add(new LineSegment(p, b.P1)); -+ } else { -+ // outside miter limit, do a bevel join. -+ a.add(new LineSegment(a.last.P2, b.P1)); -+ } -+ break; -+ -+ case JOIN_ROUND: -+ p0 = a.last.cp2(); -+ p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()}; -+ dx = p1[0] - p0[0]; -+ dy = p1[1] - p0[1]; -+ l = Math.sqrt(dx * dx + dy * dy); -+ dx = 0.5*width*dx/l; -+ dy = 0.5*width*dy/l; -+ c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy); -+ -+ p0 = new double[]{b.P1.getX(), b.P1.getY()}; -+ p1 = b.cp1(); -+ -+ dx = p0[0] - p1[0]; // backwards direction. -+ dy = p0[1] - p1[1]; -+ l = Math.sqrt(dx * dx + dy * dy); -+ dx = 0.5*width*dx/l; -+ dy = 0.5*width*dy/l; -+ c2 = new Point2D.Double(p0[0] + dx, p0[1] + dy); -+ a.add(new CubicSegment(a.last.P2, c1, c2, b.P1)); -+ break; -+ -+ case JOIN_BEVEL: -+ a.add(new LineSegment(a.last.P2, b.P1)); -+ break; -+ } -+ } -+ -+ /** -+ * Join a and b segments, removing any overlap -+ */ -+ private void joinInnerSegments(Segment a, Segment b, Point2D p) { -+ double[] p0 = a.last.cp2(); -+ double[] p1 = new double[] { a.last.P2.getX(), a.last.P2.getY() }; -+ double[] p2 = new double[] { b.P1.getX(), b.P1.getY() }; -+ double[] p3 = b.cp1(); -+ -+ if (p == null) { -+ // Dodgy. -+ a.add(new LineSegment(a.last.P2, b.P1)); -+ p = new Point2D.Double((b.P1.getX() + a.last.P2.getX()) / 2.0, -+ (b.P1.getY() + a.last.P2.getY()) / 2.0); -+ } else { -+ // This assumes segments a and b are single segments, which is -+ // incorrect - if they are a linked list of segments (ie, passed in -+ // from a flattening operation), this produces strange results!! -+ a.last.P2 = b.P1 = p; -+ } -+ } - } -diff -urN openjdk.orig/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java openjdk/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java ---- openjdk.orig/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java 2007-10-12 04:03:11.000000000 -0400 -+++ openjdk/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java 2007-10-16 22:07:44.000000000 -0400 -@@ -423,6 +423,7 @@ - transy = 0; - } - drawPath(sg2d, p2df, transx, transy); -+/* - } else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) { - ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s); - try { -@@ -431,6 +432,7 @@ - si.dispose(); - } - } else { -+*/ - fill(sg2d, sg2d.stroke.createStrokedShape(s)); - } - } ---- ../oipenjdkb23/openjdk/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java 2007-10-30 04:37:34.000000000 -0400 -+++ openjdk/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java 2007-11-13 13:01:58.000000000 -0500 -@@ -188,7 +188,7 @@ - transX, transY, p2df); - return; - } -- -+/* - if (sg2d.strokeState == sg2d.STROKE_CUSTOM) { - fill(sg2d, sg2d.stroke.createStrokedShape(s)); - return; -@@ -201,6 +201,8 @@ - } finally { - sr.dispose(); - } -+*/ -+ fill(sg2d, sg2d.stroke.createStrokedShape(s)); - } - - /** ---- ../opienjdkb23/openjdk/jdk/src/share/classes/sun/java2d/pipe/SpanShapeRenderer.java 2007-10-30 04:37:35.000000000 -0400 -+++ openjdk/jdk/src/share/classes/sun/java2d/pipe/SpanShapeRenderer.java 2007-11-13 13:02:26.000000000 -0500 -@@ -82,6 +82,7 @@ - } - - public void draw(SunGraphics2D sg, Shape s) { -+/* - if (sg.stroke instanceof BasicStroke) { - ShapeSpanIterator sr = LoopPipe.getStrokeSpans(sg, s); - try { -@@ -89,9 +90,9 @@ - } finally { - sr.dispose(); - } -- } else { -+ } else {*/ - fill(sg, sg.stroke.createStrokedShape(s)); -- } -+// } - } - - public static final int NON_RECTILINEAR_TRANSFORM_MASK = ---- ../opeinjdkb23/openjdk/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java 2007-10-30 04:39:14.000000000 -0400 -+++ openjdk/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java 2007-11-13 13:03:24.000000000 -0500 -@@ -336,6 +336,7 @@ - // Otherwise we will use drawPath() for - // high-quality thin paths. - doPath(sg2d, s, false); -+/* - } else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) { - // REMIND: X11 can handle uniform scaled wide lines - // and dashed lines itself if we set the appropriate -@@ -354,6 +355,7 @@ - } finally { - si.dispose(); - } -+*/ - } else { - fill(sg2d, sg2d.stroke.createStrokedShape(s)); - }
--- a/rt/gnu/java/awt/BitMaskExtent.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* Copyright (C) 2000, 2002 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt; - -/** - * Simple transparent utility class that can be used to perform bit - * mask extent calculations. - */ -public final class BitMaskExtent -{ - /** The number of the least significant bit of the bit mask extent. */ - public byte leastSignificantBit; - - /** The number of bits in the bit mask extent. */ - public byte bitWidth; - - /** - * Set the bit mask. This will calculate and set the leastSignificantBit - * and bitWidth fields. - * - * @see #leastSignificantBit - * @see #bitWidth - */ - public void setMask(long mask) - { - leastSignificantBit = 0; - bitWidth = 0; - if (mask == 0) return; - long shiftMask = mask; - for (; (shiftMask&1) == 0; shiftMask >>>=1) leastSignificantBit++; - for (; (shiftMask&1) != 0; shiftMask >>>=1) bitWidth++; - - if (shiftMask != 0) - throw new IllegalArgumentException("mask must be continuous"); - } - - /** - * Calculate the bit mask based on the values of the - * leastSignificantBit and bitWidth fields. - */ - public long toMask() - { - return ((1<<bitWidth)-1) << leastSignificantBit; - } -}
--- a/rt/gnu/java/awt/Buffers.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,225 +0,0 @@ -/* Buffers.java -- - Copyright (C) 2000, 2002, 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.awt; - -import java.awt.image.DataBuffer; -import java.awt.image.DataBufferByte; -import java.awt.image.DataBufferDouble; -import java.awt.image.DataBufferFloat; -import java.awt.image.DataBufferInt; -import java.awt.image.DataBufferShort; -import java.awt.image.DataBufferUShort; - -/** - * Utility class for creating and accessing data buffers of arbitrary - * data types. - */ -public final class Buffers -{ - /** - * Create a data buffer of a particular type. - * - * @param dataType the desired data type of the buffer. - * @param data an array containing data, or null - * @param size the size of the data buffer bank - */ - public static DataBuffer createBuffer(int dataType, Object data, - int size) - { - if (data == null) return createBuffer(dataType, size, 1); - - return createBufferFromData(dataType, data, size); - } - - - /** - * Create a data buffer of a particular type. - * - * @param dataType the desired data type of the buffer. - * @param size the size of the data buffer bank - */ - public static DataBuffer createBuffer(int dataType, int size) { - return createBuffer(dataType, size, 1); - } - - /** - * Create a data buffer of a particular type. - * - * @param dataType the desired data type of the buffer. - * @param size the size of the data buffer bank - * @param numBanks the number of banks the buffer should have - */ - public static DataBuffer createBuffer(int dataType, int size, int numBanks) - { - switch (dataType) - { - case DataBuffer.TYPE_BYTE: - return new DataBufferByte(size, numBanks); - case DataBuffer.TYPE_SHORT: - return new DataBufferShort(size, numBanks); - case DataBuffer.TYPE_USHORT: - return new DataBufferUShort(size, numBanks); - case DataBuffer.TYPE_INT: - return new DataBufferInt(size, numBanks); - case DataBuffer.TYPE_FLOAT: - return new DataBufferFloat(size, numBanks); - case DataBuffer.TYPE_DOUBLE: - return new DataBufferDouble(size, numBanks); - default: - throw new UnsupportedOperationException(); - } - } - - /** - * Create a data buffer of a particular type. - * - * @param dataType the desired data type of the buffer - * @param data an array containing the data - * @param size the size of the data buffer bank - */ - public static DataBuffer createBufferFromData(int dataType, Object data, - int size) - { - switch (dataType) - { - case DataBuffer.TYPE_BYTE: - return new DataBufferByte((byte[]) data, size); - case DataBuffer.TYPE_SHORT: - return new DataBufferShort((short[]) data, size); - case DataBuffer.TYPE_USHORT: - return new DataBufferUShort((short[]) data, size); - case DataBuffer.TYPE_INT: - return new DataBufferInt((int[]) data, size); - case DataBuffer.TYPE_FLOAT: - return new DataBufferFloat((float[]) data, size); - case DataBuffer.TYPE_DOUBLE: - return new DataBufferDouble((double[]) data, size); - default: - throw new UnsupportedOperationException(); - } - } - - /** - * Return the data array of a data buffer, regardless of the data - * type. - * - * @return an array of primitive values. The actual array type - * depends on the data type of the buffer. - */ - public static Object getData(DataBuffer buffer) - { - return getData(buffer, 0, null, 0, buffer.getSize()); - } - - - /** - * Copy data from array contained in data buffer, much like - * System.arraycopy. Create a suitable destination array if the - * given destination array is null. - */ - public static Object getData(DataBuffer src, int srcOffset, - Object dest, int dstOffset, - int length) - { - Object from; - switch(src.getDataType()) - { - case DataBuffer.TYPE_BYTE: - if (dest == null) dest = new byte[length+dstOffset]; - for(int i = 0; i < length; i++) - ((byte[])dest)[i + dstOffset] = (byte)src.getElem(i + srcOffset); - break; - - case DataBuffer.TYPE_DOUBLE: - if (dest == null) dest = new double[length+dstOffset]; - for(int i = 0; i < length; i++) - ((double[])dest)[i + dstOffset] = src.getElemDouble(i + srcOffset); - break; - - case DataBuffer.TYPE_FLOAT: - if (dest == null) dest = new float[length+dstOffset]; - for(int i = 0; i < length; i++) - ((float[])dest)[i + dstOffset] = src.getElemFloat(i + srcOffset); - break; - - case DataBuffer.TYPE_INT: - if (dest == null) dest = new int[length+dstOffset]; - for(int i = 0; i < length; i++) - ((int[])dest)[i + dstOffset] = src.getElem(i + srcOffset); - break; - - case DataBuffer.TYPE_SHORT: - case DataBuffer.TYPE_USHORT: - if (dest == null) dest = new short[length+dstOffset]; - for(int i = 0; i < length; i++) - ((short[])dest)[i + dstOffset] = (short)src.getElem(i + srcOffset); - break; - - case DataBuffer.TYPE_UNDEFINED: - throw new ClassCastException("Unknown data buffer type"); - } - return dest; - } - - /** - * @param bits the width of a data element measured in bits - * - * @return the smallest data type that can store data elements of - * the given number of bits, without any truncation. - */ - public static int smallestAppropriateTransferType(int bits) - { - if (bits <= 8) - { - return DataBuffer.TYPE_BYTE; - } - else if (bits <= 16) - { - return DataBuffer.TYPE_USHORT; - } - else if (bits <= 32) - { - return DataBuffer.TYPE_INT; - } - else - { - return DataBuffer.TYPE_UNDEFINED; - } - } -}
--- a/rt/gnu/java/awt/CubicSegment.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,184 +0,0 @@ -/* CubicSegment.java -- Cubic segment used for BasicStroke - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.awt; - - -import java.awt.geom.CubicCurve2D; -import java.awt.geom.Point2D; - -/** - * Cubic Bezier curve segment - */ -public class CubicSegment extends Segment -{ - public Point2D cp1; // control points - public Point2D cp2; // control points - - /** - * Constructor - takes coordinates of the starting point, - * first control point, second control point and end point, - * respecively. - */ - public CubicSegment(double x1, double y1, double c1x, double c1y, - double c2x, double c2y, double x2, double y2) - { - super(); - P1 = new Point2D.Double(x1, y1); - P2 = new Point2D.Double(x2, y2); - cp1 = new Point2D.Double(c1x, c1y); - cp2 = new Point2D.Double(c2x, c2y); - } - - public CubicSegment(Point2D p1, Point2D cp1, Point2D cp2, Point2D p2) - { - super(); - P1 = p1; - P2 = p2; - this.cp1 = cp1; - this.cp2 = cp2; - } - - /** - * Clones this segment - */ - public Object clone() - { - CubicSegment segment = null; - - try - { - segment = (CubicSegment) super.clone(); - - segment.P1 = (Point2D) P1.clone(); - segment.P2 = (Point2D) P2.clone(); - segment.cp1 = (Point2D) cp1.clone(); - segment.cp2 = (Point2D) cp2.clone(); - } - catch (CloneNotSupportedException cnse) - { - InternalError ie = new InternalError(); - ie.initCause(cnse); - throw ie; - } - - return segment; - } - - /** - * Get the "top" and "bottom" segments of this segment. First array element is - * p0 + normal, second is p0 - normal. - */ - public Segment[] getDisplacedSegments(double radius) - { - // It is, apparently, impossible to derive a curve parallel to a bezier - // curve (unless it's a straight line), so we have no choice but to - // approximate the displaced segments. Similar to FlattenPathIterator. - - Segment segmentTop = null; - Segment segmentBottom = null; - this.radius = radius; - - CubicCurve2D[] curves = new CubicCurve2D[10]; - curves[0] = new CubicCurve2D.Double(P1.getX(), P1.getY(), cp1.getX(), - cp1.getY(), cp2.getX(), cp2.getY(), - P2.getX(), P2.getY()); - int numCurves = 1; - - // Hard-coded a recursion limit of 10 and flatness of 1... should we make - // this an option somewhere? - while (numCurves > 0) - { - // The curve is flat enough, or we've reached our recursion limit, - // so take the current start/end points and add it as a line segment - // to our final approximated curves - if (curves[numCurves - 1].getFlatnessSq() <= (radius / 3) || numCurves == 10) - { - Segment[] displaced = new LineSegment( - curves[numCurves - 1].getP1(), - curves[numCurves - 1].getP2()).getDisplacedSegments(radius); - if (segmentTop == null) - { - segmentTop = displaced[0]; - segmentBottom = displaced[1]; - } - else - { - segmentTop.add(displaced[0]); - segmentBottom.add(displaced[1]); - } - numCurves--; - } - - // Otherwise, subdivide again and continue - else - { - CubicCurve2D left = new CubicCurve2D.Double(); - CubicCurve2D right = new CubicCurve2D.Double(); - curves[numCurves - 1].subdivide(left, right); - curves[numCurves - 1] = right; - curves[numCurves] = left; - curves[numCurves - 1] = right; - curves[numCurves] = left; - numCurves++; - } - } - - return new Segment[] { segmentTop, segmentBottom }; - } - - public void reverse() - { - Point2D temp = P1; - P1 = P2; - P2 = temp; - temp = cp1; - cp1 = cp2; - cp2 = temp; - } - - public double[] cp1() - { - return new double[]{cp1.getX(), cp1.getY()}; - } - - public double[] cp2() - { - return new double[]{cp2.getX(), cp2.getY()}; - } -} // class CubicSegment
--- a/rt/gnu/java/awt/LineSegment.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* LineSegment.java -- Line segment used for BasicStroke - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.awt; - - -import java.awt.geom.Point2D; - -public class LineSegment extends Segment -{ - public LineSegment(double x1, double y1, double x2, double y2) - { - super(); - P1 = new Point2D.Double(x1, y1); - P2 = new Point2D.Double(x2, y2); - } - - public LineSegment(Point2D p1, Point2D p2) - { - super(); - P1 = (Point2D) p1.clone(); - P2 = (Point2D) p2.clone(); - } - - /** - * Clones this segment - */ - public Object clone() - { - LineSegment segment = null; - - try - { - segment = (LineSegment) super.clone(); - segment.P1 = (Point2D) P1.clone(); - segment.P2 = (Point2D) P2.clone(); - } - catch (CloneNotSupportedException cnse) - { - InternalError ie = new InternalError(); - ie.initCause(cnse); - throw ie; - } - - return segment; - } - - /** - * Get the "top" and "bottom" segments of this segment. - * First array element is p0 + normal, second is p0 - normal. - */ - public Segment[] getDisplacedSegments(double radius) - { - this.radius = radius; - double x0 = P1.getX(); - double y0 = P1.getY(); - double x1 = P2.getX(); - double y1 = P2.getY(); - double[] p = normal(x0, y0, x1, y1); - Segment s1 = (new LineSegment(x0 + p[0], y0 + p[1], - x1 + p[0], y1 + p[1] )); - Segment s2 = (new LineSegment(x0 - p[0], y0 - p[1], - x1 - p[0], y1 - p[1] )); - return new Segment[]{s1, s2}; - } - - public void reverse() - { - Point2D p = P1; - P1 = P2; - P2 = p; - } - - public double[] cp1() - { - return new double[]{P2.getX(), P2.getY()}; - } - - public double[] cp2() - { - return new double[]{P1.getX(), P1.getY()}; - } -} // class LineSegment
--- a/rt/gnu/java/awt/QuadSegment.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,264 +0,0 @@ -/* QuadSegment.java -- QuadCurve segment used for BasicStroke - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.awt; - - -import java.awt.geom.Point2D; -import java.awt.geom.QuadCurve2D; - -/** - * Quadratic Bezier curve segment - * - * Note: Most peers don't support quadratics directly, so it might make - * sense to represent them as cubics internally and just be done with it. - * I think we should be peer-agnostic, however, and stay faithful to the - * input geometry types as far as possible. - */ -public class QuadSegment extends Segment -{ - public Point2D cp; // control point - - /** - * Constructor, takes the coordinates of the start, control, - * and end point, respectively. - */ - public QuadSegment(double x1, double y1, double cx, double cy, double x2, - double y2) - { - super(); - P1 = new Point2D.Double(x1, y1); - P2 = new Point2D.Double(x2, y2); - cp = new Point2D.Double(cx, cy); - } - - public QuadSegment(Point2D p1, Point2D cp, Point2D p2) - { - super(); - P1 = p1; - P2 = p2; - this.cp = cp; - } - - public QuadSegment(QuadCurve2D curve) - { - super(); - P1 = curve.getP1(); - P2 = curve.getP2(); - this.cp = curve.getCtrlPt(); - } - - /** - * Clones this segment - */ - public Object clone() - { - QuadSegment segment = null; - - try - { - segment = (QuadSegment) super.clone(); - - segment.P1 = (Point2D) P1.clone(); - segment.P2 = (Point2D) P2.clone(); - segment.cp = (Point2D) cp.clone(); - } - catch (CloneNotSupportedException cnse) - { - InternalError ie = new InternalError(); - ie.initCause(cnse); - throw ie; - } - - return segment; - } - - /** - * Get the "top" and "bottom" segments of a given segment. - * First array element is p0 + normal, second is p0 - normal. - */ - public Segment[] getDisplacedSegments(double radius) - { - this.radius = radius; - double x0 = P1.getX(); - double y0 = P1.getY(); - double x1 = cp.getX(); - double y1 = cp.getY(); - double x2 = P2.getX(); - double y2 = P2.getY(); - - QuadCurve2D left = new QuadCurve2D.Double(); - QuadCurve2D right = new QuadCurve2D.Double(); - QuadCurve2D orig = new QuadCurve2D.Double(x0, y0, x1, y1, x2, y2); - orig.subdivide(left, right); - - QuadSegment s1 = offsetSubdivided(left, true); - QuadSegment s2 = offsetSubdivided(left, false); - - s1.add( offsetSubdivided(right, true) ); - s2.add( offsetSubdivided(right, false) ); - - return new Segment[]{s1, s2}; - } - - private QuadSegment offsetSubdivided(QuadCurve2D curve, boolean plus) - { - double[] n1 = normal(curve.getX1(), curve.getY1(), - curve.getCtrlX(), curve.getCtrlY()); - double[] n2 = normal(curve.getCtrlX(), curve.getCtrlY(), - curve.getX2(), curve.getY2()); - - Point2D cp; - QuadSegment s; - if(!plus) - { - n1[0] = -n1[0]; - n1[1] = -n1[1]; - n2[0] = -n2[0]; - n2[1] = -n2[1]; - } - - // Handle special cases where the control point is equal to an end point - // or end points are equal (ie, straight lines) - if (curve.getP1().equals(curve.getCtrlPt())) - { - cp = curve.getCtrlPt(); - cp.setLocation(cp.getX() + n2[0], cp.getY() + n2[1]); - n1[0] = n2[0]; - n1[1] = n2[1]; - } - else if (curve.getP2().equals(curve.getCtrlPt())) - { - cp = curve.getCtrlPt(); - cp.setLocation(cp.getX() + n1[0], cp.getY() + n1[1]); - n2[0] = n1[0]; - n2[1] = n1[1]; - } - else if (curve.getP1().equals(curve.getP2())) - { - cp = curve.getCtrlPt(); - - double deltaX = curve.getX1() - curve.getCtrlX(); - double deltaY = curve.getY1() - curve.getCtrlY(); - double length = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)); - double ratio = radius / length; - deltaX *= ratio; - deltaY *= ratio; - - if (plus) - cp.setLocation(cp.getX() + deltaX, cp.getY() + deltaY); - else - cp.setLocation(cp.getX() - deltaX, cp.getY() - deltaY); - } - else if (n1[0] == n2[0] && n1[1] == n2[1]) - { - cp = curve.getCtrlPt(); - cp.setLocation(cp.getX() + n1[0], cp.getY() + n1[1]); - } - else - { - cp = lineIntersection(curve.getX1() + n1[0], - curve.getY1() + n1[1], - curve.getCtrlX() + n1[0], - curve.getCtrlY() + n1[1], - curve.getCtrlX() + n2[0], - curve.getCtrlY() + n2[1], - curve.getX2() + n2[0], - curve.getY2() + n2[1], true); - - if (cp == null) - cp = new Point2D.Double(curve.getCtrlX() + n1[0], - curve.getCtrlY() + n1[1]); - } - - s = new QuadSegment(curve.getX1() + n1[0], curve.getY1() + n1[1], - cp.getX(), cp.getY(), - curve.getX2() + n2[0], curve.getY2() + n2[1]); - - return s; - } - - private Point2D lineIntersection(double X1, double Y1, - double X2, double Y2, - double X3, double Y3, - double X4, double Y4, - boolean infinite) - { - double x1 = X1; - double y1 = Y1; - double rx = X2 - x1; - double ry = Y2 - y1; - - double x2 = X3; - double y2 = Y3; - double sx = X4 - x2; - double sy = Y4 - y2; - - double determinant = sx * ry - sy * rx; - double nom = (sx * (y2 - y1) + sy * (x1 - x2)); - - // lines can be considered parallel. - if (Math.abs(determinant) < 1E-6) - return null; - - nom = nom / determinant; - - // check if lines are within the bounds - if(!infinite && (nom > 1.0 || nom < 0.0)) - return null; - - return new Point2D.Double(x1 + nom * rx, y1 + nom * ry); - } - - public void reverse() - { - Point2D p = P1; - P1 = P2; - P2 = p; - } - - public double[] cp1() - { - return new double[]{cp.getX(), cp.getY()}; - } - - public double[] cp2() - { - return new double[]{cp.getX(), cp.getY()}; - } -}
--- a/rt/gnu/java/awt/Segment.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +0,0 @@ -/* Segment.java -- Abstract segment used for BasicStroke - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.awt; - -import java.awt.geom.Point2D; - -public abstract class Segment implements Cloneable -{ - // Start and end points of THIS segment - public Point2D P1; - public Point2D P2; - - // Segments can be linked together internally as a linked list - public Segment first; - public Segment next; - public Segment last; - - // Half the stroke width - protected double radius; - - /** - * Create a new, empty segment - */ - public Segment() - { - P1 = P2 = null; - first = this; - next = null; - last = this; - } - - /** - * Add a segment to the polygon - * @param newsegment segment to add - */ - public void add(Segment newsegment) - { - newsegment.first = first; - last.next = newsegment; - last = last.next.last; - } - - /** - * Reverses the orientation of the whole polygon - */ - public void reverseAll() - { - reverse(); - first = last; - Segment v = next; - Segment former = this; - next = null; - - while (v != null) - { - v.reverse(); - v.last = this; - Segment oldnext = v.next; - v.next = former; - - former = v; - v = oldnext; // move to the next in list - } - } - - public String toString() - { - return "Segment:"+P1+", "+P2; - } - - /** - * Get the normal vector to the slope of the line. - * @return vector of length radius, normal to the (x0,y0)-(x1,y1) vector) - */ - protected double[] normal(double x0, double y0, double x1, double y1) - { - double dx = (x1 - x0); - double dy = (y1 - y0); - if( dy == 0 ) - { - dy = radius * ((dx > 0)?1:-1); - dx = 0; - } - else if( dx == 0 ) - { - dx = radius * ((dy > 0)?-1:1); - dy = 0; - } - else - { - double N = Math.sqrt(dx * dx + dy * dy); - double odx = dx; - dx = -radius * dy / N; - dy = radius * odx / N; - } - return new double[]{ dx, dy }; - } - - /** - * Reverse the current segment - */ - public abstract void reverse(); - - /** - * Get the "top" and "bottom" segments of a segment. - * First array element is p0 + normal, second is p0 - normal. - */ - public abstract Segment[] getDisplacedSegments(double radius); - - /** - * Returns the coordinates of the first control point, or the start point - * for a line segment. - */ - public abstract double[] cp1(); - - /** - * Returns the coordinates of the second control point, or the end point - * for a line segment. - */ - public abstract double[] cp2(); - -}
--- a/rt/gnu/java/awt/color/CieXyzConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* CieXyzConverter.java -- CieXyz conversion class - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - - -/** - * CieXyzConverter - converts to/from a D50-relative CIE XYZ color space. - * - * The sRGB<->CIE XYZ conversions in SrgbConverter are used. - * - * @author Sven de Marothy - */ -public class CieXyzConverter implements ColorSpaceConverter -{ - public float[] toCIEXYZ(float[] in) - { - float[] out = new float[3]; - System.arraycopy(in, 0, out, 0, 3); - return out; - } - - public float[] fromCIEXYZ(float[] in) - { - float[] out = new float[3]; - System.arraycopy(in, 0, out, 0, 3); - return out; - } - - public float[] toRGB(float[] in) - { - return SrgbConverter.XYZtoRGB(in); - } - - public float[] fromRGB(float[] in) - { - return SrgbConverter.RGBtoXYZ(in); - } -}
--- a/rt/gnu/java/awt/color/ClutProfileConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -/* ClutProfileConverter.java -- Conversion routines for CLUT-Based profiles - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - -import java.awt.color.ICC_Profile; - - -/** - * ClutProfileConverter - conversions through a CLUT-based profile - * - * @author Sven de Marothy - */ -public class ClutProfileConverter implements ColorSpaceConverter -{ - private ColorLookUpTable toPCS; - private ColorLookUpTable fromPCS; - private int nChannels; - - public ClutProfileConverter(ICC_Profile profile) - { - nChannels = profile.getNumComponents(); - - // Sun does not specifiy which rendering intent should be used, - // neither does the ICC v2 spec really. - // Try intent 0 - try - { - toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB0Tag); - } - catch (Exception e) - { - toPCS = null; - } - - try - { - fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA0Tag); - } - catch (Exception e) - { - fromPCS = null; - } - - if (toPCS != null || fromPCS != null) - return; - - // If no intent 0 clut is available, look for a intent 1 clut. - try - { - toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB1Tag); - } - catch (Exception e) - { - toPCS = null; - } - - try - { - fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA1Tag); - } - catch (Exception e) - { - fromPCS = null; - } - - if (toPCS != null || fromPCS != null) - return; - - // Last shot.. intent 2 CLUT. - try - { - toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB2Tag); - } - catch (Exception e) - { - toPCS = null; - } - - try - { - fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA2Tag); - } - catch (Exception e) - { - fromPCS = null; - } - - if (toPCS == null && fromPCS == null) - throw new IllegalArgumentException("No CLUTs in profile!"); - } - - public float[] toCIEXYZ(float[] in) - { - if (toPCS != null) - return toPCS.lookup(in); - else - return new float[3]; - } - - public float[] toRGB(float[] in) - { - return SrgbConverter.XYZtoRGB(toCIEXYZ(in)); - } - - public float[] fromCIEXYZ(float[] in) - { - if (fromPCS != null) - return fromPCS.lookup(in); - else - return new float[nChannels]; - } - - public float[] fromRGB(float[] in) - { - return fromCIEXYZ(SrgbConverter.RGBtoXYZ(in)); - } -}
--- a/rt/gnu/java/awt/color/ColorLookUpTable.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,429 +0,0 @@ -/* ColorLookUpTable.java -- ICC v2 CLUT - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - -import java.awt.color.ColorSpace; -import java.awt.color.ICC_Profile; -import java.nio.ByteBuffer; - - -/** - * ColorLookUpTable handles color lookups through a color lookup table, - * as defined in the ICC specification. - * Both 'mft2' and 'mft1' (8 and 16-bit) type CLUTs are handled. - * - * This will have to be updated later for ICC 4.0.0 - * - * @author Sven de Marothy - */ -public class ColorLookUpTable -{ - /** - * CIE 1931 D50 white point (in Lab coordinates) - */ - private static float[] D50 = { 0.96422f, 1.00f, 0.82521f }; - - /** - * Number of input/output channels - */ - int nIn; - - /** - * Number of input/output channels - */ - int nOut; - int nInTableEntries; // Number of input table entries - int nOutTableEntries; // Number of output table entries - int gridpoints; // Number of gridpoints - int nClut; // This is nOut*(gridpoints**nIn) - double[][] inTable; // 1D input table ([channel][table]) - short[][] outTable; // 1D input table ([channel][table]) - double[] clut; // The color lookup table - float[][] inMatrix; // input matrix (XYZ only) - boolean useMatrix; // Whether to use the matrix or not. - int[] multiplier; - int[] offsets; // Hypercube offsets - boolean inputLab; // Set if the CLUT input CS is Lab - boolean outputLab; // Set if the CLUT output CS is Lab - - /** - * Constructor - * Requires a profile file to get the CLUT from and the tag of the - * CLUT to create. (icSigXToYZTag where X,Y = [A | B], Z = [0,1,2]) - */ - public ColorLookUpTable(ICC_Profile profile, int tag) - { - useMatrix = false; - - switch (tag) - { - case ICC_Profile.icSigAToB0Tag: - case ICC_Profile.icSigAToB1Tag: - case ICC_Profile.icSigAToB2Tag: - if (profile.getColorSpaceType() == ColorSpace.TYPE_XYZ) - useMatrix = true; - inputLab = false; - outputLab = (profile.getPCSType() == ColorSpace.TYPE_Lab); - break; - case ICC_Profile.icSigBToA0Tag: - case ICC_Profile.icSigBToA1Tag: - case ICC_Profile.icSigBToA2Tag: - if (profile.getPCSType() == ColorSpace.TYPE_XYZ) - useMatrix = true; - inputLab = (profile.getPCSType() == ColorSpace.TYPE_Lab); - outputLab = false; - break; - default: - throw new IllegalArgumentException("Not a clut-type tag."); - } - - byte[] data = profile.getData(tag); - if (data == null) - throw new IllegalArgumentException("Unsuitable profile, does not contain a CLUT."); - - // check 'mft' - if (data[0] != 0x6d || data[1] != 0x66 || data[2] != 0x74) - throw new IllegalArgumentException("Unsuitable profile, invalid CLUT data."); - - if (data[3] == 0x32) - readClut16(data); - else if (data[3] == 0x31) - readClut8(data); - else - throw new IllegalArgumentException("Unknown/invalid CLUT type."); - } - - /** - * Loads a 16-bit CLUT into our data structures - */ - private void readClut16(byte[] data) - { - ByteBuffer buf = ByteBuffer.wrap(data); - - nIn = data[8] & (0xFF); - nOut = data[9] & (0xFF); - nInTableEntries = buf.getShort(48); - nOutTableEntries = buf.getShort(50); - gridpoints = data[10] & (0xFF); - - inMatrix = new float[3][3]; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - inMatrix[i][j] = ((float) (buf.getInt(12 + (i * 3 + j) * 4))) / 65536.0f; - - inTable = new double[nIn][nInTableEntries]; - for (int channel = 0; channel < nIn; channel++) - for (int i = 0; i < nInTableEntries; i++) - inTable[channel][i] = (double) ((int) buf.getShort(52 - + (channel * nInTableEntries - + i) * 2) - & (0xFFFF)) / 65536.0; - - nClut = nOut; - multiplier = new int[nIn]; - multiplier[nIn - 1] = nOut; - for (int i = 0; i < nIn; i++) - { - nClut *= gridpoints; - if (i > 0) - multiplier[nIn - i - 1] = multiplier[nIn - i] * gridpoints; - } - - int clutOffset = 52 + nIn * nInTableEntries * 2; - clut = new double[nClut]; - for (int i = 0; i < nClut; i++) - clut[i] = (double) ((int) buf.getShort(clutOffset + i * 2) & (0xFFFF)) / 65536.0; - - outTable = new short[nOut][nOutTableEntries]; - for (int channel = 0; channel < nOut; channel++) - for (int i = 0; i < nOutTableEntries; i++) - outTable[channel][i] = buf.getShort(clutOffset - + (nClut - + channel * nOutTableEntries + i) * 2); - - // calculate the hypercube corner offsets - offsets = new int[(1 << nIn)]; - offsets[0] = 0; - for (int j = 0; j < nIn; j++) - { - int factor = 1 << j; - for (int i = 0; i < factor; i++) - offsets[factor + i] = offsets[i] + multiplier[j]; - } - } - - /** - * Loads a 8-bit CLUT into our data structures. - */ - private void readClut8(byte[] data) - { - ByteBuffer buf = ByteBuffer.wrap(data); - - nIn = (data[8] & (0xFF)); - nOut = (data[9] & (0xFF)); - nInTableEntries = 256; // always 256 - nOutTableEntries = 256; // always 256 - gridpoints = (data[10] & (0xFF)); - - inMatrix = new float[3][3]; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - inMatrix[i][j] = ((float) (buf.getInt(12 + (i * 3 + j) * 4))) / 65536.0f; - - inTable = new double[nIn][nInTableEntries]; - for (int channel = 0; channel < nIn; channel++) - for (int i = 0; i < nInTableEntries; i++) - inTable[channel][i] = (double) ((int) buf.get(48 - + (channel * nInTableEntries - + i)) & (0xFF)) / 255.0; - - nClut = nOut; - multiplier = new int[nIn]; - multiplier[nIn - 1] = nOut; - for (int i = 0; i < nIn; i++) - { - nClut *= gridpoints; - if (i > 0) - multiplier[nIn - i - 1] = multiplier[nIn - i] * gridpoints; - } - - int clutOffset = 48 + nIn * nInTableEntries; - clut = new double[nClut]; - for (int i = 0; i < nClut; i++) - clut[i] = (double) ((int) buf.get(clutOffset + i) & (0xFF)) / 255.0; - - outTable = new short[nOut][nOutTableEntries]; - for (int channel = 0; channel < nOut; channel++) - for (int i = 0; i < nOutTableEntries; i++) - outTable[channel][i] = (short) (buf.get(clutOffset + nClut - + channel * nOutTableEntries - + i) * 257); - - // calculate the hypercube corner offsets - offsets = new int[(1 << nIn)]; - offsets[0] = 0; - for (int j = 0; j < nIn; j++) - { - int factor = 1 << j; - for (int i = 0; i < factor; i++) - offsets[factor + i] = offsets[i] + multiplier[j]; - } - } - - /** - * Performs a lookup through the Color LookUp Table. - * If the CLUT tag type is AtoB the conversion will be from the device - * color space to the PCS, BtoA type goes in the opposite direction. - * - * For convenience, the PCS values for input or output will always be - * CIE XYZ (D50), if the actual PCS is Lab, the values will be converted. - * - * N-dimensional linear interpolation is used. - */ - float[] lookup(float[] in) - { - float[] in2 = new float[in.length]; - if (useMatrix) - { - for (int i = 0; i < 3; i++) - in2[i] = in[0] * inMatrix[i][0] + in[1] * inMatrix[i][1] - + in[2] * inMatrix[i][2]; - } - else if (inputLab) - in2 = XYZtoLab(in); - else - System.arraycopy(in, 0, in2, 0, in.length); - - // input table - for (int i = 0; i < nIn; i++) - { - int index = (int) Math.floor(in2[i] * (double) (nInTableEntries - 1)); // floor in - - // clip values. - if (index >= nInTableEntries - 1) - in2[i] = (float) inTable[i][nInTableEntries - 1]; - else if (index < 0) - in2[i] = (float) inTable[i][0]; - else - { - // linear interpolation - double alpha = in2[i] * ((double) nInTableEntries - 1.0) - index; - in2[i] = (float) (inTable[i][index] * (1 - alpha) - + inTable[i][index + 1] * alpha); - } - } - - // CLUT lookup - double[] output2 = new double[nOut]; - double[] weights = new double[(1 << nIn)]; - double[] clutalpha = new double[nIn]; // interpolation values - int offset = 0; // = gp - for (int i = 0; i < nIn; i++) - { - int index = (int) Math.floor(in2[i] * ((double) gridpoints - 1.0)); - double alpha = in2[i] * ((double) gridpoints - 1.0) - (double) index; - - // clip values. - if (index >= gridpoints - 1) - { - index = gridpoints - 1; - alpha = 1.0; - } - else if (index < 0) - index = 0; - clutalpha[i] = alpha; - offset += index * multiplier[i]; - } - - // Calculate interpolation weights - weights[0] = 1.0; - for (int j = 0; j < nIn; j++) - { - int factor = 1 << j; - for (int i = 0; i < factor; i++) - { - weights[factor + i] = weights[i] * clutalpha[j]; - weights[i] *= (1.0 - clutalpha[j]); - } - } - - for (int i = 0; i < nOut; i++) - output2[i] = weights[0] * clut[offset + i]; - - for (int i = 1; i < (1 << nIn); i++) - { - int offset2 = offset + offsets[i]; - for (int f = 0; f < nOut; f++) - output2[f] += weights[i] * clut[offset2 + f]; - } - - // output table - float[] output = new float[nOut]; - for (int i = 0; i < nOut; i++) - { - int index = (int) Math.floor(output2[i] * ((double) nOutTableEntries - - 1.0)); - - // clip values. - if (index >= nOutTableEntries - 1) - output[i] = outTable[i][nOutTableEntries - 1]; - else if (index < 0) - output[i] = outTable[i][0]; - else - { - // linear interpolation - double a = output2[i] * ((double) nOutTableEntries - 1.0) - - (double) index; - output[i] = (float) ((double) ((int) outTable[i][index] & (0xFFFF)) * (1 - - a) - + (double) ((int) outTable[i][index + 1] & (0xFFFF)) * a) / 65536f; - } - } - - if (outputLab) - return LabtoXYZ(output); - return output; - } - - /** - * Converts CIE Lab coordinates to (D50) XYZ ones. - */ - private float[] LabtoXYZ(float[] in) - { - // Convert from byte-packed format to a - // more convenient one (actual Lab values) - // (See ICC spec for details) - // factor is 100 * 65536 / 65280 - in[0] = (float) (100.392156862745 * in[0]); - in[1] = (in[1] * 256.0f) - 128.0f; - in[2] = (in[2] * 256.0f) - 128.0f; - - float[] out = new float[3]; - - out[1] = (in[0] + 16.0f) / 116.0f; - out[0] = in[1] / 500.0f + out[1]; - out[2] = out[1] - in[2] / 200.0f; - - for (int i = 0; i < 3; i++) - { - double exp = out[i] * out[i] * out[i]; - if (exp <= 0.008856) - out[i] = (out[i] - 16.0f / 116.0f) / 7.787f; - else - out[i] = (float) exp; - out[i] = D50[i] * out[i]; - } - return out; - } - - /** - * Converts CIE XYZ coordinates to Lab ones. - */ - private float[] XYZtoLab(float[] in) - { - float[] temp = new float[3]; - - for (int i = 0; i < 3; i++) - { - temp[i] = in[i] / D50[i]; - - if (temp[i] <= 0.008856f) - temp[i] = (7.7870689f * temp[i]) + (16f / 116.0f); - else - temp[i] = (float) Math.exp((1.0 / 3.0) * Math.log(temp[i])); - } - - float[] out = new float[3]; - out[0] = (116.0f * temp[1]) - 16f; - out[1] = 500.0f * (temp[0] - temp[1]); - out[2] = 200.0f * (temp[1] - temp[2]); - - // Normalize to packed format - out[0] = (float) (out[0] / 100.392156862745); - out[1] = (out[1] + 128f) / 256f; - out[2] = (out[2] + 128f) / 256f; - for (int i = 0; i < 3; i++) - { - if (out[i] < 0f) - out[i] = 0f; - if (out[i] > 1f) - out[i] = 1f; - } - return out; - } -}
--- a/rt/gnu/java/awt/color/ColorSpaceConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* ColorSpaceConverter.java -- an interface for colorspace conversion - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - - -/** - * ColorSpaceConverter - used by java.awt.color.ICC_ColorSpace - * - * Color space conversion can occur in several ways: - * - * -Directly (for the built in spaces sRGB, linear RGB, gray, CIE XYZ and PYCC - * -ICC_ProfileRGB works through TRC curves and a matrix - * -ICC_ProfileGray works through a single TRC - * -Everything else is done through Color lookup tables. - * - * The different conversion methods are implemented through - * an interface. The built-in colorspaces are implemented directly - * with the relevant conversion equations. - * - * In this way, we hopefully will always use the fastest and most - * accurate method available. - * - * @author Sven de Marothy - */ -public interface ColorSpaceConverter -{ - float[] toCIEXYZ(float[] in); - - float[] fromCIEXYZ(float[] in); - - float[] toRGB(float[] in); - - float[] fromRGB(float[] in); -}
--- a/rt/gnu/java/awt/color/GrayProfileConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -/* GrayProfileConverter.java -- Gray profile conversion class - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.awt.color; - -import java.awt.color.ICC_Profile; -import java.awt.color.ICC_ProfileGray; -import java.awt.color.ProfileDataException; - -/** - * GrayProfileConverter - converts Grayscale profiles (ICC_ProfileGray) - * - * This type of profile contains a single tone reproduction curve (TRC). - * Conversion consists of simple TRC lookup. - * - * This implementation is very lazy and does everything applying the TRC and - * utilizing the built-in linear grayscale color space. - * - * @author Sven de Marothy - */ -public class GrayProfileConverter implements ColorSpaceConverter -{ - private GrayScaleConverter gc; - private ToneReproductionCurve trc; - private ColorLookUpTable toPCS; - private ColorLookUpTable fromPCS; - - /** - * Constructs the converter described by an ICC_ProfileGray object - */ - public GrayProfileConverter(ICC_ProfileGray profile) - { - try - { - trc = new ToneReproductionCurve(profile.getGamma()); - } - catch (ProfileDataException e) - { - trc = new ToneReproductionCurve(profile.getTRC()); - } - - // linear grayscale converter - gc = new GrayScaleConverter(); - - // If a CLUT is available, it should be used, and the TRCs ignored. - // Note: A valid profile may only have CLUTs in one direction, and - // TRC:s without useful info, making reverse-transforms impossible. - // In this case the TRC will be used for the reverse-transform with - // unpredictable results. This is in line with the Java specification, - try - { - toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB0Tag); - } - catch (Exception e) - { - toPCS = null; - } - - try - { - fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA0Tag); - } - catch (Exception e) - { - fromPCS = null; - } - } - - public float[] toCIEXYZ(float[] in) - { - if (toPCS != null) - return toPCS.lookup(in); - float[] gray = new float[1]; - gray[0] = trc.lookup(in[0]); - return gc.toCIEXYZ(gray); - } - - public float[] toRGB(float[] in) - { - float[] gray = new float[1]; - gray[0] = trc.lookup(in[0]); - return gc.toRGB(gray); - } - - public float[] fromRGB(float[] in) - { - // get linear grayscale value - float[] gray = gc.fromRGB(in); - gray[0] = trc.reverseLookup(gray[0]); - return gray; - } - - public float[] fromCIEXYZ(float[] in) - { - if (fromPCS != null) - return fromPCS.lookup(in); - - float[] gray = gc.fromCIEXYZ(in); - gray[0] = trc.reverseLookup(gray[0]); - return gray; - } -}
--- a/rt/gnu/java/awt/color/GrayScaleConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* GrayScaleConverter.java -- Linear grayscale conversion class - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - - -/** - * Linear Grayscale converter - * - * @author Sven de Marothy - */ -public class GrayScaleConverter implements ColorSpaceConverter -{ - // intensity factors (ITU Rec. BT.709) - double[] coeff = { 0.2125f, 0.7154f, 0.0721f }; - - /** - * CIE 1931 D50 white point (in Lab coordinates) - */ - private static float[] D50 = { 0.96422f, 1.00f, 0.82521f }; - - public float[] toCIEXYZ(float[] in) - { - float g = in[0]; - if (g < 0) - g = 1 + g; - float[] out = { g * D50[0], g * D50[1], g * D50[2] }; // White spot - return out; - } - - public float[] toRGB(float[] in) - { - float[] out = new float[3]; - if (in[0] <= 0.00304f) - out[0] = in[0] * 12.92f; - else - out[0] = 1.055f * ((float) Math.exp((1 / 2.4) * Math.log(in[0]))) - - 0.055f; - out[1] = out[2] = out[0]; - return out; - } - - public float[] fromCIEXYZ(float[] in) - { - float[] temp = new float[3]; - temp[0] = 3.1338f * in[0] - 1.6171f * in[1] - 0.4907f * in[2]; - temp[1] = -0.9785f * in[0] + 1.9160f * in[1] + 0.0334f * in[2]; - temp[2] = 0.0720f * in[0] - 0.2290f * in[1] + 1.4056f * in[2]; - float[] out = new float[1]; - for (int i = 0; i < 3; i++) - out[0] = (float) (temp[i] * coeff[i]); - return out; - } - - public float[] fromRGB(float[] in) - { - float[] out = new float[1]; - - // Convert non-linear RGB coordinates to linear ones, - // numbers from the w3 spec. - out[0] = 0; - for (int i = 0; i < 3; i++) - { - float n = in[i]; - if (n < 0) - n = 0f; - if (n > 1) - n = 1f; - if (n <= 0.03928f) - out[0] += (float) (coeff[i] * n / 12.92); - else - out[0] += (float) (coeff[i] * Math.exp(2.4 * Math.log((n + 0.055) / 1.055))); - } - return out; - } -}
--- a/rt/gnu/java/awt/color/LinearRGBConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -/* LinearRGBConverter.java -- conversion to a linear RGB color space - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - - -/** - * LinearRGBConverter - conversion routines for a linear sRGB colorspace - * sRGB is a standard for RGB colorspaces, adopted by the w3c. - * - * The specification is available at: - * http://www.w3.org/Graphics/Color/sRGB.html - * - * @author Sven de Marothy - */ -public class LinearRGBConverter implements ColorSpaceConverter -{ - /** - * linear RGB --> sRGB - * Use the inverse gamma curve - */ - public float[] toRGB(float[] in) - { - float[] out = new float[3]; - for (int i = 0; i < 3; i++) - { - float n = in[i]; - if (n < 0) - n = 0f; - if (n > 1) - n = 1f; - if (n <= 0.00304f) - out[i] = in[0] * 12.92f; - else - out[i] = 1.055f * ((float) Math.exp((1 / 2.4) * Math.log(n))) - - 0.055f; - } - return out; - } - - /** - * sRGB --> linear RGB - * Use the gamma curve (gamma=2.4 in sRGB) - */ - public float[] fromRGB(float[] in) - { - float[] out = new float[3]; - - // Convert non-linear RGB coordinates to linear ones, - // numbers from the w3 spec. - for (int i = 0; i < 3; i++) - { - float n = in[i]; - if (n < 0) - n = 0f; - if (n > 1) - n = 1f; - if (n <= 0.03928f) - out[i] = (float) (n / 12.92); - else - out[i] = (float) (Math.exp(2.4 * Math.log((n + 0.055) / 1.055))); - } - return out; - } - - /** - * Linear RGB --> CIE XYZ (D50 relative) - * This is a simple matrix transform, the matrix (relative D65) - * is given in the sRGB spec. This has been combined with a - * linear Bradford transform for the D65-->D50 mapping, resulting - * in a single matrix which does the whole thing. - * - */ - public float[] fromCIEXYZ(float[] in) - { - /* - * Note: The numbers which were used to calculate this only had four - * digits of accuracy. So don't be fooled by the number of digits here. - * If someone has more accurate source, feel free to update this. - */ - float[] out = new float[3]; - out[0] = (float) (3.13383065124221 * in[0] - 1.61711949411313 * in[1] - - 0.49071914111101 * in[2]); - out[1] = (float) (-0.97847026691142 * in[0] + 1.91597856031996 * in[1] - + 0.03340430640699 * in[2]); - out[2] = (float) (0.07203679486279 * in[0] - 0.22903073553113 * in[1] - + 1.40557835776234 * in[2]); - if (out[0] < 0) - out[0] = 0f; - if (out[1] < 0) - out[1] = 0f; - if (out[2] < 0) - out[2] = 0f; - if (out[0] > 1.0f) - out[0] = 1.0f; - if (out[1] > 1.0f) - out[1] = 1.0f; - if (out[2] > 1.0f) - out[2] = 1.0f; - return out; - } - - /** - * Linear RGB --> CIE XYZ (D50 relative) - * Uses the inverse of the above matrix. - */ - public float[] toCIEXYZ(float[] in) - { - float[] out = new float[3]; - out[0] = (float) (0.43606375022190 * in[0] + 0.38514960146481 * in[1] - + 0.14308641888799 * in[2]); - out[1] = (float) (0.22245089403542 * in[0] + 0.71692584775182 * in[1] - + 0.06062451125578 * in[2]); - out[2] = (float) (0.01389851860679 * in[0] + 0.09707969011198 * in[1] - + 0.71399604572506 * in[2]); - return out; - } -}
--- a/rt/gnu/java/awt/color/ProfileHeader.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,398 +0,0 @@ -/* ProfileHeader.java -- Encapsules ICC Profile header data - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - -import java.awt.color.ColorSpace; -import java.awt.color.ICC_Profile; -import java.nio.ByteBuffer; - - -/** - * Header, abstracts and validates the header data. - * - * @author Sven de Marothy - */ -public class ProfileHeader -{ - /** - * Magic identifier (ASCII 'acsp') - */ - private static final int icMagicNumber = 0x61637370; - - /** - * Mapping from ICC Profile signatures to ColorSpace types - */ - private static final int[] csTypeMap = - { - ICC_Profile.icSigXYZData, - ColorSpace.TYPE_XYZ, - ICC_Profile.icSigLabData, - ColorSpace.TYPE_Lab, - ICC_Profile.icSigLuvData, - ColorSpace.TYPE_Luv, - ICC_Profile.icSigYCbCrData, - ColorSpace.TYPE_YCbCr, - ICC_Profile.icSigYxyData, - ColorSpace.TYPE_Yxy, - ICC_Profile.icSigRgbData, - ColorSpace.TYPE_RGB, - ICC_Profile.icSigGrayData, - ColorSpace.TYPE_GRAY, - ICC_Profile.icSigHsvData, - ColorSpace.TYPE_HSV, - ICC_Profile.icSigHlsData, - ColorSpace.TYPE_HLS, - ICC_Profile.icSigCmykData, - ColorSpace.TYPE_CMYK, - ICC_Profile.icSigCmyData, - ColorSpace.TYPE_CMY, - ICC_Profile.icSigSpace2CLR, - ColorSpace.TYPE_2CLR, - ICC_Profile.icSigSpace3CLR, - ColorSpace.TYPE_3CLR, - ICC_Profile.icSigSpace4CLR, - ColorSpace.TYPE_4CLR, - ICC_Profile.icSigSpace5CLR, - ColorSpace.TYPE_5CLR, - ICC_Profile.icSigSpace6CLR, - ColorSpace.TYPE_6CLR, - ICC_Profile.icSigSpace7CLR, - ColorSpace.TYPE_7CLR, - ICC_Profile.icSigSpace8CLR, - ColorSpace.TYPE_8CLR, - ICC_Profile.icSigSpace9CLR, - ColorSpace.TYPE_9CLR, - ICC_Profile.icSigSpaceACLR, - ColorSpace.TYPE_ACLR, - ICC_Profile.icSigSpaceBCLR, - ColorSpace.TYPE_BCLR, - ICC_Profile.icSigSpaceCCLR, - ColorSpace.TYPE_CCLR, - ICC_Profile.icSigSpaceDCLR, - ColorSpace.TYPE_DCLR, - ICC_Profile.icSigSpaceECLR, - ColorSpace.TYPE_ECLR, - ICC_Profile.icSigSpaceFCLR, - ColorSpace.TYPE_FCLR - }; - - /** - * Size of an ICC header (128 bytes) - */ - public static final int HEADERSIZE = 128; - - /** - * Mapping of ICC class signatures to profile class constants - */ - private static final int[] classMap = - { - ICC_Profile.icSigInputClass, - ICC_Profile.CLASS_INPUT, - ICC_Profile.icSigDisplayClass, - ICC_Profile.CLASS_DISPLAY, - ICC_Profile.icSigOutputClass, - ICC_Profile.CLASS_OUTPUT, - ICC_Profile.icSigLinkClass, - ICC_Profile.CLASS_DEVICELINK, - ICC_Profile.icSigColorSpaceClass, - ICC_Profile.CLASS_COLORSPACECONVERSION, - ICC_Profile.icSigAbstractClass, - ICC_Profile.CLASS_ABSTRACT, - ICC_Profile.icSigNamedColorClass, - ICC_Profile.CLASS_NAMEDCOLOR - }; - private int size; - private int cmmId; - - // Major/Minor version, The ICC-1998 spec is major v2 - private int majorVersion; - - // Major/Minor version, The ICC-1998 spec is major v2 - private int minorVersion; - private int profileClass; // profile device class - private int colorSpace; // data color space type - private int profileColorSpace; // profile connection space (PCS) type - private byte[] timestamp; // original creation timestamp - private int platform; // platform signature - private int flags; // flags - private int magic; // magic number. - private int manufacturerSig; // manufacturer sig - private int modelSig; // model sig - private byte[] attributes; // Attributes - private int intent; // rendering intent - private byte[] illuminant; // illuminant info (Coordinates of D50 in the PCS) - private int creatorSig; // Creator sig (same type as manufacturer) - - /** - * Creates a 'default' header for use with our predefined profiles. - * Note the device and profile color spaces are not set. - */ - public ProfileHeader() - { - creatorSig = 0; - intent = 0; - modelSig = manufacturerSig = (int) 0x6E6f6E65; // 'none' - magic = icMagicNumber; - cmmId = 0; - platform = 0; // no preferred platform - timestamp = new byte[8]; - majorVersion = 2; - minorVersion = 0x10; - flags = 0; - - // D50 in XYZ format (encoded) - illuminant = new byte[] - { - (byte) 0x00, (byte) 0x00, (byte) 0xf6, (byte) 0xd6, - (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, - (byte) 0x00, (byte) 0x00, (byte) 0xd3, (byte) 0x2d - }; - attributes = new byte[8]; - profileClass = ICC_Profile.CLASS_DISPLAY; - } - - /** - * Creates a header from profile data. Only the header portion (128 bytes) - * is read, so the array passed need not be the full profile. - */ - public ProfileHeader(byte[] data) - { - ByteBuffer buf = ByteBuffer.wrap(data); - - // Get size (the sign bit shouldn't matter. - // A valid profile can never be +2Gb) - size = buf.getInt(ICC_Profile.icHdrSize); - - // CMM ID - cmmId = buf.getInt(ICC_Profile.icHdrCmmId); - - // Version number - majorVersion = (int) (data[ICC_Profile.icHdrVersion]); - minorVersion = (int) (data[ICC_Profile.icHdrVersion + 1]); - - // Profile/Device class - int classSig = buf.getInt(ICC_Profile.icHdrDeviceClass); - profileClass = -1; - for (int i = 0; i < classMap.length; i += 2) - if (classMap[i] == classSig) - { - profileClass = classMap[i + 1]; - break; - } - - // get the data color space - int csSig = buf.getInt(ICC_Profile.icHdrColorSpace); - colorSpace = -1; - for (int i = 0; i < csTypeMap.length; i += 2) - if (csTypeMap[i] == csSig) - { - colorSpace = csTypeMap[i + 1]; - break; - } - - // get the profile color space (PCS), must be xyz or lab except - // for device-link-class profiles - int pcsSig = buf.getInt(ICC_Profile.icHdrPcs); - profileColorSpace = -1; - if (profileClass != ICC_Profile.CLASS_DEVICELINK) - { - if (pcsSig == ICC_Profile.icSigXYZData) - profileColorSpace = ColorSpace.TYPE_XYZ; - if (pcsSig == ICC_Profile.icSigLabData) - profileColorSpace = ColorSpace.TYPE_Lab; - } - else - { - for (int i = 0; i < csTypeMap.length; i += 2) - if (csTypeMap[i] == pcsSig) - { - profileColorSpace = csTypeMap[i + 1]; - break; - } - } - - // creation timestamp - timestamp = new byte[8]; - System.arraycopy(data, ICC_Profile.icHdrDate, timestamp, 0, 8); - - // magic number - magic = buf.getInt(ICC_Profile.icHdrMagic); - - // platform info - platform = buf.getInt(ICC_Profile.icHdrPlatform); - // get flags - flags = buf.getInt(ICC_Profile.icHdrFlags); - // get manufacturer sign - manufacturerSig = buf.getInt(ICC_Profile.icHdrManufacturer); - // get header model - modelSig = buf.getInt(ICC_Profile.icHdrModel); - // attributes - attributes = new byte[8]; - System.arraycopy(data, ICC_Profile.icHdrAttributes, attributes, 0, 8); - // rendering intent - intent = buf.getInt(ICC_Profile.icHdrRenderingIntent); - // illuminant info - illuminant = new byte[12]; - System.arraycopy(data, ICC_Profile.icHdrIlluminant, illuminant, 0, 12); - // Creator signature - creatorSig = buf.getInt(ICC_Profile.icHdrCreator); - // The rest of the header (Total size: 128 bytes) is unused.. - } - - /** - * Verify that the header is valid - * @param size equals the file size if it is to be verified, -1 otherwise - * @throws IllegalArgumentException if the header is found to be invalid. - */ - public void verifyHeader(int size) throws IllegalArgumentException - { - // verify size - if (size != -1 && this.size != size) - throw new IllegalArgumentException("Invalid profile length:" + size); - - // Check version number - if (majorVersion != 2) - throw new IllegalArgumentException("Wrong major version number:" - + majorVersion); - - // Profile/Device class - if (profileClass == -1) - throw new IllegalArgumentException("Invalid profile/device class"); - - // get the data color space - if (colorSpace == -1) - throw new IllegalArgumentException("Invalid colorspace"); - - // profile color space - if (profileColorSpace == -1) - throw new IllegalArgumentException("Invalid PCS."); - - // check magic number - if (magic != icMagicNumber) - throw new IllegalArgumentException("Invalid magic number!"); - } - - /** - * Creates a header, setting the header file size at the same time. - * @param size the profile file size. - */ - public byte[] getData(int size) - { - byte[] data = new byte[HEADERSIZE]; - ByteBuffer buf = ByteBuffer.wrap(data); - buf.putInt(ICC_Profile.icHdrSize, size); - buf.putInt(ICC_Profile.icHdrCmmId, cmmId); - buf.putShort(ICC_Profile.icHdrVersion, - (short) (majorVersion << 8 | minorVersion)); - for (int i = 1; i < classMap.length; i += 2) - if (profileClass == classMap[i]) - buf.putInt(ICC_Profile.icHdrDeviceClass, classMap[i - 1]); - for (int i = 1; i < csTypeMap.length; i += 2) - if (csTypeMap[i] == colorSpace) - buf.putInt(ICC_Profile.icHdrColorSpace, csTypeMap[i - 1]); - for (int i = 1; i < csTypeMap.length; i += 2) - if (csTypeMap[i] == profileColorSpace) - buf.putInt(ICC_Profile.icHdrPcs, csTypeMap[i - 1]); - - System.arraycopy(timestamp, 0, data, ICC_Profile.icHdrDate, - timestamp.length); - buf.putInt(ICC_Profile.icHdrMagic, icMagicNumber); - buf.putInt(ICC_Profile.icHdrPlatform, platform); - buf.putInt(ICC_Profile.icHdrFlags, flags); - buf.putInt(ICC_Profile.icHdrManufacturer, manufacturerSig); - buf.putInt(ICC_Profile.icHdrModel, modelSig); - System.arraycopy(attributes, 0, data, ICC_Profile.icHdrAttributes, - attributes.length); - buf.putInt(ICC_Profile.icHdrRenderingIntent, intent); - System.arraycopy(illuminant, 0, data, ICC_Profile.icHdrIlluminant, - illuminant.length); - buf.putInt(ICC_Profile.icHdrCreator, creatorSig); - return buf.array(); - } - - public int getSize() - { - return size; - } - - public void setSize(int s) - { - size = s; - } - - public int getMajorVersion() - { - return majorVersion; - } - - public int getMinorVersion() - { - return minorVersion; - } - - public int getProfileClass() - { - return profileClass; - } - - public void setProfileClass(int pc) - { - profileClass = pc; - } - - public int getColorSpace() - { - return colorSpace; - } - - public int getProfileColorSpace() - { - return profileColorSpace; - } - - public void setColorSpace(int cs) - { - colorSpace = cs; - } - - public void setProfileColorSpace(int pcs) - { - profileColorSpace = pcs; - } - -}
--- a/rt/gnu/java/awt/color/PyccConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* PyccConverter.java -- PhotoYCC conversion class - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - - -/** - * PyccConverter - conversion routines for the PhotoYCC colorspace - * - * Also known as PhotoCD YCC, it is an expansion of the conventional - * YCC color space to also include colors with over 100% white. - * - * XXX FIXME: Not yet implemented, implementation pending. - * - * @author Sven de Marothy - */ -public class PyccConverter implements ColorSpaceConverter -{ - public float[] toRGB(float[] in) - { - return null; - } - - public float[] fromRGB(float[] in) - { - return null; - } - - public float[] toCIEXYZ(float[] in) - { - return null; - } - - public float[] fromCIEXYZ(float[] in) - { - return null; - } -}
--- a/rt/gnu/java/awt/color/RgbProfileConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -/* RgbProfileConverter.java -- RGB Profile conversion class - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.awt.color; - -import java.awt.color.ICC_Profile; -import java.awt.color.ICC_ProfileRGB; -import java.awt.color.ProfileDataException; - -/** - * RgbProfileConverter - converts RGB profiles (ICC_ProfileRGB) - * - * This type of profile contains a matrix and three - * tone reproduction curves (TRCs). - * - * Device RGB --> CIE XYZ is done through first multiplying with - * a matrix, then each component is looked-up against it's TRC. - * - * The opposite transform is done using the inverse of the matrix, - * and TRC:s. - * - * @author Sven de Marothy - */ -public class RgbProfileConverter implements ColorSpaceConverter -{ - private float[][] matrix; - private float[][] inv_matrix; - private ToneReproductionCurve rTRC; - private ToneReproductionCurve gTRC; - private ToneReproductionCurve bTRC; - private ColorLookUpTable toPCS; - private ColorLookUpTable fromPCS; - - /** - * CIE 1931 D50 white point (in Lab coordinates) - */ - private static float[] D50 = { 0.96422f, 1.00f, 0.82521f }; - - /** - * Constructs an RgbProfileConverter from a given ICC_ProfileRGB - */ - public RgbProfileConverter(ICC_ProfileRGB profile) - { - toPCS = fromPCS = null; - matrix = profile.getMatrix(); - - // get TRCs - try - { - rTRC = new ToneReproductionCurve(profile.getGamma(ICC_ProfileRGB.REDCOMPONENT)); - } - catch (ProfileDataException e) - { - rTRC = new ToneReproductionCurve(profile.getTRC(ICC_ProfileRGB.REDCOMPONENT)); - } - try - { - gTRC = new ToneReproductionCurve(profile.getGamma(ICC_ProfileRGB.GREENCOMPONENT)); - } - catch (ProfileDataException e) - { - gTRC = new ToneReproductionCurve(profile.getTRC(ICC_ProfileRGB.GREENCOMPONENT)); - } - try - { - bTRC = new ToneReproductionCurve(profile.getGamma(ICC_ProfileRGB.BLUECOMPONENT)); - } - catch (ProfileDataException e) - { - bTRC = new ToneReproductionCurve(profile.getTRC(ICC_ProfileRGB.BLUECOMPONENT)); - } - - // If a CLUT is available, it should be used, and the TRCs ignored. - // Note: A valid profile may only have CLUTs in one direction, and - // TRC:s without useful info, making reverse-transforms impossible. - // In this case the TRC will be used for the reverse-transform with - // unpredictable results. This is in line with the Java specification, - try - { - toPCS = new ColorLookUpTable(profile, ICC_Profile.icSigAToB0Tag); - } - catch (Exception e) - { - toPCS = null; - } - - try - { - fromPCS = new ColorLookUpTable(profile, ICC_Profile.icSigBToA0Tag); - } - catch (Exception e) - { - fromPCS = null; - } - - // Calculate the inverse matrix if no reverse CLUT is available - if(fromPCS == null) - inv_matrix = invertMatrix(matrix); - else - { - // otherwise just set it to an identity matrix - inv_matrix = new float[3][3]; - inv_matrix[0][0] = inv_matrix[1][1] = inv_matrix[2][2] = 1.0f; - } - } - - public float[] toCIEXYZ(float[] in) - { - // CLUT takes precedence - if (toPCS != null) - return toPCS.lookup(in); - - float[] temp = new float[3]; - float[] out = new float[3]; - - // device space --> linear gamma - temp[0] = rTRC.lookup(in[0]); - temp[1] = gTRC.lookup(in[1]); - temp[2] = bTRC.lookup(in[2]); - - // matrix multiplication - out[0] = matrix[0][0] * temp[0] + matrix[0][1] * temp[1] - + matrix[0][2] * temp[2]; - out[1] = matrix[1][0] * temp[0] + matrix[1][1] * temp[1] - + matrix[1][2] * temp[2]; - out[2] = matrix[2][0] * temp[0] + matrix[2][1] * temp[1] - + matrix[2][2] * temp[2]; - - return out; - } - - public float[] toRGB(float[] in) - { - return SrgbConverter.XYZtoRGB(toCIEXYZ(in)); - } - - public float[] fromCIEXYZ(float[] in) - { - if (fromPCS != null) - return fromPCS.lookup(in); - - float[] temp = new float[3]; - float[] out = new float[3]; - - // matrix multiplication - temp[0] = inv_matrix[0][0] * in[0] + inv_matrix[0][1] * in[1] - + inv_matrix[0][2] * in[2]; - temp[1] = inv_matrix[1][0] * in[0] + inv_matrix[1][1] * in[1] - + inv_matrix[1][2] * in[2]; - temp[2] = inv_matrix[2][0] * in[0] + inv_matrix[2][1] * in[1] - + inv_matrix[2][2] * in[2]; - - // device space --> linear gamma - out[0] = rTRC.reverseLookup(temp[0]); - out[1] = gTRC.reverseLookup(temp[1]); - out[2] = bTRC.reverseLookup(temp[2]); - - // FIXME: Sun appears to clip the return values to [0,1] - // I don't believe that is a Good Thing, - // (some colorspaces may allow values outside that range.) - // So we return the actual values here. - return out; - } - - public float[] fromRGB(float[] in) - { - return fromCIEXYZ(SrgbConverter.RGBtoXYZ(in)); - } - - /** - * Inverts a 3x3 matrix, returns the inverse, - * throws an IllegalArgumentException if the matrix is not - * invertible (this shouldn't happen for a valid profile) - */ - private float[][] invertMatrix(float[][] matrix) - { - float[][] out = new float[3][3]; - double determinant = matrix[0][0] * (matrix[1][1] * matrix[2][2] - - matrix[2][1] * matrix[1][2]) - - matrix[0][1] * (matrix[1][0] * matrix[2][2] - - matrix[2][0] * matrix[1][2]) - + matrix[0][2] * (matrix[1][0] * matrix[2][1] - - matrix[2][0] * matrix[1][1]); - - if (determinant == 0.0) - throw new IllegalArgumentException("Can't invert conversion matrix."); - float invdet = (float) (1.0 / determinant); - - out[0][0] = invdet * (matrix[1][1] * matrix[2][2] - - matrix[1][2] * matrix[2][1]); - out[0][1] = invdet * (matrix[0][2] * matrix[2][1] - - matrix[0][1] * matrix[2][2]); - out[0][2] = invdet * (matrix[0][1] * matrix[1][2] - - matrix[0][2] * matrix[1][1]); - out[1][0] = invdet * (matrix[1][2] * matrix[2][0] - - matrix[1][0] * matrix[2][2]); - out[1][1] = invdet * (matrix[0][0] * matrix[2][2] - - matrix[0][2] * matrix[2][0]); - out[1][2] = invdet * (matrix[0][2] * matrix[1][0] - - matrix[0][0] * matrix[1][2]); - out[2][0] = invdet * (matrix[1][0] * matrix[2][1] - - matrix[1][1] * matrix[2][0]); - out[2][1] = invdet * (matrix[0][1] * matrix[2][0] - - matrix[0][0] * matrix[2][1]); - out[2][2] = invdet * (matrix[0][0] * matrix[1][1] - - matrix[0][1] * matrix[1][0]); - return out; - } -}
--- a/rt/gnu/java/awt/color/SrgbConverter.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -/* SrgbConverter.java -- sRGB conversion class - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - - -/** - * SrgbConverter - conversion routines for the sRGB colorspace - * sRGB is a standard for RGB colorspaces, adopted by the w3c. - * - * The specification is available at: - * http://www.w3.org/Graphics/Color/sRGB.html - * - * @author Sven de Marothy - */ -/** - * - * Note the matrix numbers used here are NOT identical to those in the - * w3 spec, as those numbers are CIE XYZ relative a D65 white point. - * The CIE XYZ we use is relative a D50 white point, so therefore a - * linear Bradford transform matrix for D65->D50 mapping has been applied. - * (The ICC documents describe this transform) - * - * Linearized Bradford transform: - * 0.8951 0.2664 -0.1614 - * -0.7502 1.7135 0.0367 - * 0.0389 -0.0685 1.0296 - * - * Inverse: - * 0.9870 -0.1471 0.1600 - * 0.4323 0.5184 0.0493 - * -0.00853 0.0400 0.9685 - */ -public class SrgbConverter implements ColorSpaceConverter -{ - public float[] fromCIEXYZ(float[] in) - { - return XYZtoRGB(in); - } - - public float[] toCIEXYZ(float[] in) - { - return RGBtoXYZ(in); - } - - public float[] toRGB(float[] in) - { - float[] out = new float[3]; - System.arraycopy(in, 0, out, 0, 3); - return out; - } - - public float[] fromRGB(float[] in) - { - float[] out = new float[3]; - System.arraycopy(in, 0, out, 0, 3); - return out; - } - - /** - * CIE XYZ (D50 relative) --> sRGB - * - * Static as it's used by other ColorSpaceConverters to - * convert to sRGB if the color space is defined in XYZ. - */ - public static float[] XYZtoRGB(float[] in) - { - float[] temp = new float[3]; - temp[0] = 3.1338f * in[0] - 1.6171f * in[1] - 0.4907f * in[2]; - temp[1] = -0.9785f * in[0] + 1.9160f * in[1] + 0.0334f * in[2]; - temp[2] = 0.0720f * in[0] - 0.2290f * in[1] + 1.4056f * in[2]; - - float[] out = new float[3]; - for (int i = 0; i < 3; i++) - { - if (temp[i] < 0) - temp[i] = 0.0f; - if (temp[i] > 1) - temp[i] = 1.0f; - if (temp[i] <= 0.00304f) - out[i] = temp[i] * 12.92f; - else - out[i] = 1.055f * ((float) Math.exp((1 / 2.4) * Math.log(temp[i]))) - - 0.055f; - } - return out; - } - - /** - * sRGB --> CIE XYZ (D50 relative) - * - * Static as it's used by other ColorSpaceConverters to - * convert to XYZ if the color space is defined in RGB. - */ - public static float[] RGBtoXYZ(float[] in) - { - float[] temp = new float[3]; - float[] out = new float[3]; - for (int i = 0; i < 3; i++) - if (in[i] <= 0.03928f) - temp[i] = in[i] / 12.92f; - else - temp[i] = (float) Math.exp(2.4 * Math.log((in[i] + 0.055) / 1.055)); - - /* - * Note: The numbers which were used to calculate this only had four - * digits of accuracy. So don't be fooled by the number of digits here. - * If someone has more accurate source, feel free to update this. - */ - out[0] = (float) (0.436063750222 * temp[0] + 0.385149601465 * temp[1] - + 0.143086418888 * temp[2]); - out[1] = (float) (0.222450894035 * temp[0] + 0.71692584775 * temp[1] - + 0.060624511256 * temp[2]); - out[2] = (float) (0.0138985186 * temp[0] + 0.097079690112 * temp[1] - + 0.713996045725 * temp[2]); - return out; - } -}
--- a/rt/gnu/java/awt/color/TagEntry.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -/* TagEntry.java -- A utility class used for storing the tags in ICC_Profile - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - - -/** - * TagEntry - stores a profile tag. - * These are conveniently stored in a hashtable with the tag signature - * as a key. A legal profile can only have one tag with a given sig, - * so we can conveniently ignore collisions. - * - * @author Sven de Marothy - */ -public class TagEntry -{ - // tag table entry size - public static final int entrySize = 12; - private int signature; - private int size; - private int offset; - private byte[] data; - - public TagEntry(int sig, int offset, int size, byte[] data) - { - this.signature = sig; - this.offset = offset; - this.size = size; - // Prevent invalid tag data from exhausting heap memory. See - // <https://bugzilla.redhat.com/show_bug.cgi?id=318621>. - if (size > data.length) - throw new IllegalArgumentException("Invalid tag size."); - this.data = new byte[size]; - System.arraycopy(data, offset, this.data, 0, size); - } - - public TagEntry(int sig, byte[] data) - { - this.signature = sig; - this.size = data.length; - this.data = new byte[size]; - System.arraycopy(data, offset, this.data, 0, size); - } - - public byte[] getData() - { - byte[] d = new byte[size]; - System.arraycopy(this.data, 0, d, 0, size); - return d; - } - - public String hashKey() - { - return tagHashKey(signature); - } - - public String toString() - { - String s = ""; - s = s + (char) ((byte) ((signature >> 24) & 0xFF)); - s = s + (char) ((byte) ((signature >> 16) & 0xFF)); - s = s + (char) ((byte) ((signature >> 8) & 0xFF)); - s = s + (char) ((byte) (signature & 0xFF)); - return s; - } - - public int getSignature() - { - return signature; - } - - public int getSize() - { - return size; - } - - public int getOffset() - { - return offset; - } - - public void setOffset(int offset) - { - this.offset = offset; - } - - public static String tagHashKey(int sig) - { - return "" + sig; - } -}
--- a/rt/gnu/java/awt/color/ToneReproductionCurve.java Tue Mar 04 16:30:11 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,177 +0,0 @@ -/* ToneReproductionCurve.java -- Representation of an ICC 'curv' type TRC - Copyright (C) 2004 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.java.awt.color; - - -/** - * ToneReproductionCurve - TRCs are used to describe RGB - * and Grayscale profiles. The TRC is essentially the gamma - * function of the color space. - * - * For example, Apple RGB has a gamma of 1.8, most monitors are ~2.2, - * sRGB is 2.4 with a small linear part near 0. - * Linear spaces are of course 1.0. - * (The exact function is implemented in SrgbConverter) - * - * The ICC specification allows the TRC to be described as a single - * Gamma value, where the function is thus out = in**gamma. - * Alternatively, the gamma function may be represented by a lookup table - * of values, in which case linear interpolation is used. - * - * @author Sven de Marothy - */ -public class ToneReproductionCurve -{ - private float[] trc; - private float gamma; - private float[] reverseTrc; - - /** - * Constructs a TRC from a gamma values - */ - public ToneReproductionCurve(float gamma) - { - trc = null; - reverseTrc = null; - this.gamma = gamma; - } - - /** - * Constructs a TRC from a set of float values - */ - public ToneReproductionCurve(float[] trcValues) - { - trc = new float[trcValues.length]; - System.arraycopy(trcValues, 0, trc, 0, trcValues.length); - setupReverseTrc(); - } - - /** - * Constructs a TRC from a set of short values normalized to - * the 0-65535 range (as in the ICC profile file). - * (Note the values are treated as unsigned) - */ - public ToneReproductionCurve(short[] trcValues) - { - trc = new float[trcValues.length]; - for (int i = 0; i < trcValues.length; i++) - trc[i] = (float) ((int) trcValues[i] & (0xFFFF)) / 65535.0f; - setupReverseTrc(); - } - - /** - * Performs a TRC lookup - */ - public float lookup(float in) - { - float out; - - if (trc == null) - { - if (in == 0f) - return 0.0f; - return (float) Math.exp(gamma * Math.log(in)); - } - else - { - double alpha = in * (trc.length - 1); - int index = (int) Math.floor(alpha); - alpha = alpha - (double) index; - if (index >= trc.length - 1) - return trc[trc.length - 1]; - if (index <= 0) - return trc[0]; - out = (float) (trc[index] * (1.0 - alpha) + trc[index + 1] * alpha); - } - return out; - } - - /** - * Performs an reverse lookup - */ - public float reverseLookup(float in) - { - float out; - - if (trc == null) - { - if (in == 0f) - return 0.0f; - return (float) Math.exp((1.0 / gamma) * Math.log(in)); - } - else - { - double alpha = in * (reverseTrc.length - 1); - int index = (int) Math.floor(alpha); - alpha = alpha - (double) index; - if (index >= reverseTrc.length - 1) - return reverseTrc[reverseTrc.length - 1]; - if (index <= 0) - return reverseTrc[0]; - out = (float) (reverseTrc[index] * (1.0 - alpha) - + reverseTrc[index + 1] * alpha); - } - return out; - } - - /** - * Calculates a reverse-lookup table. - * We use a whopping 10,000 entries.. This is should be more than any - * real-life TRC table (typically around 256-1024) so we won't be losing - * any precision. - * - * This will of course generate completely invalid results if the curve - * is not monotonic and invertable. But what's the alternative? - */ - public void setupReverseTrc() - { - reverseTrc = new float[10000]; - int j = 0; - for (int i = 0; i < 10000; i++) - { - float n = ((float) i) / 10000f; - while (trc[j + 1] < n && j < trc.length - 2) - j++; - - if (j == trc.length - 2) - reverseTrc[i] = trc[trc.length - 1]; - else - reverseTrc[i] = (j + (n - trc[j]) / (trc[j + 1] - trc[j])) / ((float) trc.length); - } - } -}