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

version 1.91, 2003/07/24 11:31:20 version 1.98, 2003/11/20 15:35:29
Line 33  static const char* IDENT_IMAGE_C="$Date$ Line 33  static const char* IDENT_IMAGE_C="$Date$
   
 class MImage: public Methoded {  class MImage: public Methoded {
 public: // VStateless_class  public: // VStateless_class
         Value* create_new_value() { return new VImage(); }          Value* create_new_value(Pool&) { return new VImage(); }
   
 public:  public:
         MImage();          MImage();
Line 410  static Value* parse_IFD_entry_formatted_ Line 410  static Value* parse_IFD_entry_formatted_
                         strcpy(cstr_writable, cstr);                          strcpy(cstr_writable, cstr);
   
                         time_t t=cstr_to_time_t(cstr_writable,                           time_t t=cstr_to_time_t(cstr_writable, 
                                 0/* do not throw exception, just return bad result */);                                  false/* do not throw exception, just return bad result */);
                         if(t>=0)                          if(t>=0)
                                 return new VDate(t);                                  return new VDate(t);
                 }                  }
Line 427  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::Format(i),                          String::Body::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 512  static void parse_IFD_entry(HashStringVa Line 512  static void parse_IFD_entry(HashStringVa
                   
         if(Value* value=parse_IFD_entry_value(is_big, reader, tiff_base, entry)) {          if(Value* value=parse_IFD_entry_value(is_big, reader, tiff_base, entry)) {
                 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(String::Body(name), value);
                 else                  else
                         hash.put(StringBody::Format(tag), value);                          hash.put(String::Body::Format(tag), value);
         }          }
 }  }
   
Line 687  struct File_measure_action_info { Line 687  struct File_measure_action_info {
 };  };
 #endif  #endif
 static void file_measure_action(  static void file_measure_action(
                                                                 struct stat& finfo, int f,                                                                   struct stat& /*finfo*/, int f, 
                                                                 const String& file_spec, const char* fname, bool as_text,                                                                  const String& /*file_spec*/, const char* fname, bool /*as_text*/,
                                                                 void *context) {                                                                  void *context) {
         File_measure_action_info& info=*static_cast<File_measure_action_info *>(context);          File_measure_action_info& info=*static_cast<File_measure_action_info *>(context);
   
Line 792  static gdImage* load(Request& r, Line 792  static gdImage* load(Request& r,
                 throw Exception("file.missing",                   throw Exception("file.missing", 
                         0,                           0, 
                         "can not open '%s'", file_name_cstr);                          "can not open '%s'", file_name_cstr);
                 return 0;  
         }          }
 }  }
   
Line 805  static void _load(Request& r, MethodPara Line 804  static void _load(Request& r, MethodPara
 }  }
   
 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;
Line 818  static void _create(Request& r, MethodPa Line 816  static void _create(Request& r, MethodPa
 }  }
   
 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)
                 throw Exception(0,                   throw Exception(0, 
                         0,                           0, 
                         "does not contain an image");                          "does not contain an image");
   
         // could _ but don't thing it's wise to use $image.src for vfile.name          const String *file_name=0;
           if(params.count()>0)
                   file_name=&params.as_string(0, "file name must be string");
   
         gdBuf buf=image->Gif();          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*/, 
                 (const char*)buf.ptr, buf.size, 0, content_type);                  (const char*)buf.ptr, buf.size, 
                   file_name? file_name->cstr(String::L_FILE_SPEC): 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)
                 throw Exception(0,                   throw Exception(0, 
Line 854  static void _line(Request& r, MethodPara Line 854  static void _line(Request& r, MethodPara
 }  }
   
 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)
                 throw Exception(0,                   throw Exception(0, 
Line 868  static void _fill(Request& r, MethodPara Line 867  static void _fill(Request& r, MethodPara
 }  }
   
 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)
                 throw Exception(0,                   throw Exception(0, 
Line 884  static void _rectangle(Request& r, Metho Line 882  static void _rectangle(Request& r, Metho
 }  }
   
 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)
                 throw Exception(0,                   throw Exception(0, 
Line 908  static void add_point(Table::element_typ Line 905  static void add_point(Table::element_typ
 }  }
 #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)
                 throw Exception(0,                   throw Exception(0, 
Line 921  static void _replace(Request& r, MethodP Line 917  static void _replace(Request& r, MethodP
                         0,                          0,
                         "coordinates must be table");                          "coordinates must be table");
   
         gdImage::Point *all_p=new gdImage::Point[table->count()];          gdImage::Point *all_p=new(PointerFreeGC) gdImage::Point[table->count()];
         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(), 
Line 930  static void _replace(Request& r, MethodP Line 926  static void _replace(Request& r, MethodP
 }  }
   
 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)
                 throw Exception(0,                   throw Exception(0, 
Line 943  static void _polyline(Request& r, Method Line 938  static void _polyline(Request& r, Method
                         0,                          0,
                         "coordinates must be table");                          "coordinates must be table");
   
         gdImage::Point* all_p=new gdImage::Point[table->count()];          gdImage::Point* all_p=new(PointerFreeGC) gdImage::Point[table->count()];
         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(), 
Line 952  static void _polyline(Request& r, Method Line 947  static void _polyline(Request& r, Method
 }  }
   
 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)
                 throw Exception(0,                   throw Exception(0, 
Line 965  static void _polygon(Request& r, MethodP Line 959  static void _polygon(Request& r, MethodP
                         0,                          0,
                         "coordinates must be table");                          "coordinates must be table");
   
         gdImage::Point* all_p=new gdImage::Point[table->count()];          gdImage::Point* all_p=new(PointerFreeGC) gdImage::Point[table->count()];
         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(), 
Line 973  static void _polygon(Request& r, MethodP Line 967  static void _polygon(Request& r, MethodP
 }  }
   
 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)
                 throw Exception(0,                   throw Exception(0, 
Line 986  static void _polybar(Request& r, MethodP Line 979  static void _polybar(Request& r, MethodP
                         0,                          0,
                         "coordinates must be table");                          "coordinates must be table");
   
         gdImage::Point* all_p=new gdImage::Point[table->count()];          gdImage::Point* all_p=new(PointerFreeGC) gdImage::Point[table->count()];
         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(), 
Line 1242  MImage::MImage(): Methoded("image") { Line 1235  MImage::MImage(): Methoded("image") {
         add_native_method("create", Method::CT_DYNAMIC, _create, 2, 3);          add_native_method("create", Method::CT_DYNAMIC, _create, 2, 3);
   
         // ^image.gif[]          // ^image.gif[]
         add_native_method("gif", Method::CT_DYNAMIC, _gif, 0, 0);          add_native_method("gif", Method::CT_DYNAMIC, _gif, 0, 1);
   
         // ^image.line(x0;y0;x1;y1;color)          // ^image.line(x0;y0;x1;y1;color)
         add_native_method("line", Method::CT_DYNAMIC, _line, 5, 5);          add_native_method("line", Method::CT_DYNAMIC, _line, 5, 5);

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


E-mail: