Search in sources :

Example 26 with Image

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

the class ImageDrawOval method call.

public static String call(PageContext pc, Object name, double x, double y, double width, double height, boolean filled) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    if (width < 0)
        throw new FunctionException(pc, "ImageDrawOval", 3, "width", "width must contain a none negative value");
    if (height < 0)
        throw new FunctionException(pc, "ImageDrawOval", 4, "height", "width must contain a none negative value");
    img.drawOval((int) x, (int) y, (int) width, (int) height, filled);
    return null;
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) Image(lucee.runtime.img.Image)

Example 27 with Image

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

the class ImageDrawPoint method call.

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

Example 28 with Image

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

the class ImageDrawQuadraticCurve method call.

public static String call(PageContext pc, Object name, double x1, double y1, double ctrlx, double ctrly, double x2, double y2) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    img.drawQuadraticCurve(x1, y1, ctrlx, ctrly, x2, y2);
    return null;
}
Also used : Image(lucee.runtime.img.Image)

Example 29 with Image

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

the class ImageFlip method call.

public static String call(PageContext pc, Object name, String strTranspose) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    strTranspose = strTranspose.toLowerCase().trim();
    TransposeType transpose = TransposeDescriptor.FLIP_VERTICAL;
    if ("vertical".equals(strTranspose))
        transpose = TransposeDescriptor.FLIP_VERTICAL;
    else if ("horizontal".equals(strTranspose))
        transpose = TransposeDescriptor.FLIP_HORIZONTAL;
    else if ("diagonal".equals(strTranspose))
        transpose = TransposeDescriptor.FLIP_DIAGONAL;
    else if ("antidiagonal".equals(strTranspose))
        transpose = TransposeDescriptor.FLIP_ANTIDIAGONAL;
    else if ("anti diagonal".equals(strTranspose))
        transpose = TransposeDescriptor.FLIP_ANTIDIAGONAL;
    else if ("anti-diagonal".equals(strTranspose))
        transpose = TransposeDescriptor.FLIP_ANTIDIAGONAL;
    else if ("anti_diagonal".equals(strTranspose))
        transpose = TransposeDescriptor.FLIP_ANTIDIAGONAL;
    else if ("90".equals(strTranspose))
        transpose = TransposeDescriptor.ROTATE_90;
    else if ("180".equals(strTranspose))
        transpose = TransposeDescriptor.ROTATE_180;
    else if ("270".equals(strTranspose))
        transpose = TransposeDescriptor.ROTATE_270;
    else
        throw new FunctionException(pc, "ImageFlip", 2, "transpose", "invalid transpose definition [" + strTranspose + "], " + "valid transpose values are [vertical,horizontal,diagonal,90,180,270]");
    img.flip(transpose);
    return null;
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) TransposeType(javax.media.jai.operator.TransposeType) Image(lucee.runtime.img.Image)

Example 30 with Image

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

the class ImageNew method call.

public static Object call(PageContext pc, Object source, String width, String height, String strImageType, String strCanvasColor) throws PageException {
    if (source == null)
        return call(pc);
    if (StringUtil.isEmpty(width) && StringUtil.isEmpty(height))
        return call(pc, source);
    if (StringUtil.isEmpty(width))
        throw new FunctionException(pc, "ImageNew", 2, "width", "missing argument");
    if (StringUtil.isEmpty(height))
        throw new FunctionException(pc, "ImageNew", 3, "height", "missing argument");
    if (!StringUtil.isEmpty(source))
        throw new FunctionException(pc, "ImageNew", 1, "source", "if you define width and height, source has to be empty");
    // image type
    int imageType;
    if (StringUtil.isEmpty(strImageType, true))
        imageType = BufferedImage.TYPE_INT_RGB;
    else {
        strImageType = strImageType.trim().toLowerCase();
        if ("rgb".equals(strImageType))
            imageType = BufferedImage.TYPE_INT_RGB;
        else if ("argb".equals(strImageType))
            imageType = BufferedImage.TYPE_INT_ARGB;
        else if ("gray".equals(strImageType))
            imageType = BufferedImage.TYPE_BYTE_GRAY;
        else if ("grayscale".equals(strImageType))
            imageType = BufferedImage.TYPE_BYTE_GRAY;
        else
            throw new FunctionException(pc, "ImageNew", 4, "imageType", "imageType has an invalid value [" + strImageType + "]," + "valid values are [rgb,argb,grayscale]");
    }
    // canvas color
    Color canvasColor;
    if (StringUtil.isEmpty(strCanvasColor, true))
        canvasColor = null;
    else
        canvasColor = ColorCaster.toColor(strCanvasColor);
    return new Image(Caster.toIntValue(width), Caster.toIntValue(height), imageType, canvasColor);
}
Also used : Color(java.awt.Color) FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage) 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