--- parser3/src/classes/image.C 2003/03/04 12:38:15 1.90.2.13 +++ parser3/src/classes/image.C 2003/03/04 15:59:18 1.90.2.15 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_IMAGE_C="$Date: 2003/03/04 12:38:15 $"; +static const char* IDENT_IMAGE_C="$Date: 2003/03/04 15:59:18 $"; /* jpegsize: gets the width and height (in pixels) of a jpeg file @@ -55,7 +55,7 @@ public: EXIF_tag_value2name() { // image JPEG Exif #define EXIF_TAG(tag, name) \ - exif_tag_value2name.put(tag, #name); + put(tag, #name); // Tags used by IFD0 (main image) EXIF_TAG(0x010e, ImageDescription); EXIF_TAG(0x010f, Make); @@ -459,11 +459,11 @@ static ValuePtr parse_IFD_entry_value(Po ushort format=endian_to_ushort(is_big, entry.format); if(format>=sizeof(format2component_size)/sizeof(format2component_size[0])) - return 0; // format out of range, ignoring + return ValuePtr(0); // format out of range, ignoring size_t component_size=format2component_size[format]; if(component_size==0) - return 0; // undefined format + return ValuePtr(0); // undefined format // You can get the total data byte length by multiplies // a 'bytes/components' value (see above chart) by number of components stored 'NNNNNNNN' area @@ -483,7 +483,7 @@ static ValuePtr parse_IFD_entry_value(Po reader.seek(tiff_base+endian_to_uint(is_big, entry.value_or_offset_to_it), SEEK_SET); const char *value; if(reader.read(value, value_size)signature, "Exif\0\0", 4+2)!=0) //signature invalid? - return 0; // ignore invalid block + return ValuePtr(0); // ignore invalid block uint tiff_base=reader.tell(); if(reader.read(buf, sizeof(JPG_Exif_TIFF_header))byte_align_identifier[0]=='M'; // [M]otorola vs [I]ntel @@ -804,7 +804,7 @@ static gdImagePtr load(Request& r, Strin } else { throw Exception("file.missing", method_name, - "can not open '%s'", file_name_cstr); + "can not open '%s'", file_name_cstr.get()); return gdImagePtr(0); } } @@ -1022,75 +1022,68 @@ static void _polybar(Request& r, StringP #define Y(y)(y+index*height) -/// simple gdImage-based font storage & text output -class Font: public PA_Object { -public: - - const static int letter_spacing; - int height; ///< Font heigth - int monospace; ///< Default char width - int spacebarspace; ///< spacebar width - gdImagePtr ifont; - StringPtr alphabet; - - Font(//Pool& pool, - StringPtr aalphabet, - gdImagePtr aifont, int aheight, int amonospace, int aspacebarspace): - alphabet(aalphabet), - height(aheight), monospace(amonospace), spacebarspace(aspacebarspace), - ifont(aifont) { - } - - /* ******************************** char ********************************** */ - - int index_of(char ch) { - if(ch==' ') return -1; - return alphabet->pos(&ch, 1); - } - - int index_width(int index) { - if(index<0) - return spacebarspace; - int tr=ifont->GetTransparent(); - for(int x=ifont->SX()-1; x>=0; x--) { - for(int y=0; yGetPixel(x, Y(y))!=tr) - return x+1; - } - return 0; - } - - void index_display(gdImagePtr image, int x, int y, int index){ - if(index>=0) - ifont->Copy(*image, x, y, 0, Y(0), index_width(index), height); - } - - /* ******************************** string ********************************** */ - - int step_width(int index) { - return letter_spacing + (monospace ? monospace : index_width(index)); - } +// Font class + +const int Font::letter_spacing=1; + +Font::Font(//Pool& pool, + StringPtr aalphabet, + gdImagePtr aifont, int aheight, int amonospace, int aspacebarspace): + alphabet(aalphabet), + height(aheight), monospace(amonospace), spacebarspace(aspacebarspace), + ifont(aifont) { +} + +/* ******************************** char ********************************** */ - // counts trailing letter_spacing, consider this OK. useful for contiuations - int string_width(StringPtr s){ - CharPtr cstr=s->cstr(); - int result=0; - for(const char* current=cstr; *current; current++) - result+=step_width(index_of(*current)); - return result; +int Font::index_of(char ch) { + if(ch==' ') return -1; + return alphabet->pos(&ch, 1); +} + +int Font::index_width(int index) { + if(index<0) + return spacebarspace; + int tr=ifont->GetTransparent(); + for(int x=ifont->SX()-1; x>=0; x--) { + for(int y=0; yGetPixel(x, Y(y))!=tr) + return x+1; } - - void string_display(gdImagePtr image, int x, int y, StringPtr s){ - CharPtr cstr=s->cstr(); - for(const char* current=cstr; *current; current++) { - int index=index_of(*current); - index_display(image, x, y, index); - x+=step_width(index); - } + return 0; +} + +void Font::index_display(gdImagePtr image, int x, int y, int index){ + if(index>=0) + ifont->Copy(*image, x, y, 0, Y(0), index_width(index), height); +} + +/* ******************************** string ********************************** */ + +int Font::step_width(int index) { + return letter_spacing + (monospace ? monospace : index_width(index)); +} + +// counts trailing letter_spacing, consider this OK. useful for contiuations +int Font::string_width(StringPtr s){ + CharPtr cstr=s->cstr(); + int result=0; + for(const char* current=cstr; *current; current++) + result+=step_width(index_of(*current)); + return result; +} + +void Font::string_display(gdImagePtr image, int x, int y, StringPtr s){ + CharPtr cstr=s->cstr(); + for(const char* current=cstr; *current; current++) { + int index=index_of(*current); + index_display(image, x, y, index); + x+=step_width(index); } - -}; -const int Font::letter_spacing=1; +} + +// + static void _font(Request& r, StringPtr method_name, MethodParams* params) { Pool& pool=r.pool();