X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6868c3eb8fabd2b3a04446b8a5fc752fa9e78caf..bf60426831535738b1b784629f08e9dd00bf9ecc:/src/mac/carbon/pnghand.cpp?ds=inline diff --git a/src/mac/carbon/pnghand.cpp b/src/mac/carbon/pnghand.cpp index 113365c878..52b07f6e60 100644 --- a/src/mac/carbon/pnghand.cpp +++ b/src/mac/carbon/pnghand.cpp @@ -31,7 +31,7 @@ # include #endif -#ifndef __WXMAC_X__ +#ifndef __DARWIN__ # include #endif #include "wx/msgdlg.h" @@ -39,6 +39,7 @@ #include "wx/bitmap.h" #include "wx/mac/pnghand.h" #include "wx/mac/pngread.h" +#include "wx/mac/private.h" extern "C" { #include "png.h" @@ -110,13 +111,12 @@ wxPNGReader::Create(int width, int height, int depth, int colortype) Width = width; Height = height; Depth = depth; ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0); delete m_palette; - delete[] RawImage ; - RawImage = 0; - m_palette = 0; + m_palette = NULL; + delete[] RawImage; + RawImage = NULL; - if (lpbi) - { - wxMacDestroyGWorld( lpbi ) ; + if (lpbi) { + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; } lpbi = wxMacCreateGWorld( Width , Height , Depth); if (lpbi) @@ -133,11 +133,18 @@ wxPNGReader::Create(int width, int height, int depth, int colortype) wxPNGReader::~wxPNGReader ( ) { - delete[] RawImage ; - if (lpbi) { - wxMacDestroyGWorld( lpbi ) ; - } - delete m_palette; + if (RawImage != NULL) { + delete[] RawImage ; + RawImage = NULL; + } + if (lpbi) { + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + lpbi = NULL; + } + if (m_palette != NULL) { + delete m_palette; + m_palette = NULL; + } } @@ -258,11 +265,13 @@ wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct) void wxPNGReader::NullData() { if (lpbi) { - wxMacDestroyGWorld( lpbi ) ; + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + lpbi = NULL; + } + if (m_palette != NULL) { + delete m_palette; + m_palette = NULL; } - delete m_palette; - lpbi = NULL; - m_palette = NULL; } wxBitmap* wxPNGReader::GetBitmap(void) @@ -431,7 +440,7 @@ bool wxPNGReader::ReadFile(char * ImageFileName) if (!info_ptr) { fclose(fp); - delete(png_ptr); + delete png_ptr; return FALSE; } /* set error handling */ @@ -439,8 +448,8 @@ bool wxPNGReader::ReadFile(char * ImageFileName) { png_read_destroy(png_ptr, info_ptr, (png_info *)0); fclose(fp); - delete(png_ptr); - delete(info_ptr); + delete png_ptr; + delete info_ptr; /* If we get here, we had a problem reading the file */ return FALSE; @@ -512,7 +521,7 @@ bool wxPNGReader::ReadFile(char * ImageFileName) GetGWorld( &origPort , &origDevice ) ; // ignore shapedc - SetGWorld( lpbi , NULL ) ; + SetGWorld( (GWorldPtr) lpbi , NULL ) ; do { // (unsigned char *)iter.GetRow(); @@ -529,7 +538,7 @@ bool wxPNGReader::ReadFile(char * ImageFileName) { if ( pixel_depth == 8 ) { - for ( int i = 0 ; i < info_ptr->width ; ++i ) + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) { png_color_struct* color ; RGBColor col ; @@ -573,7 +582,7 @@ bool wxPNGReader::ReadFile(char * ImageFileName) } else { - for ( int i = 0 ; i < info_ptr->width ; ++i ) + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) { png_color_struct* color ; RGBColor col ; @@ -592,7 +601,7 @@ bool wxPNGReader::ReadFile(char * ImageFileName) } else { - for ( int i = 0 ; i < info_ptr->width ; ++i ) + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) { png_color_struct* color ; RGBColor col ; @@ -622,8 +631,8 @@ bool wxPNGReader::ReadFile(char * ImageFileName) png_read_destroy(png_ptr, info_ptr, (png_info *)0); /* free the structures */ - delete(png_ptr); - delete(info_ptr); + delete png_ptr; + delete info_ptr; /* close the file */ fclose(fp); @@ -662,7 +671,7 @@ bool wxPNGReader::SaveFile(char * ImageFileName) if (!info_ptr) { fclose(fp); - delete(png_ptr); + delete png_ptr; return FALSE; } @@ -671,8 +680,8 @@ bool wxPNGReader::SaveFile(char * ImageFileName) { png_write_destroy(png_ptr); fclose(fp); - delete(png_ptr); - delete(info_ptr); + delete png_ptr; + delete info_ptr; /* If we get here, we had a problem reading the file */ return FALSE; @@ -769,8 +778,8 @@ bool wxPNGReader::SaveFile(char * ImageFileName) delete[] (info_ptr->palette); /* free the structures */ - delete(png_ptr); - delete(info_ptr); + delete png_ptr; + delete info_ptr; /* close the file */ fclose(fp); @@ -823,7 +832,7 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) if ( !GetPalette() ) return FALSE; - ofstream str(filename); + wxSTD ofstream str(filename); if ( str.bad() ) return FALSE; @@ -887,7 +896,7 @@ bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla return FALSE; } -bool wxPNGFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *pal) +bool wxPNGFileHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *pal) { return FALSE; }