|
|
| version 1.185, 2024/09/11 21:07:36 | version 1.192, 2024/11/10 20:46:08 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b image parser class. | Parser: @b image parser class. |
| Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) |
| Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| Line 189 public: | Line 189 public: |
| EXIF_TAG(0xa434, LensModel); | EXIF_TAG(0xa434, LensModel); |
| EXIF_TAG(0xa435, LensSerialNumber); | EXIF_TAG(0xa435, LensSerialNumber); |
| } | } |
| } exif_tag_value2name; | |
| static EXIF_tag_value2name &instance(){ | |
| static EXIF_tag_value2name *singleton=NULL; | |
| if(!singleton) | |
| singleton=new EXIF_tag_value2name; | |
| return *singleton; | |
| } | |
| }; | |
| class EXIF_gps_tag_value2name: public Hash<int, const char*> { | class EXIF_gps_tag_value2name: public Hash<int, const char*> { |
| public: | public: |
| Line 226 public: | Line 233 public: |
| EXIF_TAG(0x1D, GPSDateStamp); | EXIF_TAG(0x1D, GPSDateStamp); |
| EXIF_TAG(0x1E, GPSDifferential); | EXIF_TAG(0x1E, GPSDifferential); |
| } | } |
| } exif_gps_tag_value2name; | |
| static EXIF_gps_tag_value2name &instance(){ | |
| static EXIF_gps_tag_value2name *singleton=NULL; | |
| if(!singleton) | |
| singleton=new EXIF_gps_tag_value2name; | |
| return *singleton; | |
| } | |
| }; | |
| ///*********************************************** support functions | ///*********************************************** support functions |
| Line 512 static void parse_IFD_entry(HashStringVa | Line 527 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=(gps)?exif_gps_tag_value2name.get(tag):exif_tag_value2name.get(tag)) | if(const char* name=(gps ? EXIF_gps_tag_value2name::instance().get(tag) : EXIF_tag_value2name::instance().get(tag))) |
| hash.put(name, value); | hash.put(name, value); |
| else | else |
| hash.put(pa_uitoa(tag), value); | hash.put(pa_uitoa((int)tag), value); |
| } | } |
| } | } |
| Line 629 static void measure_jpeg(const String& o | Line 644 static void measure_jpeg(const String& o |
| { | { |
| // Segments that contain size info | // Segments that contain size info |
| if(reader.read(buf, sizeof(JPG_Size_segment_body))<sizeof(JPG_Size_segment_body)) | if(reader.read(buf, sizeof(JPG_Size_segment_body))<sizeof(JPG_Size_segment_body)) |
| throw Exception(IMAGE_FORMAT, &origin_string, "not JPEG file - can not fully read Size segment"); | throw Exception(IMAGE_FORMAT, &origin_string, "not JPEG file - cannot fully read Size segment"); |
| JPG_Size_segment_body *body=(JPG_Size_segment_body *)buf; | JPG_Size_segment_body *body=(JPG_Size_segment_body *)buf; |
| info.width=endian_to_ushort(true, body->width); | info.width=endian_to_ushort(true, body->width); |
| Line 960 static void measure(const String& file_n | Line 975 static void measure(const String& file_n |
| else | else |
| throw Exception(IMAGE_FORMAT, &file_name, "unhandled file name extension '%s'", cext); | throw Exception(IMAGE_FORMAT, &file_name, "unhandled file name extension '%s'", cext); |
| } else | } else |
| throw Exception(IMAGE_FORMAT, &file_name, "can not determine file type - no file name extension"); | throw Exception(IMAGE_FORMAT, &file_name, "cannot determine file type - no file name extension"); |
| } | } |
| // methods | // methods |
| Line 1075 static gdImage* load(Request& r, const S | Line 1090 static gdImage* load(Request& r, const S |
| throw Exception(IMAGE_FORMAT, &file_name, "is not in GIF format"); | throw Exception(IMAGE_FORMAT, &file_name, "is not in GIF format"); |
| return image; | return image; |
| } else { | } else { |
| throw Exception("file.missing", 0, "can not open '%s'", file_name_cstr); | throw Exception("file.missing", 0, "cannot open '%s'", file_name_cstr); |
| } | } |
| } | } |
| Line 1440 static void _circle(Request& r, MethodPa | Line 1455 static void _circle(Request& r, MethodPa |
| gdImage& as_image(MethodParams& params, int index, const char* msg) { | gdImage& as_image(MethodParams& params, int index, const char* msg) { |
| Value& value=params.as_no_junction(index, msg); | Value& value=params.as_no_junction(index, msg); |
| if(Value* vimage=value.as(VIMAGE_TYPE)) { | if(VImage* vimage=dynamic_cast<VImage *>(&value)) { |
| return static_cast<VImage *>(vimage)->image(); | return vimage->image(); |
| } else | } else |
| throw Exception(PARSER_RUNTIME, 0, msg); | throw Exception(PARSER_RUNTIME, 0, msg); |
| } | } |