001 package railo.runtime.functions.image; 002 003 import railo.runtime.PageContext; 004 import railo.runtime.exp.FunctionException; 005 import railo.runtime.exp.PageException; 006 import railo.runtime.img.Image; 007 import railo.runtime.op.Caster; 008 009 public class ImageCopy { 010 011 public static Object call(PageContext pc, Object name, double x, double y, double width, double height) throws PageException { 012 if(name instanceof String) name=pc.getVariable(Caster.toString(name)); 013 Image img = Image.toImage(name); 014 015 if (width < 0) 016 throw new FunctionException(pc,"ImageCopy",3,"width","width must contain a none negative value"); 017 if (height < 0) 018 throw new FunctionException(pc,"ImageCopy",4,"height","width must contain a none negative value"); 019 020 return img.copy((float)x, (float)y, (float)width, (float)height); 021 } 022 023 public static Object call(PageContext pc, Object name, double x, double y, double width, double height,double dx) throws PageException { 024 throw new FunctionException(pc,"ImageCopy",7,"dy","when you define dx, you have also to define dy"); 025 } 026 027 public static Object call(PageContext pc, Object name, double x, double y, double width, double height, double dx, double dy) throws PageException { 028 if(dx==-999 && dy==-999){// -999 == default value for named argument 029 return call(pc, name, x, y, width, height); 030 } 031 if(dx==-999){// -999 == default value for named argument 032 throw new FunctionException(pc,"ImageCopy",6,"dx","when you define dy, you have also to define dx"); 033 } 034 if(dy==-999){// -999 == default value for named argument 035 throw new FunctionException(pc,"ImageCopy",7,"dy","when you define dx, you have also to define dy"); 036 } 037 038 039 if(name instanceof String) name=pc.getVariable(Caster.toString(name)); 040 Image img = Image.toImage(name); 041 042 if (width < 0) 043 throw new FunctionException(pc,"ImageCopy",3,"width","width must contain a none negative value"); 044 if (height < 0) 045 throw new FunctionException(pc,"ImageCopy",4,"height","width must contain a none negative value"); 046 047 return img.copy((float)x, (float)y, (float)width, (float)height, (float)dx, (float)dy); 048 //return null; 049 } 050 }