Search in sources :

Example 31 with Image

use of lucee.runtime.img.Image in project Lucee by lucee.

the class ImageRotate method _call.

private static String _call(PageContext pc, Object name, float x, float y, float angle, String strInterpolation) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    strInterpolation = strInterpolation.trim().toLowerCase();
    int interpolation;
    if ("nearest".equals(strInterpolation))
        interpolation = lucee.runtime.img.Image.INTERPOLATION_NEAREST;
    else if ("bilinear".equals(strInterpolation))
        interpolation = lucee.runtime.img.Image.INTERPOLATION_BILINEAR;
    else if ("bicubic".equals(strInterpolation))
        interpolation = lucee.runtime.img.Image.INTERPOLATION_BICUBIC;
    else if ("none".equals(strInterpolation))
        interpolation = lucee.runtime.img.Image.INTERPOLATION_NONE;
    else
        throw new ExpressionException("invalid interpolation definition [" + strInterpolation + "]," + " valid values are [nearest,bilinear,bicubic]");
    img.rotate(x, y, angle, interpolation);
    return null;
}
Also used : Image(lucee.runtime.img.Image) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 32 with Image

use of lucee.runtime.img.Image in project Lucee by lucee.

the class ImageScaleToFit method call.

public static String call(PageContext pc, Object name, String fitWidth, String fitHeight, String strInterpolation, double blurFactor) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    img.scaleToFit(fitWidth, fitHeight, strInterpolation, blurFactor);
    return null;
}
Also used : Image(lucee.runtime.img.Image)

Example 33 with Image

use of lucee.runtime.img.Image in project Lucee by lucee.

the class ImageSetDrawingColor method call.

public static String call(PageContext pc, Object name, String strColor) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    Color color = ColorCaster.toColor(strColor);
    img.setColor(color);
    return null;
}
Also used : Color(java.awt.Color) Image(lucee.runtime.img.Image)

Example 34 with Image

use of lucee.runtime.img.Image in project Lucee by lucee.

the class ImageSetDrawingStroke method call.

public static String call(PageContext pc, Object name, Struct attributeCollection) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    img.setDrawingStroke(attributeCollection);
    return null;
}
Also used : Image(lucee.runtime.img.Image)

Example 35 with Image

use of lucee.runtime.img.Image in project Lucee by lucee.

the class ImageShear method call.

public static String call(PageContext pc, Object name, double shear, String strDirection, String strInterpolation) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    // direction
    strDirection = strDirection.toLowerCase().trim();
    ShearDir direction;
    if ("horizontal".equals(strDirection))
        direction = ShearDescriptor.SHEAR_HORIZONTAL;
    else if ("vertical".equals(strDirection))
        direction = ShearDescriptor.SHEAR_VERTICAL;
    else
        throw new FunctionException(pc, "ImageShear", 3, "direction", "invalid direction definition [" + strDirection + "], " + "valid direction values are [horizontal,vertical]");
    // interpolation
    strInterpolation = strInterpolation.toLowerCase().trim();
    Object interpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
    if ("nearest".equals(strInterpolation))
        interpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
    else if ("bilinear".equals(strInterpolation))
        interpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
    else if ("bicubic".equals(strInterpolation))
        interpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
    else
        throw new FunctionException(pc, "ImageTranslate", 4, "interpolation", "invalid interpolation definition [" + strInterpolation + "], " + "valid interpolation values are [nearest,bilinear,bicubic]");
    img.shear((float) shear, direction, interpolation);
    return null;
}
Also used : ShearDir(javax.media.jai.operator.ShearDir) FunctionException(lucee.runtime.exp.FunctionException) Image(lucee.runtime.img.Image)

Aggregations

Image (lucee.runtime.img.Image)38 FunctionException (lucee.runtime.exp.FunctionException)17 IOException (java.io.IOException)4 Color (java.awt.Color)3 Resource (lucee.commons.io.res.Resource)3 BufferedImage (java.awt.image.BufferedImage)2 ExpressionException (lucee.runtime.exp.ExpressionException)2 Paint (java.awt.Paint)1 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 ShearDir (javax.media.jai.operator.ShearDir)1 TransposeType (javax.media.jai.operator.TransposeType)1 PageSource (lucee.runtime.PageSource)1 ConverterException (lucee.runtime.converter.ConverterException)1 Struct (lucee.runtime.type.Struct)1