Diff for /parser3/src/classes/image.C between versions 1.45 and 1.47

version 1.45, 2001/09/24 14:34:25 version 1.47, 2001/10/04 14:56:29
Line 2 Line 2
         Parser: @b image parser class.          Parser: @b image parser class.
   
         Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)          Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
   
         Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
   
           $Id$
 */  */
 static const char *RCSId="$Id$";   
   
 /*  /*
         jpegsize: gets the width and height (in pixels) of a jpeg file          jpegsize: gets the width and height (in pixels) of a jpeg file
Line 612  public: Line 612  public:
         }          }
                   
         /* ******************************** string ********************************** */          /* ******************************** string ********************************** */
         /*          
         int string_width(const char *cstr){          int string_width(const String& s){
                   const char *cstr=s.cstr(String::UL_AS_IS);
                 int result=0;                  int result=0;
                 for(; *cstr; cstr++)                  for(; *cstr; cstr++)
                         result+=index_width(index_of(*cstr));                          result+=index_width(index_of(*cstr));
                 return result;                  return result;
         }          }
         */  
                   
         void string_display(gdImage& image, int x, int y, const String& s){          void string_display(gdImage& image, int x, int y, const String& s){
                 const char *cstr=s.cstr(String::UL_AS_IS);                  const char *cstr=s.cstr(String::UL_AS_IS);
Line 679  static void _text(Request& r, const Stri Line 679  static void _text(Request& r, const Stri
                         "does not contain an image");                          "does not contain an image");
 }  }
   
   static void _length(Request& r, const String& method_name, MethodParams *params) {
           Pool& pool=r.pool();
   
           const String& s=params->as_string(0, "text must not be code");
   
           VImage& vimage=*static_cast<VImage *>(r.self);
           if(vimage.image)
                   if(vimage.font) {
                           VInt& result=*new(pool) VInt(pool, vimage.font->string_width(s));
                           result.set_name(method_name);
                           r.write_assign_lang(result);
                   } else
                           PTHROW(0, 0,
                                   &method_name,
                                   "set the font first");
           else
                   PTHROW(0, 0, 
                           &method_name, 
                           "does not contain an image");
   }
   
 // constructor  // constructor
   
 MImage::MImage(Pool& apool) : Methoded(apool) {  MImage::MImage(Pool& apool) : Methoded(apool) {
Line 733  MImage::MImage(Pool& apool) : Methoded(a Line 754  MImage::MImage(Pool& apool) : Methoded(a
     // ^image.text(x;y)[text]      // ^image.text(x;y)[text]
         add_native_method("text", Method::CT_DYNAMIC, _text, 3, 3);          add_native_method("text", Method::CT_DYNAMIC, _text, 3, 3);
                   
       // ^image.ngth[text]
           add_native_method("length", Method::CT_DYNAMIC, _length, 1, 1);
           
 }  }
   
 // global variable  // global variable

Removed from v.1.45  
changed lines
  Added in v.1.47


E-mail: