--- parser3/src/classes/image.C 2003/01/31 12:34:26 1.90.2.3 +++ parser3/src/classes/image.C 2003/03/17 14:48:04 1.90.4.1 @@ -1,11 +1,11 @@ /** @file Parser: @b image parser class. - Copyright(c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright(c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_IMAGE_C="$Date: 2003/01/31 12:34:26 $"; +static const char* IDENT_IMAGE_C="$Date: 2003/03/17 14:48:04 $"; /* jpegsize: gets the width and height (in pixels) of a jpeg file @@ -30,7 +30,7 @@ static const char* IDENT_IMAGE_C="$Date: class MImage : public Methoded { public: // VStateless_class - ValuePtr create_new_value() { return ValuePtr(new VImage()); } + Value *create_new_value(Pool& pool) { return new(pool) VImage(pool); } public: MImage(Pool& pool); @@ -42,10 +42,6 @@ public: // Methoded // helpers -/// value of exif tag -> it's value -Hash exif_tag_value2name; - - #ifndef DOXYGEN class Measure_reader { public: @@ -56,7 +52,7 @@ public: class Measure_file_reader: public Measure_reader { public: - Measure_file_reader(Pool& apool, int af, const String& afile_name, const char* afname): + Measure_file_reader(Pool& apool, int af, const String& afile_name, const char *afname): pool(apool), file_name(afile_name), fname(afname), f(af) { } @@ -64,7 +60,7 @@ public: if(limit==0) return 0; - void *lbuf=pool.malloc(limit); + void *lbuf=pool.malloc_atomic(limit); size_t read_size=(size_t)::read(f, lbuf, limit); abuf=lbuf; if(ssize_t(read_size)<0 || read_size>limit) throw Exception(0, @@ -87,7 +83,7 @@ public: private: Pool& pool; - const String& file_name; const char* fname; + const String& file_name; const char *fname; int f; }; @@ -290,7 +286,7 @@ static Value *parse_IFD_entry_formatted_ size_t component_size, uint components_count, const uchar *value) { 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; // Data format is "YYYY:MM:DD HH:MM:SS"+0x00, total 20bytes if(size==JPEG_EXIF_DATE_CHARS @@ -304,7 +300,7 @@ static Value *parse_IFD_entry_formatted_ return new(pool) VDate(pool, t); } - if(const char* premature_zero_pos=(const char* )memchr(cstr, 0, size)) + if(const char *premature_zero_pos=(const char *)memchr(cstr, 0, size)) size=premature_zero_pos-cstr; return new(pool) VString(*new(pool) String(pool, cstr, size, true/*tainted*/)); } @@ -317,7 +313,7 @@ static Value *parse_IFD_entry_formatted_ for(uint i=0; iget(skey)) + if(const char *name=(const char *)exif_tag_value2name->get(skey)) hash.put(*new(pool) String(pool, name), value); else hash.put(skey, value); @@ -560,7 +556,7 @@ static void measure_png(Pool& pool, cons static void measure(Pool& pool, const String& file_name, Measure_reader& reader, ushort& width, ushort& height, Value ** exif) { - if(const char* cext=strrchr(file_name.cstr(String::UL_FILE_SPEC), '.')) { + if(const char *cext=strrchr(file_name.cstr(String::UL_FILE_SPEC), '.')) { cext++; if(strcasecmp(cext, "GIF")==0) measure_gif(pool, &file_name, reader, width, height); @@ -590,7 +586,7 @@ struct File_measure_action_info { #endif static void file_measure_action(Pool& pool, 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) { File_measure_action_info& info=*static_cast(context); @@ -680,7 +676,7 @@ static gdImage *load(Request& r, const S const String& file_name){ Pool& pool=r.pool(); - const char* file_name_cstr=r.absolute(file_name).cstr(String::UL_FILE_SPEC); + const char *file_name_cstr=r.absolute(file_name).cstr(String::UL_FILE_SPEC); if(FILE *f=fopen(file_name_cstr, "rb")) { gdImage& image=*new(pool) gdImage(pool); bool ok=image.CreateFromGif(f); @@ -836,7 +832,7 @@ static void _replace(Request& r, const S &method_name, "coordinates must be table"); - gdImage::Point *all_p=(gdImage::Point *)pool.malloc(sizeof(gdImage::Point)*table->size()); + gdImage::Point *all_p=(gdImage::Point *)pool.malloc_atomic(sizeof(gdImage::Point)*table->size()); gdImage::Point *add_p=all_p; table->for_each(add_point, &add_p); image->FilledPolygonReplaceColor(all_p, table->size(), @@ -859,7 +855,7 @@ static void _polyline(Request& r, const &method_name, "coordinates must be table"); - gdImage::Point *all_p=(gdImage::Point *)pool.malloc(sizeof(gdImage::Point)*table->size()); + gdImage::Point *all_p=(gdImage::Point *)pool.malloc_atomic(sizeof(gdImage::Point)*table->size()); gdImage::Point *add_p=all_p; table->for_each(add_point, &add_p); image->Polygon(all_p, table->size(), @@ -882,7 +878,7 @@ static void _polygon(Request& r, const S &method_name, "coordinates must be table"); - gdImage::Point *all_p=(gdImage::Point *)pool.malloc(sizeof(gdImage::Point)*table->size()); + gdImage::Point *all_p=(gdImage::Point *)pool.malloc_atomic(sizeof(gdImage::Point)*table->size()); gdImage::Point *add_p=all_p; table->for_each(add_point, &add_p); image->Polygon(all_p, table->size(), @@ -904,7 +900,7 @@ static void _polybar(Request& r, const S &method_name, "coordinates must be table"); - gdImage::Point *all_p=(gdImage::Point *)pool.malloc(sizeof(gdImage::Point)*table->size()); + gdImage::Point *all_p=(gdImage::Point *)pool.malloc_atomic(sizeof(gdImage::Point)*table->size()); gdImage::Point *add_p=all_p; table->for_each(add_point, &add_p); image->FilledPolygon(all_p, table->size(), @@ -966,7 +962,7 @@ public: // counts trailing letter_spacing, consider this OK. useful for contiuations int string_width(const String& s){ - const char* cstr=s.cstr(); + const char *cstr=s.cstr(); int result=0; for(; *cstr; cstr++) result+=step_width(index_of(*cstr)); @@ -974,7 +970,7 @@ public: } void string_display(gdImage& image, int x, int y, const String& s){ - const char* cstr=s.cstr(); + const char *cstr=s.cstr(); if(cstr) for(; *cstr; cstr++) { int index=index_of(*cstr); index_display(image, x, y, index); @@ -1115,7 +1111,7 @@ static void _circle(Request& r, const St } gdImage& as_image(Pool& pool, const String& method_name, MethodParams *params, - int index, const char* msg) { + int index, const char *msg) { gdImage *src=0; Value& value=params->as_no_junction(index, msg); @@ -1238,101 +1234,5 @@ Methoded *image_class; // creator Methoded *MImage_create(Pool& pool) { - // image JPEG Exif - #define EXIF_TAG(tag, name) \ - exif_tag_value2name.put(tag, #name); - // Tags used by IFD0 (main image) - EXIF_TAG(0x010e, ImageDescription); - EXIF_TAG(0x010f, Make); - EXIF_TAG(0x0110, Model); - EXIF_TAG(0x0112, Orientation); - EXIF_TAG(0x011a, XResolution); - EXIF_TAG(0x011b, YResolution); - EXIF_TAG(0x0128, ResolutionUnit); - EXIF_TAG(0x0131, Software); - EXIF_TAG(0x0132, DateTime); - EXIF_TAG(0x013e, WhitePoint); - EXIF_TAG(0x013f, PrimaryChromaticities); - EXIF_TAG(0x0211, YCbCrCoefficients); - EXIF_TAG(0x0213, YCbCrPositioning); - EXIF_TAG(0x0214, ReferenceBlackWhite); - EXIF_TAG(0x8298, Copyright); - EXIF_TAG(0x8769, ExifOffset); - // Tags used by Exif SubIFD - EXIF_TAG(0x829a, ExposureTime); - EXIF_TAG(0x829d, FNumber); - EXIF_TAG(0x8822, ExposureProgram); - EXIF_TAG(0x8827, ISOSpeedRatings); - EXIF_TAG(0x9000, ExifVersion); - EXIF_TAG(0x9003, DateTimeOriginal); - EXIF_TAG(0x9004, DateTimeDigitized); - EXIF_TAG(0x9101, ComponentsConfiguration); - EXIF_TAG(0x9102, CompressedBitsPerPixel); - EXIF_TAG(0x9201, ShutterSpeedValue); - EXIF_TAG(0x9202, ApertureValue); - EXIF_TAG(0x9203, BrightnessValue); - EXIF_TAG(0x9204, ExposureBiasValue); - EXIF_TAG(0x9205, MaxApertureValue); - EXIF_TAG(0x9206, SubjectDistance); - EXIF_TAG(0x9207, MeteringMode); - EXIF_TAG(0x9208, LightSource); - EXIF_TAG(0x9209, Flash); - EXIF_TAG(0x920a, FocalLength); - EXIF_TAG(0x927c, MakerNote); - EXIF_TAG(0x9286, UserComment); - EXIF_TAG(0x9290, SubsecTime); - EXIF_TAG(0x9291, SubsecTimeOriginal); - EXIF_TAG(0x9292, SubsecTimeDigitized); - EXIF_TAG(0xa000, FlashPixVersion); - EXIF_TAG(0xa001, ColorSpace); - EXIF_TAG(0xa002, ExifImageWidth); - EXIF_TAG(0xa003, ExifImageHeight); - EXIF_TAG(0xa004, RelatedSoundFile); - EXIF_TAG(0xa005, ExifInteroperabilityOffset); - EXIF_TAG(0xa20e, FocalPlaneXResolution); - EXIF_TAG(0xa20f, FocalPlaneYResolution); - EXIF_TAG(0xa210, FocalPlaneResolutionUnit); - EXIF_TAG(0xa215, ExposureIndex); - EXIF_TAG(0xa217, SensingMethod); - EXIF_TAG(0xa300, FileSource); - EXIF_TAG(0xa301, SceneType); - EXIF_TAG(0xa302, CFAPattern); - // Misc Tags - EXIF_TAG(0x00fe, NewSubfileType); - EXIF_TAG(0x00ff, SubfileType); - EXIF_TAG(0x012d, TransferFunction); - EXIF_TAG(0x013b, Artist); - EXIF_TAG(0x013d, Predictor); - EXIF_TAG(0x0142, TileWidth); - EXIF_TAG(0x0143, TileLength); - EXIF_TAG(0x0144, TileOffsets); - EXIF_TAG(0x0145, TileByteCounts); - EXIF_TAG(0x014a, SubIFDs); - EXIF_TAG(0x015b, JPEGTables); - EXIF_TAG(0x828d, CFARepeatPatternDim); - EXIF_TAG(0x828e, CFAPattern); - EXIF_TAG(0x828f, BatteryLevel); - EXIF_TAG(0x83bb, IPTC/NAA); - EXIF_TAG(0x8773, InterColorProfile); - EXIF_TAG(0x8824, SpectralSensitivity); - EXIF_TAG(0x8825, GPSInfo); - EXIF_TAG(0x8828, OECF); - EXIF_TAG(0x8829, Interlace); - EXIF_TAG(0x882a, TimeZoneOffset); - EXIF_TAG(0x882b, SelfTimerMode); - EXIF_TAG(0x920b, FlashEnergy); - EXIF_TAG(0x920c, SpatialFrequencyResponse); - EXIF_TAG(0x920d, Noise); - EXIF_TAG(0x9211, ImageNumber); - EXIF_TAG(0x9212, SecurityClassification); - EXIF_TAG(0x9213, ImageHistory); - EXIF_TAG(0x9214, SubjectLocation); - EXIF_TAG(0x9215, ExposureIndex); - EXIF_TAG(0x9216, TIFF/EPStandardID); - EXIF_TAG(0xa20b, FlashEnergy); - EXIF_TAG(0xa20c, SpatialFrequencyResponse); - EXIF_TAG(0xa214, SubjectLocation); - #undef EXIF_TAG - return image_class=new(pool) MImage(pool); }