adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-commits] CVS: adonthell/src/gfx drawable.cc, 1.1.1.1, 1.2 dra


From: Alexandre Courbot <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src/gfx drawable.cc, 1.1.1.1, 1.2 drawable.h, 1.1.1.1, 1.2 drawing_area.cc, 1.1.1.1, 1.2 drawing_area.h, 1.2, 1.3 gfx.cc, 1.1.1.1, 1.2 gfx.h, 1.1.1.1, 1.2 pnm.cc, 1.1.1.1, 1.2 screen.cc, 1.1.1.1, 1.2 surface.cc, 1.1.1.1, 1.2 surface.h, 1.1.1.1, 1.2
Date: Thu, 24 Jul 2003 08:58:01 -0400

Update of /cvsroot/adonthell/adonthell/src/gfx
In directory subversions:/tmp/cvs-serv8178/src/gfx

Modified Files:
        drawable.cc drawable.h drawing_area.cc drawing_area.h gfx.cc 
        gfx.h pnm.cc screen.cc surface.cc surface.h 
Log Message:
Applied Fabien's changes and extended them to all the source
(changing using namespace's into real namespace enclosing and fixed some
 consts)


Index: drawable.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/drawable.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** drawable.cc 18 Jul 2003 15:16:09 -0000      1.1.1.1
--- drawable.cc 24 Jul 2003 12:57:58 -0000      1.2
***************
*** 22,42 ****
  
  #include "drawable.h"
-  
- // Public methods.
- 
- using namespace gfx;
  
! drawable::drawable () 
! {
!     set_length (0);
!     set_height (0); 
! }
! 
! drawable::~drawable ()
! { 
! }
  
! bool drawable::update ()
  {
!     return true; 
  }
--- 22,44 ----
  
  #include "drawable.h"
  
! // Public methods.
  
! namespace gfx
  {
!     
!     drawable::drawable () 
!         : length_(0), height_(0)
!     {
!     }
!     
!     drawable::~drawable ()
!     { 
!     }
!     
!     bool drawable::update ()
!     {
!         return true; 
!     }
!     
  }

Index: drawable.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/drawable.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** drawable.h  18 Jul 2003 15:16:09 -0000      1.1.1.1
--- drawable.h  24 Jul 2003 12:57:58 -0000      1.2
***************
*** 143,147 ****
  }
  
  PYTHON_AS_CALLBACK_ARGUMENT(gfx::drawable)
! 
  #endif
--- 143,148 ----
  }
  
+ #ifndef SWIG
  PYTHON_AS_CALLBACK_ARGUMENT(gfx::drawable)
! #endif // SWIG
  #endif

Index: drawing_area.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/drawing_area.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** drawing_area.cc     18 Jul 2003 15:16:09 -0000      1.1.1.1
--- drawing_area.cc     24 Jul 2003 12:57:58 -0000      1.2
***************
*** 24,81 ****
  #include "drawing_area.h"
  
! using namespace gfx;
! 
! drawing_area::drawing_area ()
  {
!     move (0, 0);
!     resize (0, 0);
!     draw_to = NULL; 
! }
! 
! drawing_area::drawing_area (s_int16 px, s_int16 py, u_int16 pw, u_int16 ph)
! {
!     move (px, py);
!     resize (pw, ph); 
!     draw_to = NULL; 
! }
! 
! drawing_area drawing_area::setup_rects () const
! {
!     drawing_area ret;
!     if (draw_to)
      {
!         drawing_area temp = draw_to->setup_rects ();
!         
!         ret.move(temp.x() > x ()? temp.x() : x (),
!                  temp.y() > y ()? temp.y() : y ());
! 
!         // Precalculated for faster operation.
!         s_int32 xpl = x () + length (); 
!         s_int32 txw = temp.x() + temp.length();
!         s_int32 txwmrx = txw - ret.x();
!         s_int32 xplmrx = xpl - ret.x();  
!         s_int32 yph = y () + height (); 
!         s_int32 tyh = temp.y() + temp.height();
!         s_int32 tyhmry = tyh - ret.y();
!         s_int32 yphmry = yph - ret.y(); 
!         
          
!         ret.resize(txw < xpl ? txwmrx > 0 ? txwmrx : 0 : xplmrx > 0 ? xplmrx 
: 0,
!                    tyh < yph ? tyhmry > 0 ? tyhmry : 0 : yphmry > 0 ? yphmry 
: 0);
          
      }
!     else 
      {
!         ret = *this;
!         ret.assign_drawing_area(NULL);
      }
! 
!     return ret;
! 
! }
! 
! bool drawing_area::point_belong (s_int16 px, s_int16 py)
! {
!     return (px >= x () && px <= x () + length () &&
!             py >= y () && py <= y () + height ()); 
  }
--- 24,84 ----
  #include "drawing_area.h"
  
! namespace gfx
  {
!     
!     drawing_area::drawing_area ()
!         : x_(0), y_(0),
!           w_(0), h_(0),
!           draw_to(NULL)
      {
!     }
!     
!     drawing_area::drawing_area (s_int16 px, s_int16 py, u_int16 pw, u_int16 
ph) : 
!         x_(px), y_(py),
!         w_(pw), h_(ph),
!         draw_to(NULL)
!     {
!     }
!     
!     drawing_area drawing_area::setup_rects () const
!     {
!         drawing_area ret;
!         if (draw_to)
!         {
!             drawing_area temp = draw_to->setup_rects ();
!             
!             ret.move(temp.x() > x ()? temp.x() : x (),
!                      temp.y() > y ()? temp.y() : y ());
!             
!             // Precalculated for faster operation.
!             s_int32 xpl = x () + length (); 
!             s_int32 txw = temp.x() + temp.length();
!             s_int32 txwmrx = txw - ret.x();
!             s_int32 xplmrx = xpl - ret.x();  
!             s_int32 yph = y () + height (); 
!             s_int32 tyh = temp.y() + temp.height();
!             s_int32 tyhmry = tyh - ret.y();
!             s_int32 yphmry = yph - ret.y(); 
!             
!             
!             ret.resize(txw < xpl ? txwmrx > 0 ? txwmrx : 0 : xplmrx > 0 ? 
xplmrx : 0,
!                        tyh < yph ? tyhmry > 0 ? tyhmry : 0 : yphmry > 0 ? 
yphmry : 0);
!             
!         }
!         else 
!         {
!             ret = *this;
!             ret.assign_drawing_area(NULL);
!         }
          
!         return ret;
          
      }
!     
!     bool drawing_area::point_belong (s_int16 px, s_int16 py)
      {
!         return (px >= x () && px <= x () + length () &&
!                 py >= y () && py <= y () + height ()); 
      }
!     
  }

Index: drawing_area.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/drawing_area.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** drawing_area.h      22 Jul 2003 17:40:39 -0000      1.2
--- drawing_area.h      24 Jul 2003 12:57:58 -0000      1.3
***************
*** 130,136 ****
           *  @param da the drawing_area to assign.
           */  
!         void assign_drawing_area (const drawing_area * da) 
          {
!             draw_to = (drawing_area *) da; 
          }
  
--- 130,136 ----
           *  @param da the drawing_area to assign.
           */  
!         void assign_drawing_area (drawing_area * da) 
          {
!             draw_to = da; 
          }
  

Index: gfx.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/gfx.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** gfx.cc      18 Jul 2003 15:16:09 -0000      1.1.1.1
--- gfx.cc      24 Jul 2003 12:57:58 -0000      1.2
***************
*** 23,31 ****
   */
  
  #include "base/paths.h"
- #include "gfx/gfx.h"
  
  #include "ltdl.h"
! #include <iostream>
  
  /**
--- 23,38 ----
   */
  
+ #include <iostream>
+ 
+ #include "gfx/drawing_area.h"
+ #include "gfx/drawable.h"
+ #include "gfx/surface.h"
+ #include "gfx/screen.h"
  #include "base/paths.h"
  
  #include "ltdl.h"
! 
! #include "gfx/gfx.h"
! 
  
  /**
***************
*** 51,119 ****
   * 
   */
! static gfx::surface * (*create_surface_p)() = 0;
  
! bool gfx::init(const std::string & backend_name)
  {
      if (lt_dlinit())
!     {
!         std::cerr << lt_dlerror() << std::endl;
!         std::cerr << "Error initializing liblt!\n"; 
          return false;
!     }
! 
! //     dlhandle = lt_dlopenext(libname.c_str());
!     dlhandle = base::get_module(std::string("/gfx/") + backend_name);
      
      if (!dlhandle) goto bigerror;
!         
      gfxinit = (bool(*)()) lt_dlsym(dlhandle, "gfx_init");
      if (!gfxinit)
!     {
!         std::cerr << lt_dlerror() << std::endl;
          goto bigerror;
!     }
      
      gfxcleanup = (void(*)()) lt_dlsym(dlhandle, "gfx_cleanup");
      if (!gfxcleanup)
!     {
!         std::cerr << lt_dlerror() << std::endl;
          goto bigerror;
!     }
      
      screen::set_video_mode_p = (bool(*)(u_int16, u_int16, u_int8)) 
lt_dlsym(dlhandle, "gfx_screen_set_video_mode");
      if (!screen::set_video_mode_p)
!     {
!         std::cerr << lt_dlerror() << std::endl;
          goto bigerror;
!     }
! 
      screen::update_p = (void(*)()) lt_dlsym(dlhandle, "gfx_screen_update");
      if (!screen::update_p)
!     {
!         std::cerr << lt_dlerror() << std::endl;
          goto bigerror;
!     }
! 
      screen::trans_color_p = (u_int32(*)()) lt_dlsym(dlhandle, 
"gfx_screen_trans_color");
      if (!screen::trans_color_p)
!     {
!         std::cerr << lt_dlerror() << std::endl;
          goto bigerror;
!     }
! 
      screen::clear_p = (void(*)()) lt_dlsym(dlhandle, "gfx_screen_clear");
      if (!screen::clear_p)
!     {
!         std::cerr << lt_dlerror() << std::endl;
          goto bigerror;
!     }
! 
!     create_surface_p = (gfx::surface *(*)()) lt_dlsym(dlhandle, 
"gfx_create_surface");
      if (!create_surface_p)
!     {
!         std::cerr << lt_dlerror() << std::endl;
          goto bigerror;
!     }
! 
      goto success;
      
--- 58,130 ----
   * 
   */
! static gfx::surface * (*create_surface_p)() = 0;  
  
! using namespace std;
! 
! namespace gfx
  {
+   bool init(const string & backend_name)
+   {
      if (lt_dlinit())
!       {
!         cerr << lt_dlerror() << endl;
!         cerr << "Error initializing liblt!\n"; 
          return false;
!       }
!     
!     //     dlhandle = lt_dlopenext(libname.c_str());
!     dlhandle = base::get_module(string("/gfx/") + backend_name);
      
      if (!dlhandle) goto bigerror;
!     
      gfxinit = (bool(*)()) lt_dlsym(dlhandle, "gfx_init");
      if (!gfxinit)
!       {
!         cerr << lt_dlerror() << endl;
          goto bigerror;
!       }
      
      gfxcleanup = (void(*)()) lt_dlsym(dlhandle, "gfx_cleanup");
      if (!gfxcleanup)
!       {
!         cerr << lt_dlerror() << endl;
          goto bigerror;
!       }
      
      screen::set_video_mode_p = (bool(*)(u_int16, u_int16, u_int8)) 
lt_dlsym(dlhandle, "gfx_screen_set_video_mode");
      if (!screen::set_video_mode_p)
!       {
!         cerr << lt_dlerror() << endl;
          goto bigerror;
!       }
!     
      screen::update_p = (void(*)()) lt_dlsym(dlhandle, "gfx_screen_update");
      if (!screen::update_p)
!       {
!         cerr << lt_dlerror() << endl;
          goto bigerror;
!       }
!     
      screen::trans_color_p = (u_int32(*)()) lt_dlsym(dlhandle, 
"gfx_screen_trans_color");
      if (!screen::trans_color_p)
!       {
!         cerr << lt_dlerror() << endl;
          goto bigerror;
!       }
!     
      screen::clear_p = (void(*)()) lt_dlsym(dlhandle, "gfx_screen_clear");
      if (!screen::clear_p)
!       {
!         cerr << lt_dlerror() << endl;
          goto bigerror;
!       }
!     
!     create_surface_p = (surface *(*)()) lt_dlsym(dlhandle, 
"gfx_create_surface");
      if (!create_surface_p)
!       {
!         cerr << lt_dlerror() << endl;
          goto bigerror;
!       }
!     
      goto success;
      
***************
*** 122,141 ****
      lt_dlexit();
      return false;
! 
   success:        
      return gfxinit();
! }
  
! void gfx::cleanup()
! {
      if (gfxcleanup) gfxcleanup();
      gfxcleanup = NULL;
! 
      if (dlhandle) lt_dlclose(dlhandle);
      lt_dlexit();
! }
  
! gfx::surface * gfx::create_surface()
! {
      return create_surface_p();
  }
--- 133,154 ----
      lt_dlexit();
      return false;
!     
   success:        
      return gfxinit();
!   }
  
!   void cleanup()
!   {
      if (gfxcleanup) gfxcleanup();
      gfxcleanup = NULL;
!     
      if (dlhandle) lt_dlclose(dlhandle);
      lt_dlexit();
!   }
  
!   surface * create_surface()
!   {
      return create_surface_p();
+   }
+   
  }

Index: gfx.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/gfx.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** gfx.h       18 Jul 2003 15:16:09 -0000      1.1.1.1
--- gfx.h       24 Jul 2003 12:57:58 -0000      1.2
***************
*** 38,41 ****
--- 38,43 ----
  namespace gfx
  {
+     class surface;
+     
      /** 
       * Initialize the gfx module. This function \e must be called
***************
*** 70,74 ****
       * the current backend.
       */
!     gfx::surface * create_surface();
  }
  
--- 72,76 ----
       * the current backend.
       */
!     surface * create_surface();
  }
  

Index: pnm.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/pnm.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** pnm.cc      18 Jul 2003 15:16:09 -0000      1.1.1.1
--- pnm.cc      24 Jul 2003 12:57:58 -0000      1.2
***************
*** 29,118 ****
  #include <cstring>
  
! using namespace gfx;
  
! void * pnm::get (std::ifstream & file, u_int16 & length, u_int16 & height)
  {
!     char *image;
!     char sign[10];
!     u_int16 l, h;
!     u_int32 i = 0;
! 
!     file.read(sign, 2);
!     if ((sign[0] != 'P') || (sign[1] != '6'))
      {
!         printf ("Invalid format.\n");
!         return (NULL);
      }
!     pnm_gotonextline (file);
!     /* Getting height and length */
!     while (pnm_checkforcomment (file));
!     do
      {
!         file.read(&sign[i], 1);
!         i++;
      }
!     while (sign[i - 1] != ' ');
!     sign[i - 1] = 0;
!     l = atoi (sign);
!     i = 0;
!     do
      {
!         file.read(&sign[i], 1);
!         i++;
!     }
!     while (sign[i - 1] != '\n');
!     sign[i - 1] = 0;
!     h = atoi (sign);
!     /* Going to next line */
!     pnm_gotonextline (file);
!     /* Reading the image */
!     image = (char *)calloc (l * h, 3);
!     file.read(image, 3 *l * h);
!     if (length)
!         length = l;
!     if (height)
!         height = h;
!     return (image);
! }
! 
! void pnm::put (std::ofstream & file, const char *image, u_int16 length, 
u_int16 height)
! {
!     char s[30];
! 
!     sprintf (s, "P6\n%d %d\n255\n", length, height);
!     file.write(s, sizeof (char) * strlen (s));
! 
!     file.write(image, 3 * length * height);
! }
!  
! 
! 
! 
! // Private methods.
! 
! 
! 
! void pnm::pnm_gotonextline (std::ifstream & file)
! {
!     char buff;
! 
!     do file.read(&buff, 1);
!     while (buff != '\n');
! }
! 
! int pnm::pnm_checkforcomment (std::ifstream & file)
! {
!     char buff;
! 
!     file.read(&buff, 1);
!     if (buff == '#')
!     {
!         pnm_gotonextline (file);
!         return (1);
      }
!     else
      {
!         file.seekg(-1, std::ios::cur);
!         return (0);
      }
  }
--- 29,115 ----
  #include <cstring>
  
! using namespace std;
  
! namespace gfx
  {
!     
!     void * pnm::get (ifstream & file, u_int16 & length, u_int16 & height)
      {
!         char *image;
!         char sign[10];
!         u_int16 l, h;
!         u_int32 i = 0;
!         
!         file.read(sign, 2);
!         if ((sign[0] != 'P') || (sign[1] != '6'))
!         {
!             printf ("Invalid format.\n");
!             return (NULL);
!         }
!         pnm_gotonextline (file);
!         /* Getting height and length */
!         while (pnm_checkforcomment (file));
!         do
!         {
!             file.read(&sign[i], 1);
!             i++;
!         }
!         while (sign[i - 1] != ' ');
!         sign[i - 1] = 0;
!         l = atoi (sign);
!         i = 0;
!         do
!         {
!             file.read(&sign[i], 1);
!             i++;
!         }
!         while (sign[i - 1] != '\n');
!         sign[i - 1] = 0;
!         h = atoi (sign);
!         /* Going to next line */
!         pnm_gotonextline (file);
!         /* Reading the image */
!         image = (char *)calloc (l * h, 3);
!         file.read(image, 3 *l * h);
!         if (length)
!             length = l;
!         if (height)
!             height = h;
!         return (image);
      }
!     
!     void pnm::put (ofstream & file, const char *image, u_int16 length, 
u_int16 height)
      {
!         char s[30];
!         
!         sprintf (s, "P6\n%d %d\n255\n", length, height);
!         file.write(s, sizeof (char) * strlen (s));
!         
!         file.write(image, 3 * length * height);
      }
!     
!     void pnm::pnm_gotonextline (ifstream & file)
      {
!         char buff;
!         
!         do file.read(&buff, 1);
!         while (buff != '\n');
      }
!     
!     int pnm::pnm_checkforcomment (ifstream & file)
      {
!         char buff;
!         
!         file.read(&buff, 1);
!         if (buff == '#')
!         {
!             pnm_gotonextline (file);
!             return (1);
!         }
!         else
!         {
!             file.seekg(-1, ios::cur);
!             return (0);
!         }
      }
  }

Index: screen.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/screen.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** screen.cc   18 Jul 2003 15:16:09 -0000      1.1.1.1
--- screen.cc   24 Jul 2003 12:57:58 -0000      1.2
***************
*** 25,50 ****
  #include "gfx/screen.h"
  
! using namespace gfx;
! 
! u_int16 screen::length_, screen::height_;
! u_int8 screen::bytes_per_pixel_;
! bool screen::fullscreen_;
! 
! bool (*screen::set_video_mode_p) (u_int16 nl, u_int16 nh, u_int8 depth) = 
NULL;
! void (*screen::update_p)() = NULL;
! u_int32 (*screen::trans_color_p)() = NULL;
! void (*screen::clear_p)() = NULL;
! 
! bool screen::set_video_mode(u_int16 nl, u_int16 nh, u_int8 depth)
  {
!     bool res = set_video_mode_p(nl, nh, depth); 
! 
!     if (res)
      {
!         length_ = nl;
!         height_ = nh;
!         bytes_per_pixel_ = depth;
!     }
! 
!     return res;
  }
--- 25,51 ----
  #include "gfx/screen.h"
  
! namespace gfx
  {
!     u_int16 screen::length_, screen::height_;
!     u_int8 screen::bytes_per_pixel_;
!     bool screen::fullscreen_;
!     
!     bool (*screen::set_video_mode_p) (u_int16 nl, u_int16 nh, u_int8 depth) = 
NULL;
!     void (*screen::update_p)() = NULL;
!     u_int32 (*screen::trans_color_p)() = NULL;
!     void (*screen::clear_p)() = NULL;
!     
!     bool screen::set_video_mode(u_int16 nl, u_int16 nh, u_int8 depth)
      {
!         bool res = set_video_mode_p(nl, nh, depth); 
!         
!         if (res)
!         {
!             length_ = nl;
!             height_ = nh;
!             bytes_per_pixel_ = depth;
!         }
!         
!         return res;
!     }    
  }

Index: surface.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/surface.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** surface.cc  18 Jul 2003 15:16:09 -0000      1.1.1.1
--- surface.cc  24 Jul 2003 12:57:58 -0000      1.2
***************
*** 25,100 ****
  #include "gfx/pnm.h"
  
! using namespace gfx;
  
! surface::surface()
  {
!     alpha_ = 255;
!     is_masked_ = false;
! }
! 
! surface::~surface()
! {
! }
! 
! bool surface::get_pnm (std::ifstream & file)
! {
!     void *rawdata;
!     u_int16 l, h; 
! 
!     rawdata = pnm::get (file, l, h);
! 
!     if (!rawdata) return false;
! 
!     clear (); 
!     /**
!      * @bug We don't take care of endianness here! Colors
!      * won't be rendered correctly on big-endian machines.
!      */
!     set_data(rawdata, l, h, 3, 0x0000ff, 0x00ff00, 0xff0000);
! 
!     free (rawdata);
! 
!     return true;
! }
! 
! bool surface::load_pnm (const std::string & fname)
! {
!     std::ifstream file(fname.c_str());
!     bool ret = true;
! 
!     if (!file.is_open())
!         return false;
!     ret = get_pnm (file);
!     file.close();
!     return ret;
! }
! 
! bool surface::put_pnm (std::ofstream & file) const
! {
!     /**
!      * @bug We don't take care of endianness here!
!      * 
!      */
!     void * rawdata = get_data(3, 0x0000ff, 0x00ff00,
!                               0xff0000);
! 
!     if (!rawdata) return false;
! 
!     pnm::put (file, (const char *)rawdata, length (), height ()); 
! 
!     free(rawdata);
! 
!     return true;
! }
! 
! bool surface::save_pnm (const std::string & fname) const
! {
!     std::ofstream file(fname.c_str());
!     bool ret = true;
! 
!     if (!file.is_open())
!         return false;
!     ret = put_pnm (file);
!     file.close();
!     return true;
  }
--- 25,102 ----
  #include "gfx/pnm.h"
  
! using namespace std;
  
! namespace gfx
  {
!     surface::surface()
!         : is_masked_(false), alpha_(255)
!     {
!     }
!     
!     surface::~surface()
!     {
!     }
!     
!     bool surface::get_pnm (ifstream & file)
!     {
!         void *rawdata;
!         u_int16 l, h; 
!         
!         rawdata = pnm::get (file, l, h);
!         
!         if (!rawdata) return false;
!         
!         clear (); 
!         /**
!          * @bug We don't take care of endianness here! Colors
!          * won't be rendered correctly on big-endian machines.
!          */
!         set_data(rawdata, l, h, 3, 0x0000ff, 0x00ff00, 0xff0000);
!         
!         free (rawdata);
!         
!         return true;
!     }
!     
!     bool surface::load_pnm (const string & fname)
!     {
!         ifstream file(fname.c_str());
!         bool ret = true;
!         
!         if (!file.is_open())
!             return false;
!         ret = get_pnm (file);
!         file.close();
!         return ret;
!     }
!     
!     bool surface::put_pnm (ofstream & file) const
!     {
!         /**
!          * @bug We don't take care of endianness here!
!          * 
!          */
!         void * rawdata = get_data(3, 0x0000ff, 0x00ff00,
!                                   0xff0000);
!         
!         if (!rawdata) return false;
!         
!         pnm::put (file, (const char *)rawdata, length (), height ()); 
!         
!         free(rawdata);
!         
!         return true;
!     }
!     
!     bool surface::save_pnm (const string & fname) const
!     {
!         ofstream file(fname.c_str());
!         bool ret = true;
!         
!         if (!file.is_open())
!             return false;
!         ret = put_pnm (file);
!         file.close();
!         return true;
!     }   
  }

Index: surface.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/surface.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** surface.h   18 Jul 2003 15:16:09 -0000      1.1.1.1
--- surface.h   24 Jul 2003 12:57:58 -0000      1.2
***************
*** 63,67 ****
           */
          virtual ~surface () = 0;
-     
  
          /**
--- 63,66 ----
***************
*** 277,281 ****
           * @sa copy ()
           */
!         virtual surface& operator = (surface& src) = 0;
  #endif
  
--- 276,280 ----
           * @sa copy ()
           */
!         virtual surface& operator = (const surface& src) = 0;
  #endif
  
***************
*** 285,289 ****
           * @sa operator = 
           */
!         void copy (surface& src) 
          {
              *this = src; 
--- 284,288 ----
           * @sa operator = 
           */
!         void copy (const surface& src) 
          {
              *this = src; 
***************
*** 413,421 ****
           * 
           */ 
!         surface (surface & src); 
      };
  }
  
  PYTHON_AS_CALLBACK_ARGUMENT(gfx::surface)
! 
  #endif
--- 412,421 ----
           * 
           */ 
!         surface (const surface & src); 
      };
  }
  
+ #ifndef SWIG
  PYTHON_AS_CALLBACK_ARGUMENT(gfx::surface)
! #endif // SWIG
  #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]