|
|
| version 1.6, 2001/04/11 13:03:39 | version 1.9, 2001/04/11 17:06:10 |
|---|---|
| Line 328 static void _load(Request& r, const Stri | Line 328 static void _load(Request& r, const Stri |
| const String& file_name=vfile_name.as_string(); | const String& file_name=vfile_name.as_string(); |
| 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_NAME); |
| gdImage image(pool); | |
| if(FILE *f=fopen(file_name_cstr, "rb")) { | if(FILE *f=fopen(file_name_cstr, "rb")) { |
| gdImagePtr image=gdImageCreateFromGif(f); | image.CreateFromGif(f); |
| int width=gdImageSX(image); | int width=image.SX(); |
| int height=gdImageSY(image); | int height=image.SY(); |
| fclose(f); | fclose(f); |
| static_cast<VImage *>(r.self)->set(&file_name, width, height, image); | static_cast<VImage *>(r.self)->set(&file_name, width, height, &image); |
| } else | } else |
| PTHROW(0, 0, | PTHROW(0, 0, |
| &method_name, | &method_name, |
| "can not open background image '%s'", file_name_cstr); | "can not open background image '%s'", file_name_cstr); |
| } | } |
| inline void v2rgb(int v, int& r, int& g, int& b) { | |
| r=v>>8*2 & 0xFF; | |
| g=v>>8*1 & 0xFF; | |
| b=v & 0xFF; | |
| } | |
| /// ^image.create[width;height] bgcolor=white | /// ^image.create[width;height] bgcolor=white |
| /// ^image.create[width;height;bgcolor] | /// ^image.create[width;height;bgcolor] |
| static void _create(Request& r, const String& method_name, Array *params) { | static void _create(Request& r, const String& method_name, Array *params) { |
| Line 354 static void _create(Request& r, const St | Line 349 static void _create(Request& r, const St |
| int width=(int)r.process(*static_cast<Value *>(params->get(0))).as_double(); | int width=(int)r.process(*static_cast<Value *>(params->get(0))).as_double(); |
| int height=(int)r.process(*static_cast<Value *>(params->get(1))).as_double(); | int height=(int)r.process(*static_cast<Value *>(params->get(1))).as_double(); |
| int bgcolor_value=0xFFFFFF; | int bgcolor_value=0xffFFff; |
| if(params->size()>2) | if(params->size()>2) |
| bgcolor_value= | bgcolor_value= |
| (int)r.process(*static_cast<Value *>(params->get(2))).as_double(); | (int)r.process(*static_cast<Value *>(params->get(2))).as_double(); |
| gdImagePtr image=gdImageCreate(width, height); | gdImage *image=new(pool) gdImage(pool); |
| { | image->Create(width, height); |
| int r,g,b; v2rgb(bgcolor_value, r,g,b); | image->FilledRectangle(0, 0, width-1, height-1, image->Color(bgcolor_value)); |
| gdImageFilledRectangle(image, 0, 0, width-1, height-1, | |
| gdImageColorExact(image, r,g,b)); | |
| } | |
| static_cast<VImage *>(r.self)->set(0, width, height, image); | static_cast<VImage *>(r.self)->set(0, width, height, image); |
| } | } |
| Line 373 static void _create(Request& r, const St | Line 365 static void _create(Request& r, const St |
| static void _gif(Request& r, const String& method_name, Array *params) { | static void _gif(Request& r, const String& method_name, Array *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| gdImagePtr image=static_cast<VImage *>(r.self)->image; | gdImage *image=static_cast<VImage *>(r.self)->image; |
| if(!image) | if(!image) |
| PTHROW(0, 0, | PTHROW(0, 0, |
| &method_name, | &method_name, |