X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f5c6eb5c178b44f4400495e06274ffd130635190..1e4786bb37ff247ce8f11cd0f7305136357c6f40:/src/mac/carbon/pnghand.cpp diff --git a/src/mac/carbon/pnghand.cpp b/src/mac/carbon/pnghand.cpp index 358515d283..52b07f6e60 100644 --- a/src/mac/carbon/pnghand.cpp +++ b/src/mac/carbon/pnghand.cpp @@ -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;