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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations