Changeset 492

Show
Ignore:
Timestamp:
05/30/10 16:10:07 (2 years ago)
Author:
litwan
Message:

- introduced background color configuration

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • resource-types/image-resizer/src/java/com/litwan/yanel/impl/resources/imageresizer/ImageResizerResource.java

    r491 r492  
    1818 
    1919import java.awt.AlphaComposite; 
     20import java.awt.Color; 
    2021import java.awt.Graphics2D; 
    2122import java.awt.Image; 
     
    7071     
    7172    private static final String CONFIG_PROPERTY_CROP_H = "crop-h"; 
     73 
     74    private static final String CONFIG_PROPERTY_BACKGROUND_COLOR = "background-color"; 
    7275 
    7376    private static final String CONFIG_PROPERTY_TARGET_PERCENTAGE = "target-percentage"; 
     
    197200        int cropH = origHeight; 
    198201        int cropW = origWidth; 
    199          
     202        Color color = new Color(0xFFFFFF); 
    200203         
    201204         
     
    254257            throw new Exception("Image resizer is not properly configured."); 
    255258        } 
    256          
     259        //croping 
    257260        String propertyCropX = getResourceConfigProperty(CONFIG_PROPERTY_CROP_X); 
    258261        String propertyCropY = getResourceConfigProperty(CONFIG_PROPERTY_CROP_Y); 
     
    295298            cropH = origHeight - cropY; 
    296299        } 
     300        //backgroundColor 
     301        String propertyBackgroundColor = getResourceConfigProperty(CONFIG_PROPERTY_BACKGROUND_COLOR); 
     302        if (propertyBackgroundColor != null) { 
     303            color = Color.decode(propertyBackgroundColor); 
     304        } 
    297305        if (Boolean.parseBoolean(getResourceConfigProperty(CONFIG_PROPERTY_PROHIBIT_UP_SCALE)) && (targetWidth > origWidth || targetHeight > origHeight)) { 
    298306            return originalImage; 
     
    305313                g.setComposite(AlphaComposite.Src); 
    306314            } 
    307             g.drawImage(clipedImage, 0, 0, targetWidth, targetHeight, null);  
     315            g.drawImage(clipedImage, 0, 0, targetWidth, targetHeight, color, null);  
    308316            g.dispose(); 
    309317            return scaledBI;