Annotation of parser3/src/types/pa_vimage.C, revision 1.47
1.7 paf 1: /** @file
1.1 paf 2: Parser: @b image parser type.
3:
1.46 moko 4: Copyright (c) 2001-2017 Art. Lebedev Studio (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:
8: #include "pa_vimage.h"
9: #include "pa_vint.h"
10: #include "pa_vstring.h"
1.8 parser 11: #include "gif.h"
1.36 misha 12: #include "pa_vbool.h"
13:
1.47 ! moko 14: volatile const char * IDENT_PA_VIMAGE_C="$Id: pa_vimage.C,v 1.46 2017/02/07 22:00:48 moko Exp $" IDENT_PA_VIMAGE_H;
1.1 paf 15:
1.47 ! moko 16: void VImage::set(const String* src, int width, int height, gdImage* aimage, Value* aexif) {
1.30 paf 17: fimage=aimage;
1.3 paf 18:
1.1 paf 19: // $src
1.3 paf 20: if(src)
1.44 moko 21: ffields.put("src", new VString(*src));
1.1 paf 22: // $width
23: if(width)
1.44 moko 24: ffields.put("width", new VInt(width));
1.1 paf 25: // $height
26: if(height)
1.44 moko 27: ffields.put("height", new VInt(height));
1.47 ! moko 28: // $exif
! 29: if(aexif)
! 30: ffields.put("exif", aexif);
! 31:
1.2 paf 32: // defaults
1.8 parser 33: // $border(0)
1.44 moko 34: ffields.put("border", new VInt(0));
1.11 parser 35:
1.12 parser 36: // internals, take a look at image.C append_attrib_pair before update
1.47 ! moko 37: // $line-width(1)
1.44 moko 38: ffields.put("line-width", new VInt(1));
1.8 parser 39: }
40:
1.42 moko 41: Value& VImage::as_expr_result() {
1.37 misha 42: return VBool::get(as_bool());
1.36 misha 43: }
44:
1.21 paf 45:
1.40 misha 46: Value* VImage::get_element(const String& aname) {
1.21 paf 47: // $method
1.40 misha 48: if(Value* result=VStateless_object::get_element(aname))
1.21 paf 49: return result;
50:
51: // $src, $size
1.23 paf 52: return ffields.get(aname);
1.21 paf 53: }
1.8 parser 54:
1.43 moko 55: const VJunction* VImage::put_element(const String& aname, Value* avalue) {
1.8 parser 56: ffields.put(aname, avalue);
57:
1.30 paf 58: if(fimage) {
1.8 parser 59: if(aname=="line-width") {
1.30 paf 60: fimage->SetLineWidth(min(max(avalue->as_int(), 1), 10));
1.8 parser 61: } else if(aname=="line-style") {
1.23 paf 62: const String& sline_style=avalue->as_string();
1.39 misha 63: fimage->SetLineStyle(sline_style.length()?sline_style.taint_cstr(String::L_AS_IS):0);
1.8 parser 64: }
1.20 paf 65: }
66:
1.47 ! moko 67: return PUT_ELEMENT_REPLACED_ELEMENT;
1.1 paf 68: }
E-mail: