]> git.saurik.com Git - wxWidgets.git/commitdiff
made wxImage::Scale() const to not confuse people any more and added
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Jul 1999 21:08:29 +0000 (21:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Jul 1999 21:08:29 +0000 (21:08 +0000)
a Rescale() which changes the image size "in place". Documented both
changes too.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2955 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/image.tex
include/wx/image.h
src/common/image.cpp

index abed2426348f1f54ac6cc49a683ebbf9d4a2fd59..c99c8a9ecd937ec4ae331c680ebeee1921c9aff3 100644 (file)
@@ -433,15 +433,50 @@ mimetype to the named file}
 \end{twocollist}}
 }
 
 \end{twocollist}}
 }
 
+\membersection{wxImage::Rescale}\label{wximagerescale}
+
+\func{wxImage}{Rescale}{\param{int}{ width}, \param{int}{ height}}
+
+Changes the size of the image in-place: after a call to this function, thei
+mage will have the given width and height.
+
+\wxheading{See also}
+
+\helpref{Scale}{wximagescale}
+
 \membersection{wxImage::Scale}\label{wximagescale}
 
 \membersection{wxImage::Scale}\label{wximagescale}
 
-\func{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}}
+\constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}}
 
 Returns a scaled version of the image. This is also useful for
 scaling bitmaps in general as the only other way to scale bitmaps
 
 Returns a scaled version of the image. This is also useful for
 scaling bitmaps in general as the only other way to scale bitmaps
-is to blit a wxMemoryDC into another wxMemoryDC. Windows can do such
-scaling itself but in the GTK port, scaling bitmaps is done using
-this routine internally.
+is to blit a wxMemoryDC into another wxMemoryDC.
+
+NB: although Windows can do such scaling itself but in the GTK port, scaling
+bitmaps is done using this routine internally.
+
+Example:
+
+\begin{verbatim}
+    // get the bitmap from somewhere
+    wxBitmap bmp = ...;
+
+    // rescale it to have size of 32*32
+    if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
+    {
+        wxImage image(bmp);
+        bmp = image.Scale(32, 32).ConvertToBitmap();
+
+        // another possibility:
+        image.Rescale(32, 32);
+        bmp = image;
+    }
+
+\end{verbatim}
+
+\wxheading{See also}
+
+\helpref{Rescale}{wximagerescale}
 
 \membersection{wxImage::SetData}\label{wximagesetdata}
 
 
 \membersection{wxImage::SetData}\label{wximagesetdata}
 
index 2a1c3ad5b07370c7aeee96cae01766206ff377e1..bd3d4845826b0570f66cb35f627db8167f6ca911 100644 (file)
@@ -195,13 +195,18 @@ public:
   
   // these functions get implemented in /src/(platform)/bitmap.cpp 
   wxImage( const wxBitmap &bitmap );
   
   // these functions get implemented in /src/(platform)/bitmap.cpp 
   wxImage( const wxBitmap &bitmap );
+  operator wxBitmap() const { return ConvertToBitmap(); }
   wxBitmap ConvertToBitmap() const;
 
   void Create( int width, int height );
   void Destroy();
   
   wxBitmap ConvertToBitmap() const;
 
   void Create( int width, int height );
   void Destroy();
   
-  wxImage Scale( int width, int height );
-  
+  // return the new image with size width*height
+  wxImage Scale( int width, int height ) const;
+
+  // rescales the image in place
+  wxImage Rescale( int width, int height ) { *this = Scale(width, height); }
+
   // these routines are slow but safe  
   void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
   unsigned char GetRed( int x, int y );
   // these routines are slow but safe  
   void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
   unsigned char GetRed( int x, int y );
@@ -238,18 +243,19 @@ public:
   void SetMask( bool mask = TRUE );
   bool HasMask() const;
 
   void SetMask( bool mask = TRUE );
   bool HasMask() const;
 
-  inline wxImage& operator = (const wxImage& image)
-    { if ((*this) == image)
-          return (*this);
+  wxImage& operator = (const wxImage& image)
+  {
+    if ( (*this) != image )
       Ref(image);
       Ref(image);
-      return *this; }
+    return *this;
+  }
 
 
-  inline bool operator == (const wxImage& image)
+  bool operator == (const wxImage& image)
     { return m_refData == image.m_refData; }
     { return m_refData == image.m_refData; }
-  inline bool operator != (const wxImage& image) 
+  bool operator != (const wxImage& image) 
     { return m_refData != image.m_refData; }
 
     { return m_refData != image.m_refData; }
 
-  static inline wxList& GetHandlers() { return sm_handlers; }
+  static wxList& GetHandlers() { return sm_handlers; }
   static void AddHandler( wxImageHandler *handler );
   static void InsertHandler( wxImageHandler *handler );
   static bool RemoveHandler( const wxString& name );
   static void AddHandler( wxImageHandler *handler );
   static void InsertHandler( wxImageHandler *handler );
   static bool RemoveHandler( const wxString& name );
index bb000882425f86786b9ff445351fe8a3d32a1157..b5c526628eab0ca8d43a6dd6eaf42ed1e8cb38b7 100644 (file)
@@ -150,7 +150,7 @@ void wxImage::Destroy()
     UnRef();
 }
 
     UnRef();
 }
 
-wxImage wxImage::Scale( int width, int height )
+wxImage wxImage::Scale( int width, int height ) const
 {
     wxImage image;
 
 {
     wxImage image;