--- parser3/src/classes/image.C 2001/04/12 14:07:33 1.13 +++ parser3/src/classes/image.C 2001/04/12 14:50:26 1.15 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: image.C,v 1.13 2001/04/12 14:07:33 paf Exp $ + $Id: image.C,v 1.15 2001/04/12 14:50:26 paf Exp $ */ #include "pa_config_includes.h" @@ -328,7 +328,7 @@ static void _load(Request& r, const Stri const String& file_name=vfile_name.as_string(); const char *file_name_cstr=r.absolute(file_name).cstr(String::UL_FILE_NAME); - gdImage image(pool); + gdImage& image=*new(pool) gdImage(pool); if(FILE *f=fopen(file_name_cstr, "rb")) { image.CreateFromGif(f); int width=image.SX(); @@ -353,14 +353,13 @@ static void _create(Request& r, const St if(params->size()>2) bgcolor_value= (int)r.process(*static_cast(params->get(2))).as_double(); - gdImage *image=new(pool) gdImage(pool); - image->Create(width, height); - image->FilledRectangle(0, 0, width-1, height-1, image->Color(bgcolor_value)); - static_cast(r.self)->set(0, width, height, image); + gdImage& image=*new(pool) gdImage(pool); + image.Create(width, height); + image.FilledRectangle(0, 0, width-1, height-1, image.Color(bgcolor_value)); + static_cast(r.self)->set(0, width, height, &image); } /// ^image.gif[] -/// ^image.gif[user-file-name] static void _gif(Request& r, const String& method_name, Array *params) { Pool& pool=r.pool(); @@ -370,21 +369,13 @@ static void _gif(Request& r, const Strin &method_name, "does not contain an image"); - char *file_name_cstr=0; - if(params->size()) { - Value& vfile_name=*static_cast(params->get(0)); - // forcing [this body type] - r.fail_if_junction_(true, vfile_name, method_name, "file name must not be code"); - - file_name_cstr=vfile_name.as_string().cstr(String::UL_FILE_NAME); - } // could _ but don't thing it's wise to use $image.src for vfile.name String out(pool); image->Gif(out); VFile& vfile=*new(pool) VFile(pool); String& image_gif=*new(pool) String(pool, "image/gif"); - vfile.set(false/*not tainted*/, out.cstr(), out.size(), file_name_cstr, &image_gif); + vfile.set(false/*not tainted*/, out.cstr(), out.size(), 0, &image_gif); r.write_no_lang(vfile); } @@ -555,8 +546,7 @@ void initialize_image_class(Pool& pool, vclass.add_native_method("create", Method::CT_DYNAMIC, _create, 2, 3); /// ^image.gif[] - /// ^image.gif[user-file-name] - vclass.add_native_method("gif", Method::CT_DYNAMIC, _gif, 0, 1); + vclass.add_native_method("gif", Method::CT_DYNAMIC, _gif, 0, 0); /// ^image.line(x0;y0;x1;y1;color) vclass.add_native_method("line", Method::CT_DYNAMIC, _line, 5, 5);