You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jb...@apache.org on 2006/02/08 10:06:58 UTC
svn commit: r375901 - in /cocoon/branches/BRANCH_2_1_X: ./
src/blocks/imageop/ src/blocks/imageop/conf/ src/blocks/imageop/java/
src/blocks/imageop/java/org/ src/blocks/imageop/java/org/apache/
src/blocks/imageop/java/org/apache/cocoon/ src/blocks/imag...
Author: jbq
Date: Wed Feb 8 01:06:55 2006
New Revision: 375901
URL: http://svn.apache.org/viewcvs?rev=375901&view=rev
Log:
Added contribution from COCOON-1301: Image Operation Reader
Added:
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-category.xlog
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-target.xlog
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xconf (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xmap (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xroles (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xsamples
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/AffineTransformOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ColorOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ConvolveOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/GrayScaleOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOpReader.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/MirrorOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/OffsetOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/RotateOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ScaleOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ShearOperation.java (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/add.jpg (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/dir2page.xsl (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/fix.jpg (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/logo.jpg (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/logo2.png (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/remove.jpg (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/samples.xml (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/sitemap.xmap (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/update.jpg (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/test/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/test/org/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/test/org/apache/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/test/org/apache/cocoon/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/test/org/apache/cocoon/reading/
cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/test/org/apache/cocoon/reading/imageop/
Modified:
cocoon/branches/BRANCH_2_1_X/blocks.properties
cocoon/branches/BRANCH_2_1_X/gump.xml
cocoon/branches/BRANCH_2_1_X/status.xml
Modified: cocoon/branches/BRANCH_2_1_X/blocks.properties
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/blocks.properties?rev=375901&r1=375900&r2=375901&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/blocks.properties (original)
+++ cocoon/branches/BRANCH_2_1_X/blocks.properties Wed Feb 8 01:06:55 2006
@@ -152,13 +152,14 @@
#include.block.cron=false
#include.block.deli=false
#-----[dependency]: "eventcache" depends on "jms".
-#-----[dependency]: "eventcache" is needed by "repository".
+#-----[dependency]: "eventcache" is needed by "repository", "webdav".
#include.block.eventcache=false
#-----[dependency]: "faces" depends on "portal", "taglib".
#include.block.faces=false
#-----[dependency]: "forms" depends on "ajax".
#-----[dependency]: "forms" is needed by "apples", "javaflow", "ojb", "petstore", "portal", "querybean", "tour".
#include.block.forms=false
+#include.block.imageop=false
#-----[dependency]: "javaflow" depends on "forms", "ojb".
#include.block.javaflow=false
#include.block.jcr=false
@@ -188,6 +189,6 @@
#-----[dependency]: "tour" depends on "batik", "fop", "forms", "slop".
#include.block.tour=false
#include.block.validation=false
-#-----[dependency]: "webdav" depends on "repository", "eventcache".
+#-----[dependency]: "webdav" depends on "eventcache", "repository".
#include.block.webdav=false
#include.block.xsltal=false
Modified: cocoon/branches/BRANCH_2_1_X/gump.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/gump.xml?rev=375901&r1=375900&r2=375901&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/gump.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/gump.xml Wed Feb 8 01:06:55 2006
@@ -1663,6 +1663,27 @@
<nag from="Gump <general@gump.apache.org>" to="dev@cocoon.apache.org"/>
</project>
+
+ <project name="cocoon-block-imageop" status="unstable" dir="src/blocks/imageop">
+ <package>org.apache.cocoon</package>
+
+ <description>ImageOp - Image Operation Reader</description>
+
+ <ant target="gump-block">
+ <property name="block-name" value="imageop"/>
+ <property name="version" value="@@DATE@@"/>
+ </ant>
+
+ <depend project="cocoon" inherit="all"/>
+
+ <work nested="build/cocoon-@@DATE@@/blocks/forms/imageop"/>
+ <work nested="tools/anttasks"/>
+ <home nested="build/cocoon-@@DATE@@"/>
+
+ <jar name="blocks/imageop-block.jar"/>
+
+ <nag from="Gump <general@gump.apache.org>" to="dev@cocoon.apache.org"/>
+ </project>
<!--
********************************************
******** COCOON SUPPLIED PROJECTS ********
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-category.xlog
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-category.xlog?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-category.xlog (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-category.xlog Wed Feb 8 01:06:55 2006
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xlog xpath="/logkit/categories"
+ unless="category[@name='imageop']">
+
+ <category log-level="INFO" name="imageop">
+ <log-target id-ref="imageop" />
+ <log-target id-ref="error"/>
+ </category>
+
+</xlog>
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-target.xlog
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-target.xlog?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-target.xlog (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop-target.xlog Wed Feb 8 01:06:55 2006
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xlog xpath="/logkit/targets" unless="cocoon[@id='imageop']">
+ <!-- The logger for the imageop components -->
+ <cocoon id="imageop">
+ <filename>${context-root}/WEB-INF/logs/imageop.log</filename>
+ <format type="cocoon">
+ %7.7{priority} %{time} [%{category}] %{thread}/%{class:short}: %{message}\n%{throwable}
+ </format>
+ <append>true</append>
+ </cocoon>
+</xlog>
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xconf
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xconf?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xconf (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xconf Wed Feb 8 01:06:55 2006
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xconf xpath="/cocoon" unless="image-operations">
+
+ <!-- =============== Image Operations ==================== -->
+ <image-operations>
+ <component-instance name="scale" class="org.apache.cocoon.reading.imageop.ScaleOperation" logger="imageop" />
+ <component-instance name="resize" class="org.apache.cocoon.reading.imageop.ResizeOperation" logger="imageop" />
+ <component-instance name="rotate" class="org.apache.cocoon.reading.imageop.RotateOperation" logger="imageop" />
+ <component-instance name="offset" class="org.apache.cocoon.reading.imageop.OffsetOperation" logger="imageop" />
+ <component-instance name="mirror" class="org.apache.cocoon.reading.imageop.MirrorOperation" logger="imageop" />
+ <component-instance name="affine" class="org.apache.cocoon.reading.imageop.AffineTransformOperation" logger="imageop" />
+ <component-instance name="grayscale" class="org.apache.cocoon.reading.imageop.GrayScaleOperation" logger="imageop" />
+ <component-instance name="convolve" class="org.apache.cocoon.reading.imageop.ConvolveOperation" logger="imageop" />
+ <component-instance name="color" class="org.apache.cocoon.reading.imageop.ColorOperation" logger="imageop" />
+ <component-instance name="shear" class="org.apache.cocoon.reading.imageop.ShearOperation" logger="imageop" />
+ </image-operations>
+
+</xconf>
+
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xconf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xconf
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xmap?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xmap (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xmap Wed Feb 8 01:06:55 2006
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<xmap xpath="/sitemap/components/readers" unless="reader[@name='image-op-scale']">
+
+ <map:reader logger="imageop" name="image-op-scale" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="scale" prefix="scale-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-resize" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="resize" prefix="size-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-rotate" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="rotate" prefix="rotate-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-mirror" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="mirror" prefix="mirror-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-offset" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="offset" prefix="offset-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-affine" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="affine" prefix="affine-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-grayscale" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="grayscale" prefix="grayscale-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-color" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="color" prefix="color-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-complex" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="mirror" prefix="mirror-" />
+ <op type="rotate" prefix="rotate-" />
+ <op type="offset" prefix="offset-" />
+ <op type="shear" prefix="shear-" />
+ <op type="resize" prefix="resize-" />
+ </effects>
+ </map:reader>
+
+ <map:reader logger="imageop" name="image-op-convolve" src="org.apache.cocoon.reading.imageop.ImageOpReader" >
+ <effects>
+ <op type="convolve" prefix="convolve-" />
+ </effects>
+ </map:reader>
+</xmap>
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xmap
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xmap
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xroles
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xroles?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xroles (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xroles Wed Feb 8 01:06:55 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xroles xpath="/role-list" unless="role [@name='org.apache.cocoon.reading.imageop.ImageOperationSelector']">
+ <role name="org.apache.cocoon.reading.imageop.ImageOperationSelector"
+ shorthand="image-operations"
+ default-class="org.apache.cocoon.components.ExtendedComponentSelector"/>
+</xroles>
+
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xroles
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xsamples
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xsamples?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xsamples (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/conf/imageop.xsamples Wed Feb 8 01:06:55 2006
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xsamples xpath="/samples" unless="group[@name='Image Effects']">
+
+ <group name="Image Effects">
+ <sample href="imageop/" name="Image Effects">
+ Image Effects to be applied to images.
+ </sample>
+ </group>
+
+</xsamples>
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/AffineTransformOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/AffineTransformOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/AffineTransformOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/AffineTransformOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,136 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.geom.AffineTransform;
+
+import java.awt.image.AffineTransformOp;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import java.util.StringTokenizer;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+
+public class AffineTransformOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+ private float[] m_Matrix;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ throws ProcessingException
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ int size = params.getParameterAsInteger( m_Prefix + "matrix-size", 6 );
+ String values = params.getParameter( m_Prefix + "values", null );
+
+ if( size != 4 && size != 6 )
+ throw new ProcessingException( "Only matrices of 4 or 6 elements can be used." );
+
+ if( values != null )
+ m_Matrix = getFloatArray( values );
+ else
+ m_Matrix = new float[ size ];
+
+ if( m_Matrix.length != 4 && m_Matrix.length != 6 )
+ throw new ProcessingException( "Only matrices of 4 or 6 elements can be used." );
+
+ float m00 = params.getParameterAsFloat( m_Prefix + "m00", Float.NaN );
+ float m01 = params.getParameterAsFloat( m_Prefix + "m01", Float.NaN );
+ float m02 = params.getParameterAsFloat( m_Prefix + "m02", Float.NaN );
+ float m10 = params.getParameterAsFloat( m_Prefix + "m10", Float.NaN );
+ float m11 = params.getParameterAsFloat( m_Prefix + "m11", Float.NaN );
+ float m12 = params.getParameterAsFloat( m_Prefix + "m12", Float.NaN );
+
+ if( m_Matrix.length == 4 )
+ {
+ m_Matrix[0] = m00;
+ m_Matrix[1] = m01;
+ m_Matrix[2] = m10;
+ m_Matrix[3] = m11;
+ }
+ else
+ {
+ m_Matrix[0] = m00;
+ m_Matrix[1] = m01;
+ m_Matrix[2] = m02;
+ m_Matrix[3] = m10;
+ m_Matrix[4] = m11;
+ m_Matrix[5] = m12;
+ }
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+ AffineTransform transform = new AffineTransform( m_Matrix );
+ AffineTransformOp op = new AffineTransformOp( transform, AffineTransformOp.TYPE_BILINEAR );
+ WritableRaster scaledRaster = op.filter( image, null );
+ return scaledRaster;
+ }
+
+ public String getKey()
+ {
+ return "affine:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + getMatrixAsString()
+ + ":" + m_Prefix;
+ }
+
+ private float[] getFloatArray( String values )
+ {
+ float[] fvalues = new float[ 30 ];
+ int counter = 0;
+ StringTokenizer st = new StringTokenizer( values, ",", false );
+ for( int i = 0 ; st.hasMoreTokens() ; i++ )
+ {
+ String value = st.nextToken().trim();
+ fvalues[ i ] = Float.parseFloat( value );
+ counter = counter + 1;
+ }
+ float[] result = new float[ counter ];
+ for( int i = 0 ; i < counter ; i++ )
+ result[i] = fvalues[i];
+ return result;
+ }
+
+ private String getMatrixAsString()
+ {
+ StringBuffer b = new StringBuffer();
+ for( int i = 0 ; i < m_Matrix.length ; i++ )
+ {
+ if( i != 0 )
+ b.append( "," );
+ b.append( m_Matrix[ i ] );
+ }
+ String result = b.toString();
+ b.setLength( 0 );
+ return result;
+ }
+
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/AffineTransformOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/AffineTransformOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ColorOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ColorOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ColorOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ColorOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.image.Raster;
+import java.awt.image.RasterOp;
+import java.awt.image.RescaleOp;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+public class ColorOperation
+ implements ImageOperation
+{
+ private RescaleOp m_ColorFilter = null;
+ private String m_Prefix;
+ private boolean m_Enabled;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ float[] scaleColor = new float[3];
+ float[] offsetColor = new float[3];
+ scaleColor[0] = params.getParameterAsFloat( m_Prefix + "scale-red", -1.0f);
+ scaleColor[1] = params.getParameterAsFloat( m_Prefix + "scale-green", -1.0f);
+ scaleColor[2] = params.getParameterAsFloat( m_Prefix + "scale-blue", -1.0f);
+ offsetColor[0] = params.getParameterAsFloat( m_Prefix + "offset-red", 0.0f);
+ offsetColor[1] = params.getParameterAsFloat( m_Prefix + "offset-green", 0.0f);
+ offsetColor[2] = params.getParameterAsFloat( m_Prefix + "offset-blue", 0.0f);
+ m_ColorFilter = new RescaleOp( scaleColor, offsetColor, null );
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+
+ WritableRaster r = m_ColorFilter.filter( image, null );
+ return r;
+ }
+
+ public String getKey()
+ {
+ return "colorop:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + m_ColorFilter
+ + ":" + m_Prefix;
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ColorOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ColorOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ConvolveOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ConvolveOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ConvolveOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ConvolveOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.image.ConvolveOp;
+import java.awt.image.Kernel;
+import java.awt.image.Raster;
+import java.awt.image.RasterOp;
+import java.awt.image.WritableRaster;
+
+import java.util.StringTokenizer;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+
+public class ConvolveOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+ private int m_ConvolveHeight;
+ private int m_ConvolveWidth;
+ private float[] m_Data;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ throws ProcessingException
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ m_ConvolveWidth = params.getParameterAsInteger( m_Prefix + "width", 3 );
+ m_ConvolveHeight = params.getParameterAsInteger( m_Prefix + "height", 3 );
+ String values = params.getParameter( m_Prefix + "data", "" );
+ m_Data = getFloatArray( values );
+ if( m_Data.length != m_ConvolveWidth * m_ConvolveHeight )
+ throw new ProcessingException( "The width*height must be equal to the number of data elements given: " + (m_ConvolveWidth * m_ConvolveHeight) + " is not compatible with '" + values + "'" );
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+
+ Kernel kernel = new Kernel( m_ConvolveWidth, m_ConvolveHeight, m_Data );
+ ConvolveOp op = new ConvolveOp( kernel, ConvolveOp.EDGE_NO_OP, null );
+ WritableRaster r = op.filter( image, null );
+ return r;
+ }
+
+ private float[] getFloatArray( String values )
+ {
+ float[] fvalues = new float[ 30 ];
+ int counter = 0;
+ StringTokenizer st = new StringTokenizer( values, ",", false );
+ for( int i = 0 ; st.hasMoreTokens() ; i++ )
+ {
+ String value = st.nextToken().trim();
+ fvalues[ i ] = Float.parseFloat( value );
+ counter = counter + 1;
+ }
+ float[] result = new float[ counter ];
+ for( int i = 0 ; i < counter ; i++ )
+ result[i] = fvalues[i];
+ return result;
+ }
+
+ private String getDataAsString()
+ {
+ StringBuffer b = new StringBuffer();
+ for( int i = 0 ; i < m_Data.length ; i++ )
+ {
+ if( i != 0 )
+ b.append( "," );
+ b.append( m_Data[ i ] );
+ }
+ String result = b.toString();
+ b.setLength( 0 );
+ return result;
+ }
+
+ public String getKey()
+ {
+ return "convolve:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + m_ConvolveWidth
+ + ":" + m_ConvolveHeight
+ + ":" + getDataAsString()
+ + ":" + m_Prefix;
+ }
+}
+
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ConvolveOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ConvolveOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/GrayScaleOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/GrayScaleOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/GrayScaleOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/GrayScaleOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.color.ColorSpace;
+
+import java.awt.image.ColorConvertOp;
+import java.awt.image.Raster;
+import java.awt.image.RasterOp;
+import java.awt.image.RescaleOp;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+public class GrayScaleOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+
+ ColorSpace grayspace = ColorSpace.getInstance( ColorSpace.CS_GRAY );
+ ColorConvertOp op = new ColorConvertOp( grayspace, null );
+ WritableRaster r = op.filter( image, null );
+ return r;
+ }
+
+ public String getKey()
+ {
+ return "grayscale:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + m_Prefix;
+ }
+}
\ No newline at end of file
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/GrayScaleOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/GrayScaleOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOpReader.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOpReader.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOpReader.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOpReader.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,267 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.RasterOp;
+import java.awt.image.WritableRaster;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.spi.ImageWriterSpi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+import org.apache.avalon.framework.component.Composable;
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.component.ComponentSelector;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+
+import org.apache.cocoon.environment.SourceResolver;
+
+import org.apache.cocoon.reading.ResourceReader;
+
+import org.xml.sax.SAXException;
+
+/**
+ * The <code>ImageOpReader</code> component is used to serve binary image data
+ * in a sitemap pipeline. It makes use of HTTP Headers to determine if
+ * the requested resource should be written to the <code>OutputStream</code>
+ * or if it can signal that it hasn't changed.
+ */
+final public class ImageOpReader extends ResourceReader
+ implements Configurable, Composable
+{
+ private final static String FORMAT_DEFAULT = "png";
+
+ private String m_Format;
+ private ArrayList m_EffectsStack;
+ private ComponentSelector m_OperationSelector;
+
+ /**
+ * Read reader configuration
+ */
+ public void configure(Configuration configuration)
+ throws ConfigurationException
+ {
+ super.configure( configuration );
+ Configuration effects = configuration.getChild( "effects" );
+ try
+ {
+ configureEffects( effects );
+ } catch( ComponentException e )
+ {
+ throw new ConfigurationException( "Unable to configure ImageOperations", e );
+ }
+ }
+
+ public void compose( ComponentManager man )
+ throws ComponentException
+ {
+ m_OperationSelector = (ComponentSelector) man.lookup( "org.apache.cocoon.reading.imageop.ImageOperationSelector" );
+ }
+
+ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
+ throws ProcessingException, SAXException, IOException
+ {
+ super.setup(resolver, objectModel, src, par);
+ m_Format = par.getParameter("output-format", FORMAT_DEFAULT);
+ getLogger().info( src + " --> " + m_Format );
+ setupEffectsStack( par );
+ }
+
+ protected void processStream( InputStream inputStream )
+ throws IOException, ProcessingException
+ {
+ if( m_EffectsStack.size() > 0 )
+ {
+ // since we create the image on the fly
+ response.setHeader("Accept-Ranges", "none");
+
+ BufferedImage image = ImageIO.read( inputStream );
+ if( image == null )
+ throw new ProcessingException( "Unable to decode the InputStream. Possibly an unknown format." );
+
+ image = applyEffectsStack( image );
+
+ write( image );
+ } else {
+ // only read the resource - no modifications requested
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("passing original resource");
+ }
+ super.processStream(inputStream);
+ }
+ }
+
+ /**
+ * Generate the unique key.
+ * This key must be unique inside the space of this component.
+ *
+ * @return The generated key consists of the src and width and height, and the color transform
+ * parameters
+ */
+ public Serializable getKey()
+ {
+ StringBuffer b = new StringBuffer( 200 );
+ b.append( this.inputSource.getURI() );
+ b.append( ':' );
+ b.append( m_Format );
+ b.append( ':' );
+ b.append( super.getKey() );
+ b.append( ':' );
+ Iterator list = m_EffectsStack.iterator();
+ while( list.hasNext() )
+ {
+ ImageOperation op = (ImageOperation) list.next();
+ b.append( op.getKey() );
+ b.append( ':' );
+ }
+ String key = b.toString();
+ b.setLength( 0 ); // Seems to be something odd (memory leak?)
+ // going on if this isn't done. (JDK1.4.2)
+ return key;
+ }
+
+ private void configureEffects( Configuration conf )
+ throws ConfigurationException, ComponentException
+ {
+ m_EffectsStack = new ArrayList();
+
+ Configuration[] ops = conf.getChildren( "op" );
+ for( int i=0 ; i < ops.length ; i++ )
+ {
+ String type = ops[i].getAttribute( "type" );
+ String prefix = ops[i].getAttribute( "prefix", type + "-" );
+ ImageOperation op = (ImageOperation) m_OperationSelector.select( type );
+ op.setPrefix( prefix );
+ m_EffectsStack.add( op );
+ }
+ }
+
+ private void setupEffectsStack( Parameters params )
+ throws ProcessingException
+ {
+ Iterator list = m_EffectsStack.iterator();
+ while( list.hasNext() )
+ {
+ ImageOperation op = (ImageOperation) list.next();
+ op.setup( params );
+ }
+ }
+
+ private BufferedImage applyEffectsStack( BufferedImage image )
+ {
+ if( m_EffectsStack.size() == 0 )
+ return image;
+ Iterator list = m_EffectsStack.iterator();
+ WritableRaster src = image.getRaster();
+ while( list.hasNext() )
+ {
+ ImageOperation op = (ImageOperation) list.next();
+ WritableRaster r = op.apply( src );
+ System.out.println( "In Bounds: " + r.getBounds() );
+ src = r.createWritableTranslatedChild( 0, 0 );
+ }
+ ColorModel cm = image.getColorModel();
+ System.out.println( "Out Bounds: " + src.getBounds() );
+ BufferedImage newImage = new BufferedImage( cm, src, true, new Hashtable() );
+ // Not sure what this should really be --------------^^^^^
+
+ int minX = newImage.getMinX();
+ int minY = newImage.getMinY();
+ int width = newImage.getWidth();
+ int height = newImage.getHeight();
+ System.out.println( "Image: " + minX + ", " + minY + ", " + width + ", " + height );
+
+ return newImage;
+ }
+
+ private void write( BufferedImage image )
+ throws ProcessingException, IOException
+ {
+ ImageTypeSpecifier its = ImageTypeSpecifier.createFromRenderedImage( image );
+ Iterator writers = ImageIO.getImageWriters( its, m_Format );
+ ImageWriter writer = null;
+ if( writers.hasNext() )
+ {
+ writer = (ImageWriter) writers.next();
+ }
+ if( writer == null )
+ throw new ProcessingException( "Unable to find a ImageWriter: " + m_Format );
+
+ ImageWriterSpi spi = writer.getOriginatingProvider();
+ String[] mimetypes = spi.getMIMETypes();
+ getLogger().info( "Setting content-type: " + mimetypes[0] );
+ response.setHeader("Content-Type", mimetypes[0] );
+ ImageOutputStream output = ImageIO.createImageOutputStream( out );
+ try
+ {
+ writer.setOutput( output );
+ writer.write( image );
+ } finally
+ {
+ writer.dispose();
+ output.close();
+ out.flush();
+ // Niclas Hedhman: Stream is closed in superclass.
+ }
+ }
+/*
+ private void printRaster( WritableRaster r )
+ {
+ DataBuffer data = r.getDataBuffer();
+ int numBanks = data.getNumBanks();
+ int size = data.getSize();
+ for( int i=0 ; i < size ; i++ )
+ {
+ long value = 0;
+ for( int j=0 ; j < numBanks ; j++ )
+ {
+ int v = data.getElem( j, i );
+ if( v < 256 )
+ value = value << 8 ;
+ else
+ value = value << 16;
+ value = value + v;
+ }
+ System.out.print( Long.toHexString( value ) );
+ System.out.print( " " );
+ }
+ System.out.println();
+ System.out.println();
+ }
+*/
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOpReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOpReader.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.component.Component;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+
+public interface ImageOperation extends Component
+{
+ static String ROLE = ImageOperation.class.getName();
+
+ void setPrefix( String prefix );
+
+ void setup( Parameters params )
+ throws ProcessingException;
+
+ WritableRaster apply( WritableRaster raster );
+
+ String getKey();
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ImageOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/MirrorOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/MirrorOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/MirrorOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/MirrorOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.geom.AffineTransform;
+
+import java.awt.image.AffineTransformOp;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+
+public class MirrorOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+ private boolean m_AlongY;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ throws ProcessingException
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ m_AlongY = params.getParameterAsBoolean( m_Prefix + "along-y", false );
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+ int xScale;
+ int yScale;
+ if( m_AlongY )
+ {
+ xScale = -1;
+ yScale = 1;
+ }
+ else
+ {
+ xScale = 1;
+ yScale = -1;
+ }
+ AffineTransform transform = new AffineTransform( xScale, 0.0d, 0.0d, yScale, 0.0d, 0.0d );
+ AffineTransformOp op = new AffineTransformOp( transform, AffineTransformOp.TYPE_BILINEAR );
+ WritableRaster scaledRaster = op.filter( image, null );
+ return scaledRaster;
+ }
+
+ public String getKey()
+ {
+ return "mirror:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + ( m_AlongY ? "along-y" : "along-x" )
+ + ":" + m_Prefix;
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/MirrorOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/MirrorOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/OffsetOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/OffsetOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/OffsetOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/OffsetOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.geom.AffineTransform;
+
+import java.awt.image.AffineTransformOp;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+
+public class OffsetOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+ private int m_Up;
+ private int m_Left;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ throws ProcessingException
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ m_Up = params.getParameterAsInteger( m_Prefix + "up", 0 );
+ m_Left = params.getParameterAsInteger( m_Prefix + "left", 0 );
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+ AffineTransform translate = AffineTransform.getTranslateInstance( m_Left, m_Up );
+ AffineTransformOp op = new AffineTransformOp( translate, AffineTransformOp.TYPE_BILINEAR );
+ WritableRaster scaledRaster = op.filter( image, null );
+ return scaledRaster;
+ }
+
+ public String getKey()
+ {
+ return "offset:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + m_Up
+ + ":" + m_Left
+ + ":" + m_Prefix;
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/OffsetOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/OffsetOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,88 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.geom.AffineTransform;
+
+import java.awt.image.AffineTransformOp;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+
+public class ResizeOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+ private int m_Height;
+ private int m_Width;
+ private boolean m_PreserveRatio;
+ private boolean m_AdjustX;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ throws ProcessingException
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ m_Height = params.getParameterAsInteger( m_Prefix + "height", 200 );
+ if( m_Height < 0 )
+ throw new ProcessingException( "Negative Height is not allowed: " + m_Height );
+ m_Width = params.getParameterAsInteger( m_Prefix + "width", 300 );
+ if( m_Width < 0 )
+ throw new ProcessingException( "Negative Width is not allowed: " + m_Width );
+ m_PreserveRatio = params.getParameterAsBoolean( m_Prefix + "preserve-ratio", false );
+ m_AdjustX = params.getParameterAsBoolean( m_Prefix + "adjust-x", false );
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+ double height = image.getHeight();
+ double width = image.getWidth();
+ double xScale = m_Width / width;
+ double yScale = m_Height / height;
+ if( m_PreserveRatio )
+ {
+ if( m_AdjustX )
+ xScale = yScale;
+ else
+ yScale = xScale;
+ }
+ AffineTransform scale = AffineTransform.getScaleInstance( xScale, yScale );
+ AffineTransformOp op = new AffineTransformOp( scale, AffineTransformOp.TYPE_BILINEAR );
+ WritableRaster scaledRaster = op.filter( image, null );
+ return scaledRaster;
+ }
+
+ public String getKey()
+ {
+ return "resize:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + m_Width
+ + ":" + m_Height
+ + ":" + m_Prefix;
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/RotateOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/RotateOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/RotateOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/RotateOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,85 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.geom.AffineTransform;
+
+import java.awt.image.AffineTransformOp;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+
+public class RotateOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+ private double m_Angle;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ throws ProcessingException
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ double angle = params.getParameterAsFloat( m_Prefix + "angle", 0.0f );
+ boolean useRadians = params.getParameterAsBoolean( m_Prefix + "use-radians", false);
+ if( ! useRadians )
+ m_Angle = ( angle / 180.0 ) * Math.PI;
+ else
+ m_Angle = angle;
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+ int width = image.getWidth();
+ int height = image.getHeight();
+ int x = width / 2;
+ int y = height / 2;
+
+ WritableRaster newRaster1 = image.createCompatibleWritableRaster(-x, -y, width, height );
+
+ AffineTransform translate = AffineTransform.getTranslateInstance( -x, -y );
+ AffineTransformOp op = new AffineTransformOp( translate, AffineTransformOp.TYPE_BILINEAR );
+ op.filter( image, newRaster1 );
+
+ AffineTransform rotate = AffineTransform.getRotateInstance( m_Angle );
+ op = new AffineTransformOp( rotate, AffineTransformOp.TYPE_BILINEAR );
+
+ WritableRaster newRaster2 = image.createCompatibleWritableRaster(-x, -y, width, height );
+ op.filter( newRaster1, newRaster2 );
+
+ return newRaster2;
+ }
+
+ public String getKey()
+ {
+ return "rotate:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + m_Angle
+ + ":" + m_Prefix;
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/RotateOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/RotateOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ScaleOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ScaleOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ScaleOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ScaleOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.geom.AffineTransform;
+
+import java.awt.image.AffineTransformOp;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+public class ScaleOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+ private float m_Scale;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ m_Scale = params.getParameterAsFloat( m_Prefix + "scale", 1.0f );
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+ AffineTransform scale = AffineTransform.getScaleInstance( m_Scale, m_Scale );
+ AffineTransformOp op = new AffineTransformOp( scale, AffineTransformOp.TYPE_BILINEAR );
+ WritableRaster scaledRaster = op.filter( image, null );
+ return scaledRaster;
+ }
+
+ public String getKey()
+ {
+ return "scale:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + m_Scale
+ + ":" + m_Prefix;
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ScaleOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ScaleOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ShearOperation.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ShearOperation.java?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ShearOperation.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ShearOperation.java Wed Feb 8 01:06:55 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.reading.imageop;
+
+import java.awt.RenderingHints;
+
+import java.awt.geom.AffineTransform;
+
+import java.awt.image.AffineTransformOp;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import org.apache.avalon.framework.parameters.Parameters;
+
+public class ShearOperation
+ implements ImageOperation
+{
+ private String m_Prefix;
+ private boolean m_Enabled;
+ private float m_ShearX;
+ private float m_ShearY;
+
+ public void setPrefix( String prefix )
+ {
+ m_Prefix = prefix;
+ }
+
+ public void setup( Parameters params )
+ {
+ m_Enabled = params.getParameterAsBoolean( m_Prefix + "enabled", true);
+ m_ShearX = params.getParameterAsFloat( m_Prefix + "shear-x", 0.0f );
+ m_ShearY = params.getParameterAsFloat( m_Prefix + "shear-y", 0.0f );
+ }
+
+ public WritableRaster apply( WritableRaster image )
+ {
+ if( ! m_Enabled )
+ return image;
+ AffineTransform shear = AffineTransform.getShearInstance( m_ShearX, m_ShearY );
+ AffineTransformOp op = new AffineTransformOp( shear, AffineTransformOp.TYPE_BILINEAR );
+ WritableRaster scaledRaster = op.filter( image, null );
+ return scaledRaster;
+ }
+
+ public String getKey()
+ {
+ return "shear:"
+ + ( m_Enabled ? "enable" : "disable" )
+ + ":" + m_ShearX
+ + ":" + m_ShearY
+ + ":" + m_Prefix;
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ShearOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ShearOperation.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/add.jpg
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/add.jpg?rev=375901&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/add.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/dir2page.xsl
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/dir2page.xsl?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/dir2page.xsl (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/dir2page.xsl Wed Feb 8 01:06:55 2006
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2002-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:dir="http://apache.org/cocoon/directory/2.0">
+
+ <xsl:template match="/">
+ <html><head><title>Image Directory Generator demonstration</title></head>
+ <body>
+ <h1>Image Directory Generator demonstration</h1>
+ <xsl:apply-templates/>
+ <p>
+ See other <a href=".">image reader</a> samples.
+ </p>
+ <p>
+ See documentation for
+ <a href="../../docs/userdocs/generators/imagedirectory-generator.html">Image
+ Directory Generator</a> and
+ <a href="../../docs/userdocs/readers/image-reader.html">Image Reader</a>
+ </p>
+ </body></html>
+ </xsl:template>
+
+ <xsl:template match="dir:directory">
+ <table border="1" cellpadding="3" cellspacing="3">
+ <tr>
+ <th>Image</th>
+ <th>Name</th>
+ <th>Width</th>
+ <th>Height</th>
+ <th colspan="2">Scale Size</th>
+ </tr>
+ <xsl:apply-templates select="dir:file|dir:directory"/>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="dir:file">
+ <xsl:variable name="basename" select="substring-before(@name,'.jpg')"/>
+ <tr>
+ <td valign="top">
+ <img src="full-{$basename}" alt="{@name} (full size)"
+ title="{@name} (full size)"
+ width="{@width}" height="{@height}"
+ />
+ </td>
+ <td valign="top"><xsl:value-of select="$basename"/></td>
+ <td valign="top"><xsl:value-of select="@width"/></td>
+ <td valign="top"><xsl:value-of select="@height"/></td>
+ <td valign="top">
+ <a href="scale-{@width*2}-{@height*2}-{$basename}"
+ title="{@name} (double size)">2x</a>
+ </td>
+ <td valign="top">
+ <a href="scale-{@width*3}-{@height*3}-{$basename}"
+ title="{@name} (triple size)">3x</a>
+ </td>
+ </tr>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/dir2page.xsl
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/fix.jpg
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/fix.jpg?rev=375901&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/fix.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/logo.jpg
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/logo.jpg?rev=375901&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/logo.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/logo2.png
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/logo2.png?rev=375901&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/logo2.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/remove.jpg
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/remove.jpg?rev=375901&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/remove.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/samples.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/samples.xml?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/samples.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/samples.xml Wed Feb 8 01:06:55 2006
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<samples xmlns:xlink="http://www.w3.org/1999/xlink" name="Image Effects Samples">
+
+ <group name="Main examples page.">
+ <sample name="Back" href="..">to Cocoon examples main page</sample>
+ </group>
+
+ <group name="The Original">
+ <sample href="image" name="Image">
+ Image of original size and color.
+ </sample>
+ </group>
+
+ <group name="ImageReader - Size Scaling">
+ <sample href="logo2.png/scale-0.5-jpg" name="Image Scaled">
+ An PNG file is read from the system, scaled to half size and
+ converted to JPG, which is returned to the client.
+ </sample>
+ <sample href="logo2.png/resize-50-50" name="Image 50x50">
+ Image scaled down to the size 50 x 50.
+ </sample>
+ <sample href="logo2.png/resize-250-250" name="Image 250x250">
+ Image scaled up to the size 250 x 250.
+ </sample>
+ <sample href="logo2.png/resize-50-100" name="Image 50x100">
+ Image scaled along x-axis only.
+ </sample>
+ </group>
+
+ <group name="ImageReader - Color Manipulation">
+ <sample href="logo2.png/grayscale" name="Image grayscaled">
+ The image in gray.
+ </sample>
+ <sample href="logo2.png/color-2-1-1-0-0-0" name="Image tinted red">
+ The values for the color red are doubled.
+ </sample>
+ <sample href="logo2.png/color-1-2-1-0-0-0" name="Image tinted green">
+ The values for the color green are doubled.
+ </sample>
+ <sample href="logo2.png/color-1-1-2-0-0-0" name="Image tinted blue">
+ The values for the color blue are doubled.
+ </sample>
+ <sample href="logo2.png/color-1-1-1-50-0-0" name="Image tinted red">
+ The values for the color red are incremented by 50.
+ </sample>
+ <sample href="logo2.png/color-1-1-1-0-50-0" name="Image tinted green">
+ The values for the color green are incremented by 50.
+ </sample>
+ <sample href="logo2.png/color-1-1-1-0-0-50" name="Image tinted blue">
+ The values for the color blue are incremented by 50.
+ </sample>
+ </group>
+
+ <group name="ImageReader - Transforms">
+ <note>
+ We provide the following transform samples as-is, but sadly they don't
+ work satisfactorily. Your contribution to fix them will be greatly
+ appreciated.
+ </note>
+ <sample href="logo2.png/rotate-90" name="Image Rotate 90 degree">
+ The image is rotated 90 degrees clockwise.
+ </sample>
+ <sample href="logo2.png/rotate-180" name="Image Rotate 180 degree">
+ The image is rotated 180 degrees clockwise.
+ </sample>
+ <sample href="logo2.png/rotate-270" name="Image Rotate 270 degree">
+ The image is rotated 270 degrees clockwise.
+ </sample>
+ <sample href="logo2.png/mirror-false" name="Image Mirrored Horizontally">
+ The image is mirrored along the X-axis.
+ </sample>
+ <sample href="logo2.png/mirror-true" name="Image Mirrored Vertically">
+ The image is mirrored along the Y-axis.
+ </sample>
+ </group>
+
+ <group name="ImageReader - Visuals">
+ <sample href="logo2.png/sharpen" name="Image Sharpened">
+ The image is sharpened with a medium strength convolve operation.
+ </sample>
+ <sample href="logo2.png/blur" name="Image Blurred">
+ The image is blurred with a medium strength convolve operation.
+ </sample>
+ </group>
+</samples>
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/samples.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/samples.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/sitemap.xmap?rev=375901&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/sitemap.xmap (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/sitemap.xmap Wed Feb 8 01:06:55 2006
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+<!-- =========================== Pipelines ================================= -->
+
+ <map:pipelines>
+ <map:pipeline>
+
+ <map:match pattern="">
+ <map:generate src="samples.xml"/>
+ <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
+ <map:parameter name="contextPath" value="{request:contextPath}"/>
+ </map:transform>
+ <map:serialize/>
+ </map:match>
+
+ <map:match pattern="image">
+ <map:read src="logo.jpg"/>
+ </map:match>
+
+ <map:match pattern="*/scale-*-*">
+ <map:read type="image-op-scale" src="{1}" >
+ <map:parameter name="scale-scale" value="{2}"/>
+ <map:parameter name="output-format" value="{3}"/>
+ </map:read>
+ </map:match>
+
+ <map:match pattern="*/resize-*-*">
+ <map:read type="image-op-resize" src="{1}" >
+ <map:parameter name="size-width" value="{2}"/>
+ <map:parameter name="size-height" value="{3}"/>
+ </map:read>
+ </map:match>
+
+ <map:match pattern="*/offset-*-*">
+ <map:read type="image-op-offset" src="{1}" >
+ <map:parameter name="offset-up" value="{2}"/>
+ <map:parameter name="offset-left" value="{3}"/>
+ </map:read>
+ </map:match>
+
+ <map:match pattern="*/mirror-*">
+ <map:read type="image-op-mirror" src="{1}" >
+ <map:parameter name="mirror-along-y" value="{2}"/>
+ </map:read>
+ </map:match>
+
+ <map:match pattern="*/rotate-*">
+ <map:read type="image-op-rotate" src="{1}" >
+ <map:parameter name="rotate-angle" value="{2}"/>
+ </map:read>
+ </map:match>
+
+ <map:match pattern="*/grayscale">
+ <map:read type="image-op-grayscale" src="{1}" />
+ </map:match>
+
+ <map:match pattern="*/color-*-*-*-*-*-*">
+ <map:read type="image-op-color" src="{1}" >
+ <map:parameter name="color-scale-red" value="{2}"/>
+ <map:parameter name="color-scale-green" value="{3}"/>
+ <map:parameter name="color-scale-blue" value="{4}"/>
+ <map:parameter name="color-offset-red" value="{5}"/>
+ <map:parameter name="color-offset-green" value="{6}"/>
+ <map:parameter name="color-offset-blue" value="{7}"/>
+ </map:read>
+ </map:match>
+
+ <map:match pattern="*/complex-*-*-*-*-*-*-*-*">
+ <map:read type="image-op-complex" src="{1}" >
+ <map:parameter name="mirror-enabled" value="{2}"/>
+ <map:parameter name="size-width" value="{3}"/>
+ <map:parameter name="size-height" value="{4}"/>
+ <map:parameter name="shear-x" value="{5}"/>
+ <map:parameter name="shear-y" value="{6}"/>
+ <map:parameter name="rotate-angle" value="{7}"/>
+ <map:parameter name="offset-up" value="{8}"/>
+ <map:parameter name="offset-left" value="{9}"/>
+ </map:read>
+ </map:match>
+
+ <map:match pattern="*/sharpen">
+ <map:read type="image-op-convolve" src="{1}" >
+ <map:parameter name="convolve-height" value="3" />
+ <map:parameter name="convolve-width" value="3" />
+ <map:parameter name="convolve-data" value="0.0, -1.0, 0.0, -1.0, 5.0, -1.0, 0.0, -1.0, 0.0" />
+ </map:read>
+ </map:match>
+
+ <map:match pattern="*/blur">
+ <map:read type="image-op-convolve" src="{1}" >
+ <map:parameter name="convolve-height" value="3" />
+ <map:parameter name="convolve-width" value="3" />
+ <map:parameter name="convolve-data" value="0.1, 0.1, 0.1, 0.1, 0.2, 0.1, 0.1, 0.1, 0.1"/>
+ </map:read>
+ </map:match>
+
+ </map:pipeline>
+ </map:pipelines>
+</map:sitemap>
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/sitemap.xmap
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/sitemap.xmap
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/update.jpg
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/update.jpg?rev=375901&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/samples/update.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=375901&r1=375900&r2=375901&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Wed Feb 8 01:06:55 2006
@@ -180,6 +180,12 @@
<release version="@version@" date="@date@">
-->
<release version="2.1.9" date="TBD">
+ <action dev="JBQ" type="add" fixes-bug="COCOON-1301" due-to="Niclas Hedhman" due-to-email="niclas@apache.org">
+ Added the imageop block, an Image Operation Reader providing a fairly
+ flexible and powerful Image Reader that is capable of performing a stack
+ of Effects, such as Scaling, color manipulation and coordination
+ transforms, in a pluggable manner.
+ </action>
<action dev="JBQ" type="fix" fixes-bug="COCOON-1715">
Allow to run Cocoon CLI by adding servlet.jar in the classpath. Turn off cli's debug messages by default.
</action>