Annotation of parser3/src/types/pa_vimage.C, revision 1.52
1.7 paf 1: /** @file
1.1 paf 2: Parser: @b image parser type.
3:
1.52 ! moko 4: Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com)
1.51 moko 5: Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <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.52 ! moko 14: volatile const char * IDENT_PA_VIMAGE_C="$Id: pa_vimage.C,v 1.51 2023/09/26 20:49:12 moko Exp $" IDENT_PA_VIMAGE_H;
1.1 paf 15:
1.48 moko 16: void VImage::set(const String* src, int width, int height, gdImage* aimage, Value* aexif, Value* axmp) {
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.48 moko 22:
1.1 paf 23: // $width
24: if(width)
1.44 moko 25: ffields.put("width", new VInt(width));
1.1 paf 26: // $height
27: if(height)
1.44 moko 28: ffields.put("height", new VInt(height));
1.48 moko 29:
1.47 moko 30: // $exif
31: if(aexif)
32: ffields.put("exif", aexif);
1.48 moko 33: // $xmp
34: if(axmp)
35: ffields.put("xmp", axmp);
1.47 moko 36:
1.2 paf 37: // defaults
1.8 parser 38: // $border(0)
1.44 moko 39: ffields.put("border", new VInt(0));
1.11 parser 40:
1.12 parser 41: // internals, take a look at image.C append_attrib_pair before update
1.47 moko 42: // $line-width(1)
1.44 moko 43: ffields.put("line-width", new VInt(1));
1.8 parser 44: }
45:
1.42 moko 46: Value& VImage::as_expr_result() {
1.37 misha 47: return VBool::get(as_bool());
1.36 misha 48: }
49:
1.21 paf 50:
1.40 misha 51: Value* VImage::get_element(const String& aname) {
1.21 paf 52: // $method
1.40 misha 53: if(Value* result=VStateless_object::get_element(aname))
1.21 paf 54: return result;
55:
56: // $src, $size
1.23 paf 57: return ffields.get(aname);
1.21 paf 58: }
1.8 parser 59:
1.43 moko 60: const VJunction* VImage::put_element(const String& aname, Value* avalue) {
1.8 parser 61: ffields.put(aname, avalue);
62:
1.30 paf 63: if(fimage) {
1.8 parser 64: if(aname=="line-width") {
1.30 paf 65: fimage->SetLineWidth(min(max(avalue->as_int(), 1), 10));
1.8 parser 66: } else if(aname=="line-style") {
1.23 paf 67: const String& sline_style=avalue->as_string();
1.39 misha 68: fimage->SetLineStyle(sline_style.length()?sline_style.taint_cstr(String::L_AS_IS):0);
1.8 parser 69: }
1.20 paf 70: }
71:
1.49 moko 72: return 0;
1.1 paf 73: }
E-mail: