]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
wxSetlocale() doesn't always return NULL
[wxWidgets.git] / src / common / image.cpp
index 163154260ef10d5180e70a15ed4009bd36e01d16..29e7087ea3619bcbc34b3d4810af5e9aed3b8fe7 100644 (file)
@@ -45,7 +45,6 @@
 
 class wxImageRefData: public wxObjectRefData
 {
-
 public:
     wxImageRefData();
     ~wxImageRefData();
@@ -72,7 +71,8 @@ wxImageRefData::wxImageRefData()
 
 wxImageRefData::~wxImageRefData()
 {
-    if (m_data) free( m_data );
+    if (m_data) 
+        free( m_data );
 }
 
 wxList wxImage::sm_handlers;
@@ -195,8 +195,8 @@ wxImage wxImage::GetSubImage( const wxRect &rect ) const
 
     wxCHECK_MSG( Ok(), image, wxT("invalid image") );
 
-    wxCHECK_MSG( (rect.GetLeft()>=0) && (rect.GetTop()>=0) && (rect.GetRight()<=GetWidth()) && (rect.GetBottom()<=GetHeight())
-                 image, wxT("invalid subimage size") );
+    wxCHECK_MSG( (rect.GetLeft()>=0) && (rect.GetTop()>=0) && (rect.GetRight()<=GetWidth()) && (rect.GetBottom()<=GetHeight()),
+                 image, wxT("invalid subimage size") );
 
     int subwidth=rect.GetWidth();
     const int subheight=rect.GetHeight();
@@ -383,9 +383,9 @@ bool wxImage::LoadFile( const wxString& filename, long type )
         wxFileInputStream stream(filename);
         return LoadFile(stream, type);
     }
-
-    else {
-        wxLogError( wxT("Can't load image from file '%s': file does not exist."), filename.c_str() );
+    else 
+    {
+        wxLogError( _("Can't load image from file '%s': file does not exist."), filename.c_str() );
 
         return FALSE;
     }
@@ -402,9 +402,9 @@ bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype )
         wxFileInputStream stream(filename);
         return LoadFile(stream, mimetype);
     }
-
-    else {
-        wxLogError( wxT("Can't load image from file '%s': file does not exist."), filename.c_str() );
+    else 
+    {
+        wxLogError( _("Can't load image from file '%s': file does not exist."), filename.c_str() );
 
         return FALSE;
     }
@@ -483,7 +483,7 @@ bool wxImage::LoadFile( wxInputStream& stream, long type )
 
         }
 
-        wxLogWarning( wxT("No handler found for this image.") );
+        wxLogWarning( _("No handler found for image type.") );
         return FALSE;
     }
 
@@ -491,7 +491,7 @@ bool wxImage::LoadFile( wxInputStream& stream, long type )
 
     if (handler == NULL)
     {
-        wxLogWarning( wxT("No image handler for type %d defined."), type );
+        wxLogWarning( _("No image handler for type %d defined."), type );
 
         return FALSE;
     }
@@ -509,7 +509,7 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype )
 
     if (handler == NULL)
     {
-        wxLogWarning( wxT("No image handler for type %s defined."), mimetype.GetData() );
+        wxLogWarning( _("No image handler for type %s defined."), mimetype.GetData() );
 
         return FALSE;
     }
@@ -525,7 +525,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, int type )
 
     if (handler == NULL)
     {
-        wxLogWarning( wxT("No image handler for type %d defined."), type );
+        wxLogWarning( _("No image handler for type %d defined."), type );
 
         return FALSE;
     }
@@ -541,7 +541,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, const wxString& mimetype )
 
     if (handler == NULL)
     {
-        wxLogWarning( wxT("No image handler for type %s defined."), mimetype.GetData() );
+        wxLogWarning( _("No image handler for type %s defined."), mimetype.GetData() );
 
         return FALSE;
     }
@@ -656,7 +656,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxImageHandler,wxObject)
 #endif
 
 #if wxUSE_STREAMS
-bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream), bool WXUNUSED(verbose) )
+bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream), bool WXUNUSED(verbose), int WXUNUSED(index) )
 {
     return FALSE;
 }
@@ -666,9 +666,13 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSE
     return FALSE;
 }
 
+int wxImageHandler::GetImageCount( wxInputStream& WXUNUSED(stream) )
+{
+    return 1;
+}
+
 bool wxImageHandler::CanRead( const wxString& name )
 {
-#if wxUSE_STREAMS
     if (wxFileExists(name))
     {
         wxFileInputStream stream(name);
@@ -676,17 +680,13 @@ bool wxImageHandler::CanRead( const wxString& name )
     }
 
     else {
-        wxLogError( wxT("Can't check image format of file '%s': file does not exist."), name.c_str() );
+        wxLogError( _("Can't check image format of file '%s': file does not exist."), name.c_str() );
 
         return FALSE;
     }
-#else // !wxUSE_STREAMS
     return FALSE;
-#endif // wxUSE_STREAMS
 }
 
-
-
 #endif // wxUSE_STREAMS
 
 //-----------------------------------------------------------------------------
@@ -1555,7 +1555,6 @@ wxImage::wxImage( const wxBitmap &bitmap )
         for (int i = 0; i < bitmap.GetWidth(); i++)
         {
             wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j );
-            // pixel = wxINT32_SWAP_ON_BE( pixel );
             if (bpp <= 8)
             {
                 data[pos] = cmap->colors[pixel].red >> 8;
@@ -1563,19 +1562,31 @@ wxImage::wxImage( const wxBitmap &bitmap )
                 data[pos+2] = cmap->colors[pixel].blue >> 8;
             } else if (bpp == 15)
             {
+#if (wxBYTE_ORDER == wxBIG_ENDIAN)
+                // ?
+#endif
                 data[pos] = (pixel >> 7) & 0xf8;
                 data[pos+1] = (pixel >> 2) & 0xf8;
                 data[pos+2] = (pixel << 3) & 0xf8;
             } else if (bpp == 16)
             {
+#if (wxBYTE_ORDER == wxBIG_ENDIAN)
+                // ?
+#endif
                 data[pos] = (pixel >> 8) & 0xf8;
                 data[pos+1] = (pixel >> 3) & 0xfc;
                 data[pos+2] = (pixel << 3) & 0xf8;
             } else
             {
+#if (wxBYTE_ORDER == wxBIG_ENDIAN)
+                data[pos] = (pixel) & 0xff;            // Red
+                data[pos+1] = (pixel >> 8) & 0xff;     // Green
+                data[pos+2] = (pixel >> 16) & 0xff;    // Blue
+#else
                 data[pos] = (pixel >> 16) & 0xff;
                 data[pos+1] = (pixel >> 8) & 0xff;
                 data[pos+2] = pixel & 0xff;
+#endif
             }
 
             if (gdk_image_mask)