--- parser3/src/classes/image.C 2001/09/15 15:42:08 1.40.4.1 +++ parser3/src/classes/image.C 2001/09/15 11:48:41 1.43 @@ -5,9 +5,9 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: image.C,v 1.40.4.1 2001/09/15 15:42:08 parser Exp $ + $Id: image.C,v 1.43 2001/09/15 11:48:41 parser Exp $ */ -static const char *RCSId="$Id: image.C,v 1.40.4.1 2001/09/15 15:42:08 parser Exp $"; +static const char *RCSId="$Id: image.C,v 1.43 2001/09/15 11:48:41 parser Exp $"; /* jpegsize: gets the width and height (in pixels) of a jpeg file @@ -47,7 +47,7 @@ public: // Methoded // helpers -/// simple buffered reader[from memory/file], used in _measure +#ifndef DOXYGEN class Measure_reader { public: enum { READ_CHUNK_SIZE=0x400*10 };// 10K @@ -83,6 +83,7 @@ private: size_t offset; size_t size; }; +#endif /// GIF file header struct GIF_Header { @@ -137,7 +138,7 @@ void measure_gif(Pool& pool, const Strin if(strncmp(head->type, "GIF", 3)!=0) PTHROW(0, 0, origin_string, - "not GIF file - wrong signature"); + "not GIF file - signature not found"); width=little_endian_to_int(head->width); height=little_endian_to_int(head->height); @@ -161,7 +162,7 @@ void measure_jpeg(Pool& pool, const Stri if(!(signature[0]==0xFF && signature[1]==0xD8)) PTHROW(0, 0, origin_string, - "not JPEG file - wrong signature"); + "not JPEG file - signature not found"); bool found=false; while(true) { @@ -334,7 +335,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_NAME); + 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); @@ -356,7 +357,8 @@ static gdImage *load(Request& r, const S static void _load(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - const String& file_name=params->as_string(0, "file name must not be code"); + Value& vfile_name=params->as_no_junction(0, "file name must not be code"); + const String& file_name=vfile_name.as_string(); gdImage& image=*load(r, method_name, file_name); int width=image.SX(); @@ -392,9 +394,9 @@ static void _gif(Request& r, const Strin String out(pool); image->Gif(out); VFile& vfile=*new(pool) VFile(pool); - String& image_gif=*new(pool) String(pool, "image/gif"); + Value *content_type=new(pool) VString(*new(pool) String(pool, "image/gif")); vfile.set(false/*not tainted*/, - out.cstr(String::UL_AS_IS), out.size(), 0, &image_gif); + out.cstr(String::UL_AS_IS), out.size(), 0, content_type); r.write_no_lang(vfile); } @@ -408,24 +410,12 @@ static void _line(Request& r, const Stri &method_name, "does not contain an image"); - if(params->size()>5) { - // '*** * ' - const String& sline_style=params->as_string(5, "line style must not be code"); - - image->StyledLine( - params->as_int(0, r), - params->as_int(1, r), - params->as_int(2, r), - params->as_int(3, r), - image->Color(params->as_int(4, r)), - sline_style.size()?sline_style.cstr(String::UL_AS_IS):0); - } else - image->Line( - params->as_int(0, r), - params->as_int(1, r), - params->as_int(2, r), - params->as_int(3, r), - image->Color(params->as_int(4, r))); + image->Line( + params->as_int(0, r), + params->as_int(1, r), + params->as_int(2, r), + params->as_int(3, r), + image->Color(params->as_int(4, r))); } static void _fill(Request& r, const String& method_name, MethodParams *params) { @@ -692,7 +682,7 @@ MImage::MImage(Pool& apool) : Methoded(a add_native_method("gif", Method::CT_DYNAMIC, _gif, 0, 0); // ^image.line(x0;y0;x1;y1;color) - add_native_method("line", Method::CT_DYNAMIC, _line, 5, 6); + add_native_method("line", Method::CT_DYNAMIC, _line, 5, 5); // ^image.fill(x;y;color) add_native_method("fill", Method::CT_DYNAMIC, _fill, 3, 3);