Annotation of parser3/src/types/pa_vimage.C, revision 1.15

1.7       paf         1: /** @file
1.1       paf         2:        Parser: @b image parser type.
                      3: 
1.15    ! paf         4:        Copyright(c) 2001, 2002 ArtLebedev Group(http://www.artlebedev.com)
1.14      paf         5:        Author: Alexander Petrosyan <paf@design.ru>(http://paf.design.ru)
1.1       paf         6: 
1.15    ! paf         7:        $Id: pa_vimage.C,v 1.14 2001/11/05 11:46:33 paf Exp $
1.1       paf         8: */
                      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.6       paf        16:                                 gdImage* aimage) {
1.5       paf        17:        image=aimage;
1.3       paf        18: 
1.1       paf        19:        // $src
1.3       paf        20:        if(src)
1.13      paf        21:                ffields.put(*NEW String(pool(), "src"), NEW VString(*src));
1.1       paf        22:        // $width
                     23:        if(width)
1.13      paf        24:                ffields.put(*NEW String(pool(), "width"), NEW VInt(pool(), width));
1.1       paf        25:        // $height
                     26:        if(height)
1.13      paf        27:                ffields.put(*NEW String(pool(), "height"), NEW VInt(pool(), height));
1.2       paf        28: 
                     29:        // defaults
1.8       parser     30:        // $border(0)
1.13      paf        31:        ffields.put(*NEW String(pool(), "border"), NEW VInt(pool(), 0));
1.11      parser     32: 
1.12      parser     33:        // internals, take a look at image.C append_attrib_pair before update
1.8       parser     34:        // $line-width(1) 
1.13      paf        35:        ffields.put(*NEW String(pool(), "line-width"), NEW VInt(pool(), 1));
1.8       parser     36: }
                     37: 
                     38: 
                     39: void VImage::put_element(const String& aname, Value *avalue) {
                     40:        ffields.put(aname, avalue);
                     41: 
                     42:        if(image)
                     43:                if(aname=="line-width") {
                     44:                        image->SetLineWidth(min(max(avalue->as_int(), 1), 10));
                     45:                } else if(aname=="line-style") {
                     46:                        const String sline_style=avalue->as_string();
                     47:                        image->SetLineStyle(sline_style.size()?sline_style.cstr(String::UL_AS_IS):0);
                     48:                }
1.1       paf        49: }

E-mail: