--- parser3/src/classes/image.C 2001/04/11 17:00:53 1.8 +++ parser3/src/classes/image.C 2001/04/11 18:07:15 1.11 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: image.C,v 1.8 2001/04/11 17:00:53 paf Exp $ + $Id: image.C,v 1.11 2001/04/11 18:07:15 paf Exp $ */ #include "pa_config_includes.h" @@ -303,7 +303,7 @@ static void _html(Request& r, const Stri Hash& fields=static_cast(r.self)->fields(); Hash *attribs=0; - if(params) + if(params->size()) if(attribs=static_cast(params->get(0))->get_hash()) { Attrib_info attrib_info={&tag, 0}; attribs->for_each(append_attrib_pair, &attrib_info); @@ -328,13 +328,14 @@ 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); if(FILE *f=fopen(file_name_cstr, "rb")) { - gdImagePtr image=gdImageCreateFromGif(f); - int width=gdImageSX(image); - int height=gdImageSY(image); + image.CreateFromGif(f); + int width=image.SX(); + int height=image.SY(); fclose(f); - static_cast(r.self)->set(&file_name, width, height, image); + static_cast(r.self)->set(&file_name, width, height, &image); } else PTHROW(0, 0, &method_name, @@ -360,18 +361,17 @@ static void _create(Request& r, const St /// ^image.gif[] /// ^image.gif[user-file-name] -/// @test gdImageDestroy make gd pooled! static void _gif(Request& r, const String& method_name, Array *params) { Pool& pool=r.pool(); - gdImagePtr image=static_cast(r.self)->image; + gdImage *image=static_cast(r.self)->image; if(!image) PTHROW(0, 0, &method_name, "does not contain image"); char *file_name_cstr=0; - if(params) { + 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"); @@ -379,10 +379,12 @@ static void _gif(Request& r, const Strin 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*/, z, z, file_name_cstr, &image_gif); + vfile.set(false/*not tainted*/, out.cstr(), out.size(), file_name_cstr, &image_gif); r.write_no_lang(vfile); }