Annotation of parser3/src/types/pa_vimage.C, revision 1.22
1.7 paf 1: /** @file
1.1 paf 2: Parser: @b image parser type.
3:
1.22 ! paf 4: Copyright(c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com)
1.16 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.18 paf 6: */
1.1 paf 7:
1.22 ! paf 8: static const char* IDENT_VIMAGE_C="$Date: 2002/11/22 16:16:34 $";
1.1 paf 9:
10: #include "pa_vimage.h"
11: #include "pa_vint.h"
12: #include "pa_vstring.h"
1.8 parser 13: #include "gif.h"
1.1 paf 14:
1.3 paf 15: void VImage::set(const String *src, int width, int height,
1.21 paf 16: gdImage* aimage,
17: Value* aexif) {
1.5 paf 18: image=aimage;
1.21 paf 19: fexif=aexif;
1.3 paf 20:
1.1 paf 21: // $src
1.3 paf 22: if(src)
1.13 paf 23: ffields.put(*NEW String(pool(), "src"), NEW VString(*src));
1.1 paf 24: // $width
25: if(width)
1.13 paf 26: ffields.put(*NEW String(pool(), "width"), NEW VInt(pool(), width));
1.1 paf 27: // $height
28: if(height)
1.13 paf 29: ffields.put(*NEW String(pool(), "height"), NEW VInt(pool(), height));
1.2 paf 30:
31: // defaults
1.8 parser 32: // $border(0)
1.13 paf 33: ffields.put(*NEW String(pool(), "border"), NEW VInt(pool(), 0));
1.11 parser 34:
1.12 parser 35: // internals, take a look at image.C append_attrib_pair before update
1.8 parser 36: // $line-width(1)
1.13 paf 37: ffields.put(*NEW String(pool(), "line-width"), NEW VInt(pool(), 1));
1.8 parser 38: }
39:
1.21 paf 40:
41: Value *VImage::get_element(const String& aname, Value& aself, bool looking_up) {
42: // $method
43: if(Value *result=VStateless_object::get_element(aname, aself, looking_up))
44: return result;
45:
46: // $exif
47: if(aname==EXIF_ELEMENT_NAME)
48: return fexif;
49:
50: // $src, $size
51: return static_cast<Value *>(ffields.get(aname));
52: }
1.8 parser 53:
1.20 paf 54: bool VImage::put_element(const String& aname, Value *avalue, bool replace) {
1.8 parser 55: ffields.put(aname, avalue);
56:
1.20 paf 57: if(image) {
1.8 parser 58: if(aname=="line-width") {
59: image->SetLineWidth(min(max(avalue->as_int(), 1), 10));
60: } else if(aname=="line-style") {
61: const String sline_style=avalue->as_string();
62: image->SetLineStyle(sline_style.size()?sline_style.cstr(String::UL_AS_IS):0);
63: }
1.20 paf 64: }
65:
66: return true;
1.1 paf 67: }
E-mail: