cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltriel...@apache.org
Subject svn commit: r530482 - in /cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop: CombineImagesOperation.java ImageOpReader.java OverlayOperation.java
Date Thu, 19 Apr 2007 16:48:34 GMT
Author: ltrieloff
Date: Thu Apr 19 09:48:33 2007
New Revision: 530482

URL: http://svn.apache.org/viewvc?view=rev&rev=530482
Log:
fixed a problem with transparent images

Modified:
    cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/CombineImagesOperation.java
    cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/ImageOpReader.java
    cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/OverlayOperation.java

Modified: cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/CombineImagesOperation.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/CombineImagesOperation.java?view=diff&rev=530482&r1=530481&r2=530482
==============================================================================
--- cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/CombineImagesOperation.java
(original)
+++ cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/CombineImagesOperation.java
Thu Apr 19 09:48:33 2007
@@ -21,7 +21,7 @@
 
 public interface CombineImagesOperation extends GenericImageOperation {
     
-    WritableRaster combine(BufferedImage source, BufferedImage overlay);
+    BufferedImage combine(BufferedImage source, BufferedImage overlay);
 
     String getOverlayURI();
 }

Modified: cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/ImageOpReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/ImageOpReader.java?view=diff&rev=530482&r1=530481&r2=530482
==============================================================================
--- cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/ImageOpReader.java
(original)
+++ cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/ImageOpReader.java
Thu Apr 19 09:48:33 2007
@@ -195,11 +195,19 @@
         }
         Iterator list = effectsStack.iterator();
         WritableRaster src = image.getRaster();
+        BufferedImage newImage = null;
+        
         while( list.hasNext() ) {
             GenericImageOperation op = (GenericImageOperation) list.next();
             WritableRaster r;
             if (op instanceof ImageOperation) {
                 r = ((ImageOperation) op).apply( src );
+                
+	            if(getLogger().isDebugEnabled()) {
+	                getLogger().debug( "In Bounds: " + r.getBounds() );
+	            }
+	            src = r.createWritableTranslatedChild( 0, 0 );
+	            
             } else if (op instanceof CombineImagesOperation) {
                 CombineImagesOperation cio = (CombineImagesOperation) op;
                 String uri = cio.getOverlayURI();
@@ -220,23 +228,21 @@
                     throw new ProcessingException("Source '" + uri + "' for combine image
operation cannot be read.", e);
                 }
                 
-                r = cio.combine(image, secondImage);
+                newImage = cio.combine(image, secondImage);
+                image = newImage;
+                src = image.getRaster();
             } else {
                 continue;
             }
-            
-            if(getLogger().isDebugEnabled()) {
-                getLogger().debug( "In Bounds: " + r.getBounds() );
-            }
-            src = r.createWritableTranslatedChild( 0, 0 );
         }
-        ColorModel cm = image.getColorModel();
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug( "Out Bounds: " + src.getBounds() );
+        if (newImage == null) {        	
+	        ColorModel cm = image.getColorModel();
+	        if (getLogger().isDebugEnabled()) {
+	            getLogger().debug( "Out Bounds: " + src.getBounds() );
+	        }
+	        newImage = new BufferedImage( cm, src, true, new Hashtable() );
+	        // Not sure what this should really be --------------^^^^^
         }
-        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();

Modified: cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/OverlayOperation.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/OverlayOperation.java?view=diff&rev=530482&r1=530481&r2=530482
==============================================================================
--- cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/OverlayOperation.java
(original)
+++ cocoon/trunk/blocks/cocoon-imageop/cocoon-imageop-impl/src/main/java/org/apache/cocoon/reading/imageop/OverlayOperation.java
Thu Apr 19 09:48:33 2007
@@ -57,12 +57,12 @@
         }
     }
     
-    public WritableRaster combine(BufferedImage image, BufferedImage overlay) {
+    public BufferedImage combine(BufferedImage image, BufferedImage overlay) {
         if (!enabled) {
-            return image.getRaster();
+            return image;
         }
         
-        BufferedImage result = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
+        BufferedImage result = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
         Graphics2D g = result.createGraphics();
         
         // first copy the original image into the result
@@ -74,7 +74,7 @@
         // then overlay the second image with alpha compositing turned on
         g.drawImage(overlay, offset_x, offset_y, null);        
         
-        return result.getRaster();
+        return result;
     }
 
     public String getKey() {



Mime
View raw message