Diff for /parser3/src/classes/image.C between versions 1.90.2.15.2.12 and 1.91

version 1.90.2.15.2.12, 2003/03/24 10:21:28 version 1.91, 2003/07/24 11:31:20
Line 175  public: Line 175  public:
                 if(limit==0)                  if(limit==0)
                         return 0;                          return 0;
   
                 char* lbuf=new char[limit];                  char* lbuf=new(PointerFreeGC) char[limit];
                 size_t read_size=(size_t)::read(f, lbuf, limit);  abuf=lbuf;                  size_t read_size=(size_t)::read(f, lbuf, limit);  abuf=lbuf;
                 if(ssize_t(read_size)<0 || read_size>limit)                  if(ssize_t(read_size)<0 || read_size>limit)
                         throw Exception(0,                          throw Exception(0,
Line 396  static Value* parse_IFD_entry_formatted_ Line 396  static Value* parse_IFD_entry_formatted_
 // date.C  // date.C
 time_t cstr_to_time_t(char *cstr, bool fail_on_error);  time_t cstr_to_time_t(char *cstr, bool fail_on_error);
   
 static Value* parse_IFD_entry_formatted_value(  static Value* parse_IFD_entry_formatted_value(bool is_big, ushort format, 
                                                                                           bool is_big, ushort format,                                                 size_t component_size, uint components_count, 
                                                                                           size_t component_size, uint components_count,                                                 const uchar *value) {
                                                                                           const uchar *value) {  
         if(format==2) { // ascii string, exception: the only type with varying size          if(format==2) { // ascii string, exception: the only type with varying size
                 const char* cstr=(const char* )value;                  const char* cstr=(const char* )value;
                 size_t size=components_count;                  size_t length=components_count;
                 // Data format is "YYYY:MM:DD HH:MM:SS"+0x00, total 20bytes                  // Data format is "YYYY:MM:DD HH:MM:SS"+0x00, total 20bytes
                 if(size==JPEG_EXIF_DATE_CHARS                   if(length==JPEG_EXIF_DATE_CHARS 
                         && isdigit(cstr[0])                          && isdigit(cstr[0])
                         && cstr[JPEG_EXIF_DATE_CHARS-1]==0) {                          && cstr[length-1]==0) {
                         char cstr_writable[JPEG_EXIF_DATE_CHARS];                           char cstr_writable[JPEG_EXIF_DATE_CHARS]; 
                         strcpy(cstr_writable, cstr);                          strcpy(cstr_writable, cstr);
   
Line 416  static Value* parse_IFD_entry_formatted_ Line 415  static Value* parse_IFD_entry_formatted_
                                 return new VDate(t);                                  return new VDate(t);
                 }                  }
   
                 if(const char* premature_zero_pos=(const char* )memchr(cstr, 0, size))                  if(const char* premature_zero_pos=(const char* )memchr(cstr, 0, length))
                         size=premature_zero_pos-cstr;                          length=premature_zero_pos-cstr;
                 return new VString(*new String(cstr, size, true/*tainted*/));                  return new VString(*new String(cstr, length, true/*tainted*/));
         }          }
   
         if(components_count==1)          if(components_count==1)
Line 428  static Value* parse_IFD_entry_formatted_ Line 427  static Value* parse_IFD_entry_formatted_
         HashStringValue& hash=result->hash();          HashStringValue& hash=result->hash();
         for(uint i=0; i<components_count; i++, value+=component_size) {          for(uint i=0; i<components_count; i++, value+=component_size) {
                 hash.put(                  hash.put(
                         StringBody(pa_format_integer(i)),                          StringBody::Format(i),
                         parse_IFD_entry_formatted_one_value(is_big, format, component_size, value));                          parse_IFD_entry_formatted_one_value(is_big, format, component_size, value));
         }          }
   
Line 515  static void parse_IFD_entry(HashStringVa Line 514  static void parse_IFD_entry(HashStringVa
                 if(const char* name=exif_tag_value2name.get(tag))                  if(const char* name=exif_tag_value2name.get(tag))
                         hash.put(StringBody(name), value);                          hash.put(StringBody(name), value);
                 else                  else
                         hash.put(StringBody(pa_format_integer(tag)), value);                          hash.put(StringBody::Format(tag), value);
         }          }
 }  }
   
Line 697  static void file_measure_action( Line 696  static void file_measure_action(
         measure(*info.file_name, reader, *info.width, *info.height, info.exif);          measure(*info.file_name, reader, *info.width, *info.height, info.exif);
 }  }
   
 static void _measure(Request& r, MethodParams* params) {  static void _measure(Request& r, MethodParams& params) {
         Value& data=params->as_no_junction(0, "data must not be code");          Value& data=params.as_no_junction(0, "data must not be code");
   
         ushort width=0;          ushort width=0;
         ushort height=0;          ushort height=0;
         Value* exif=0;          Value* exif=0;
         const String* file_name;          const String* file_name;
         if(file_name=data.get_string()) {          if(file_name=data.get_string()) {
                 File_measure_action_info info;                  File_measure_action_info info={0};
                 info.width=&width;                  info.width=&width;
                 info.height=&height;                  info.height=&height;
                 info.exif=&exif;                  info.exif=&exif;
Line 745  static void append_attrib_pair( Line 744  static void append_attrib_pair(
         if(value->is_string() || value->as_int()>=0)          if(value->is_string() || value->as_int()>=0)
                 *info->tag << "=\"" << value->as_string() << "\"";                  *info->tag << "=\"" << value->as_string() << "\"";
 }  }
 static void _html(Request& r, MethodParams* params) {  static void _html(Request& r, MethodParams& params) {
   
         String tag;          String tag;
         tag << "<img";          tag << "<img";
Line 753  static void _html(Request& r, MethodPara Line 752  static void _html(Request& r, MethodPara
         const HashStringValue& fields=GET_SELF(r, VImage).fields();          const HashStringValue& fields=GET_SELF(r, VImage).fields();
         HashStringValue* attribs=0;          HashStringValue* attribs=0;
   
         if(params->count()) {          if(params.count()) {
                 // for backward compatibility: someday was ^html{}                  // for backward compatibility: someday was ^html{}
                 Value& vattribs=r.process_to_value(*(*params)[0],                  Value& vattribs=r.process_to_value(params[0],
                         /*0/*no name* /,*/                          /*0/*no name* /,*/
                         false/*don't intercept string*/);                          false/*don't intercept string*/);
                 if(!vattribs.is_string()) // allow empty                  if(!vattribs.is_string()) // allow empty
Line 779  static void _html(Request& r, MethodPara Line 778  static void _html(Request& r, MethodPara
 /// @test wrap FILE to auto-object  /// @test wrap FILE to auto-object
 static gdImage* load(Request& r,   static gdImage* load(Request& r, 
                                          const String& file_name){                                           const String& file_name){
   
         const char* file_name_cstr=r.absolute(file_name).cstr(String::L_FILE_SPEC);          const char* file_name_cstr=r.absolute(file_name).cstr(String::L_FILE_SPEC);
         if(FILE *f=fopen(file_name_cstr, "rb")) {          if(FILE *f=fopen(file_name_cstr, "rb")) {
                 gdImage* image=new gdImage;                  gdImage* image=new gdImage;
Line 799  static gdImage* load(Request& r, Line 797  static gdImage* load(Request& r,
 }  }
   
   
 static void _load(Request& r, MethodParams* params) {  static void _load(Request& r, MethodParams& params) {
         const String& file_name=params->as_string(0, "file name must not be code");          const String& file_name=params.as_string(0, "file name must not be code");
   
         gdImage* image=load(r, file_name);          gdImage* image=load(r, file_name);
         GET_SELF(r, VImage).set(&file_name, image->SX(), image->SY(), image);          GET_SELF(r, VImage).set(&file_name, image->SX(), image->SY(), image);
 }  }
   
 static void _create(Request& r, MethodParams* params) {  static void _create(Request& r, MethodParams& params) {
   
         int width=params->as_int(0, "width must be int", r);          int width=params.as_int(0, "width must be int", r);
         int height=params->as_int(1, "height must be int", r);          int height=params.as_int(1, "height must be int", r);
         int bgcolor_value=0xffFFff;          int bgcolor_value=0xffFFff;
         if(params->count()>2)          if(params.count()>2)
                 bgcolor_value=params->as_int(2, "color must be int", r);                  bgcolor_value=params.as_int(2, "color must be int", r);
         gdImage* image=new gdImage;          gdImage* image=new gdImage;
         image->Create(width, height);          image->Create(width, height);
         image->FilledRectangle(0, 0, width-1, height-1, image->Color(bgcolor_value));          image->FilledRectangle(0, 0, width-1, height-1, image->Color(bgcolor_value));
         GET_SELF(r, VImage).set(0, width, height, image);          GET_SELF(r, VImage).set(0, width, height, image);
 }  }
   
 static void _gif(Request& r, MethodParams* params) {  static void _gif(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 829  static void _gif(Request& r, MethodParam Line 827  static void _gif(Request& r, MethodParam
   
         // could _ but don't thing it's wise to use $image.src for vfile.name          // could _ but don't thing it's wise to use $image.src for vfile.name
   
         String out; image->Gif(out);          gdBuf buf=image->Gif();
                   
         VFile& vfile=*new VFile;          VFile& vfile=*new VFile;
         Value* content_type=new VString(*new String("image/gif"));          Value* content_type=new VString(*new String("image/gif"));
         vfile.set(false/*not tainted*/,           vfile.set(false/*not tainted*/, 
                 out.cstr(), out.length(), 0, content_type);                  (const char*)buf.ptr, buf.size, 0, content_type);
   
         r.write_no_lang(vfile);          r.write_no_lang(vfile);
 }  }
   
 static void _line(Request& r, MethodParams* params) {  static void _line(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 848  static void _line(Request& r, MethodPara Line 846  static void _line(Request& r, MethodPara
                         "does not contain an image");                          "does not contain an image");
   
         image->Line(          image->Line(
                 params->as_int(0, "x0 must be int", r),                   params.as_int(0, "x0 must be int", r), 
                 params->as_int(1, "y0 must be int", r),                   params.as_int(1, "y0 must be int", r), 
                 params->as_int(2, "x1 must be int", r),                   params.as_int(2, "x1 must be int", r), 
                 params->as_int(3, "y1 must be int", r),                   params.as_int(3, "y1 must be int", r), 
                 image->Color(params->as_int(4, "color must be int", r)));                  image->Color(params.as_int(4, "color must be int", r)));
 }  }
   
 static void _fill(Request& r, MethodParams* params) {  static void _fill(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 864  static void _fill(Request& r, MethodPara Line 862  static void _fill(Request& r, MethodPara
                         "does not contain an image");                          "does not contain an image");
   
         image->Fill(          image->Fill(
                 params->as_int(0, "x must be int", r),                   params.as_int(0, "x must be int", r), 
                 params->as_int(1, "y must be int", r),                   params.as_int(1, "y must be int", r), 
                 image->Color(params->as_int(2, "color must be int", r)));                  image->Color(params.as_int(2, "color must be int", r)));
 }  }
   
 static void _rectangle(Request& r, MethodParams* params) {  static void _rectangle(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 878  static void _rectangle(Request& r, Metho Line 876  static void _rectangle(Request& r, Metho
                         "does not contain an image");                          "does not contain an image");
   
         image->Rectangle(          image->Rectangle(
                 params->as_int(0, "x0 must be int", r),                   params.as_int(0, "x0 must be int", r), 
                 params->as_int(1, "y0 must be int", r),                   params.as_int(1, "y0 must be int", r), 
                 params->as_int(2, "x1 must be int", r),                   params.as_int(2, "x1 must be int", r), 
                 params->as_int(3, "y1 must be int", r),                   params.as_int(3, "y1 must be int", r), 
                 image->Color(params->as_int(4, "color must be int", r)));                  image->Color(params.as_int(4, "color must be int", r)));
 }  }
   
 static void _bar(Request& r, MethodParams* params) {  static void _bar(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 894  static void _bar(Request& r, MethodParam Line 892  static void _bar(Request& r, MethodParam
                         "does not contain an image");                          "does not contain an image");
   
         image->FilledRectangle(          image->FilledRectangle(
                 params->as_int(0, "x0 must be int", r),                   params.as_int(0, "x0 must be int", r), 
                 params->as_int(1, "y0 must be int", r),                   params.as_int(1, "y0 must be int", r), 
                 params->as_int(2, "x1 must be int", r),                   params.as_int(2, "x1 must be int", r), 
                 params->as_int(3, "y1 must be int", r),                   params.as_int(3, "y1 must be int", r), 
                 image->Color(params->as_int(4, "color must be int", r)));                  image->Color(params.as_int(4, "color must be int", r)));
 }  }
   
 #ifndef DOXYGEN  #ifndef DOXYGEN
Line 909  static void add_point(Table::element_typ Line 907  static void add_point(Table::element_typ
         (*p)++;          (*p)++;
 }  }
 #endif  #endif
 static void _replace(Request& r, MethodParams* params) {  static void _replace(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 917  static void _replace(Request& r, MethodP Line 915  static void _replace(Request& r, MethodP
                         0,                           0, 
                         "does not contain an image");                          "does not contain an image");
   
         Table* table=params->as_no_junction(2, "coordinates must not be code").get_table();          Table* table=params.as_no_junction(2, "coordinates must not be code").get_table();
         if(!table)           if(!table) 
                 throw Exception(0,                  throw Exception(0,
                         0,                          0,
Line 927  static void _replace(Request& r, MethodP Line 925  static void _replace(Request& r, MethodP
         gdImage::Point *add_p=all_p;              gdImage::Point *add_p=all_p;    
         table->for_each(add_point, &add_p);          table->for_each(add_point, &add_p);
         image->FilledPolygonReplaceColor(all_p, table->count(),           image->FilledPolygonReplaceColor(all_p, table->count(), 
                 image->Color(params->as_int(0, "src color must be int", r)),                  image->Color(params.as_int(0, "src color must be int", r)),
                 image->Color(params->as_int(1, "dest color must be int", r)));                  image->Color(params.as_int(1, "dest color must be int", r)));
 }  }
   
 static void _polyline(Request& r, MethodParams* params) {  static void _polyline(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 939  static void _polyline(Request& r, Method Line 937  static void _polyline(Request& r, Method
                         0,                           0, 
                         "does not contain an image");                          "does not contain an image");
   
         Table* table=params->as_no_junction(1, "coordinates must not be code").get_table();          Table* table=params.as_no_junction(1, "coordinates must not be code").get_table();
         if(!table)           if(!table) 
                 throw Exception(0,                  throw Exception(0,
                         0,                          0,
Line 949  static void _polyline(Request& r, Method Line 947  static void _polyline(Request& r, Method
         gdImage::Point *add_p=all_p;              gdImage::Point *add_p=all_p;    
         table->for_each(add_point, &add_p);          table->for_each(add_point, &add_p);
         image->Polygon(all_p, table->count(),           image->Polygon(all_p, table->count(), 
                 image->Color(params->as_int(0, "color must be int", r)),                  image->Color(params.as_int(0, "color must be int", r)),
                 false/*not closed*/);                  false/*not closed*/);
 }  }
   
 static void _polygon(Request& r, MethodParams* params) {  static void _polygon(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 961  static void _polygon(Request& r, MethodP Line 959  static void _polygon(Request& r, MethodP
                         0,                           0, 
                         "does not contain an image");                          "does not contain an image");
   
         Table* table=params->as_no_junction(1, "coordinates must not be code").get_table();          Table* table=params.as_no_junction(1, "coordinates must not be code").get_table();
         if(!table)           if(!table) 
                 throw Exception(0,                  throw Exception(0,
                         0,                          0,
Line 971  static void _polygon(Request& r, MethodP Line 969  static void _polygon(Request& r, MethodP
         gdImage::Point *add_p=all_p;              gdImage::Point *add_p=all_p;    
         table->for_each(add_point, &add_p);          table->for_each(add_point, &add_p);
         image->Polygon(all_p, table->count(),           image->Polygon(all_p, table->count(), 
                 image->Color(params->as_int(0, "color must be int", r)));                  image->Color(params.as_int(0, "color must be int", r)));
 }  }
   
 static void _polybar(Request& r, MethodParams* params) {  static void _polybar(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
Line 982  static void _polybar(Request& r, MethodP Line 980  static void _polybar(Request& r, MethodP
                         0,                           0, 
                         "does not contain an image");                          "does not contain an image");
   
         Table* table=params->as_no_junction(1, "coordinates must not be code").get_table();          Table* table=params.as_no_junction(1, "coordinates must not be code").get_table();
         if(!table)           if(!table) 
                 throw Exception("parser.runtime",                  throw Exception("parser.runtime",
                         0,                          0,
Line 992  static void _polybar(Request& r, MethodP Line 990  static void _polybar(Request& r, MethodP
         gdImage::Point *add_p=all_p;              gdImage::Point *add_p=all_p;    
         table->for_each(add_point, &add_p);          table->for_each(add_point, &add_p);
         image->FilledPolygon(all_p, table->count(),           image->FilledPolygon(all_p, table->count(), 
                 image->Color(params->as_int(0, "color must be int", r)));                  image->Color(params.as_int(0, "color must be int", r)));
 }  }
   
 // font  // font
Line 1013  Font::Font(//, Line 1011  Font::Font(//,
   
 /* ******************************** char ********************************** */  /* ******************************** char ********************************** */
   
 int Font::index_of(char ch) {  size_t Font::index_of(char ch) {
         if(ch==' ') return -1;          if(ch==' ') return STRING_NOT_FOUND;
         return alphabet.pos(&ch, 1);          return alphabet.pos(ch);
 }  }
   
 int Font::index_width(int index) {  int Font::index_width(size_t index) {
         if(index<0)          if(index==STRING_NOT_FOUND)
                 return spacebarspace;                  return spacebarspace;
         int tr=ifont->GetTransparent();          int tr=ifont->GetTransparent();
         for(int x=ifont->SX()-1; x>=0; x--) {          for(int x=ifont->SX()-1; x>=0; x--) {
Line 1030  int Font::index_width(int index) { Line 1028  int Font::index_width(int index) {
         return 0;          return 0;
 }  }
   
 void Font::index_display(gdImage* image, int x, int y, int index){  void Font::index_display(gdImage* image, int x, int y, size_t index){
         if(index>=0)           if(index!=STRING_NOT_FOUND) 
                 ifont->Copy(*image, x, y, 0, Y(0), index_width(index), height);                  ifont->Copy(*image, x, y, 0, Y(0), index_width(index), height);
 }  }
   
Line 1053  int Font::string_width(const String& s){ Line 1051  int Font::string_width(const String& s){
 void Font::string_display(gdImage* image, int x, int y, const String& s){  void Font::string_display(gdImage* image, int x, int y, const String& s){
         const char* cstr=s.cstr();          const char* cstr=s.cstr();
         for(const char* current=cstr; *current; current++) {          for(const char* current=cstr; *current; current++) {
                 int index=index_of(*current);                  size_t index=index_of(*current);
                 index_display(image, x, y, index);                  index_display(image, x, y, index);
                 x+=step_width(index);                  x+=step_width(index);
         }          }
Line 1062  void Font::string_display(gdImage* image Line 1060  void Font::string_display(gdImage* image
 //  //
   
   
 static void _font(Request& r, MethodParams* params) {  static void _font(Request& r, MethodParams& params) {
           const String& alphabet=params.as_string(0, "alphabet must not be code");
         const String& alphabet=params->as_string(0, "alphabet must not be code");          gdImage* image=load(r, params.as_string(1, "file_name must not be code"));
         gdImage* image=load(r, params->as_string(1, "file_name must not be code"));          int spacebar_width=params.as_int(2, "spacebar_width must be int", r);
         int spacebar_width=params->as_int(2, "spacebar_width must be int", r);  
         int monospace_width;          int monospace_width;
         if(params->count()>3) {          if(params.count()>3) {
                 monospace_width=params->as_int(3, "monospace_width must be int", r);                  monospace_width=params.as_int(3, "monospace_width must be int", r);
                 if(!monospace_width)                  if(!monospace_width)
                         monospace_width=image->SX();                          monospace_width=image->SX();
         } else          } else
Line 1092  static void _font(Request& r, MethodPara Line 1089  static void _font(Request& r, MethodPara
                 image->SY() / alphabet.length(), monospace_width, spacebar_width);                  image->SY() / alphabet.length(), monospace_width, spacebar_width);
 }  }
   
 static void _text(Request& r, MethodParams* params) {  static void _text(Request& r, MethodParams& params) {
           int x=params.as_int(0, "x must be int", r);
         int x=params->as_int(0, "x must be int", r);          int y=params.as_int(1, "y must be int", r);
         int y=params->as_int(1, "y must be int", r);          const String& s=params.as_string(2, "text must not be code");
         const String& s=params->as_string(2, "text must not be code");  
   
         VImage& vimage=GET_SELF(r, VImage);          VImage& vimage=GET_SELF(r, VImage);
         if(vimage.image)          if(vimage.image)
Line 1112  static void _text(Request& r, MethodPara Line 1108  static void _text(Request& r, MethodPara
                         "does not contain an image");                          "does not contain an image");
 }  }
   
 static void _length(Request& r, MethodParams* params) {  static void _length(Request& r, MethodParams& params) {
           const String& s=params.as_string(0, "text must not be code");
         const String& s=params->as_string(0, "text must not be code");  
   
         VImage& vimage=GET_SELF(r, VImage);          VImage& vimage=GET_SELF(r, VImage);
         if(vimage.image)          if(vimage.image)
Line 1130  static void _length(Request& r, MethodPa Line 1125  static void _length(Request& r, MethodPa
                         "does not contain an image");                          "does not contain an image");
 }  }
   
 static void _arc(Request& r, MethodParams* params) {  static void _arc(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
                 throw Exception(0,                   throw Exception(0, 
Line 1139  static void _arc(Request& r, MethodParam Line 1133  static void _arc(Request& r, MethodParam
                         "does not contain an image");                          "does not contain an image");
   
         image->Arc(          image->Arc(
                 params->as_int(0, "center_x must be int", r),                   params.as_int(0, "center_x must be int", r), 
                 params->as_int(1, "center_y must be int", r),                   params.as_int(1, "center_y must be int", r), 
                 params->as_int(2, "width must be int", r),                   params.as_int(2, "width must be int", r), 
                 params->as_int(3, "height must be int", r),                   params.as_int(3, "height must be int", r), 
                 params->as_int(4, "start degrees must be int", r),                   params.as_int(4, "start degrees must be int", r), 
                 params->as_int(5, "end degrees must be int", r),                   params.as_int(5, "end degrees must be int", r), 
                 image->Color(params->as_int(6, "cx must be int", r)));                  image->Color(params.as_int(6, "cx must be int", r)));
 }  }
   
 static void _sector(Request& r, MethodParams* params) {  static void _sector(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
                 throw Exception(0,                   throw Exception(0, 
Line 1157  static void _sector(Request& r, MethodPa Line 1150  static void _sector(Request& r, MethodPa
                         "does not contain an image");                          "does not contain an image");
   
         image->Sector(          image->Sector(
                 params->as_int(0, "center_x must be int", r),                   params.as_int(0, "center_x must be int", r), 
                 params->as_int(1, "center_y must be int", r),                   params.as_int(1, "center_y must be int", r), 
                 params->as_int(2, "width must be int", r),                   params.as_int(2, "width must be int", r), 
                 params->as_int(3, "height must be int", r),                   params.as_int(3, "height must be int", r), 
                 params->as_int(4, "start degrees must be int", r),                   params.as_int(4, "start degrees must be int", r), 
                 params->as_int(5, "end degrees must be int", r),                   params.as_int(5, "end degrees must be int", r), 
                 image->Color(params->as_int(6, "color must be int", r)));                  image->Color(params.as_int(6, "color must be int", r)));
 }  }
   
 static void _circle(Request& r, MethodParams* params) {  static void _circle(Request& r, MethodParams& params) {
   
         gdImage* image=GET_SELF(r, VImage).image;          gdImage* image=GET_SELF(r, VImage).image;
         if(!image)          if(!image)
                 throw Exception(0,                   throw Exception(0, 
                         0,                           0, 
                         "does not contain an image");                          "does not contain an image");
   
         int size=params->as_int(2, "radius must be int", r)*2;          int size=params.as_int(2, "radius must be int", r)*2;
         image->Arc(          image->Arc(
                 params->as_int(0, "center_x must be int", r),                   params.as_int(0, "center_x must be int", r), 
                 params->as_int(1, "center_y must be int", r),                   params.as_int(1, "center_y must be int", r), 
                 size, //w                  size, //w
                 size, //h                  size, //h
                 0, //s                  0, //s
                 360, //e                  360, //e
                 image->Color(params->as_int(3, "color must be int", r)));                  image->Color(params.as_int(3, "color must be int", r)));
 }  }
   
 gdImage* as_image(MethodParams* params, int index, const char* msg) {  gdImage* as_image(MethodParams& params, int index, const char* msg) {
         gdImage* src=0;          gdImage* src=0;
   
         Value& value=params->as_no_junction(index, msg);          Value& value=params.as_no_junction(index, msg);
   
         if(Value* vimage=value.as(VIMAGE_TYPE, false)) {          if(Value* vimage=value.as(VIMAGE_TYPE, false)) {
                 src=static_cast<VImage *>(vimage)->image;                  src=static_cast<VImage *>(vimage)->image;
Line 1204  gdImage* as_image(MethodParams* params, Line 1196  gdImage* as_image(MethodParams* params,
         return src;          return src;
 }  }
   
 static void _copy(Request& r, MethodParams* params) {  static void _copy(Request& r, MethodParams& params) {
   
         gdImage* dest=GET_SELF(r, VImage).image;          gdImage* dest=GET_SELF(r, VImage).image;
         if(!dest)          if(!dest)
                 throw Exception(0,                   throw Exception(0, 
Line 1214  static void _copy(Request& r, MethodPara Line 1205  static void _copy(Request& r, MethodPara
   
         gdImage* src=as_image(params, 0, "src must be image");          gdImage* src=as_image(params, 0, "src must be image");
   
         int sx=params->as_int(1, "src_x must be int", r);          int sx=params.as_int(1, "src_x must be int", r);
         int sy=params->as_int(2, "src_y must be int", r);          int sy=params.as_int(2, "src_y must be int", r);
         int sw=params->as_int(3, "src_w must be int", r);          int sw=params.as_int(3, "src_w must be int", r);
         int sh=params->as_int(4, "src_h must be int", r);          int sh=params.as_int(4, "src_h must be int", r);
         int dx=params->as_int(5, "dest_x must be int", r);          int dx=params.as_int(5, "dest_x must be int", r);
         int dy=params->as_int(6, "dest_y must be int", r);          int dy=params.as_int(6, "dest_y must be int", r);
         if(params->count()>1+2+2+2) {          if(params.count()>1+2+2+2) {
                 int dw=params->as_int(1+2+2+2, "dest_w must be int", r);                  int dw=params.as_int(1+2+2+2, "dest_w must be int", r);
                 int dh=(int)(params->count()>1+2+2+2+1?                  int dh=(int)(params.count()>1+2+2+2+1?
                         params->as_int(1+2+2+2+1, "dest_h must be int", r):sh*(((double)dw)/((double)sw)));                          params.as_int(1+2+2+2+1, "dest_h must be int", r):sh*(((double)dw)/((double)sw)));
                 int tolerance=params->count()>1+2+2+2+2?                  int tolerance=params.count()>1+2+2+2+2?
                         params->as_int(1+2+2+2+2, "tolerance must be int", r):150;                          params.as_int(1+2+2+2+2, "tolerance must be int", r):150;
   
                 src->CopyResampled(*dest, dx, dy, sx, sy, dw, dh, sw, sh, tolerance);                  src->CopyResampled(*dest, dx, dy, sx, sy, dw, dh, sw, sh, tolerance);
         } else          } else

Removed from v.1.90.2.15.2.12  
changed lines
  Added in v.1.91


E-mail: