X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9b73db3c34aefd98080b425459322fa821ae271f..58c837a4e67c0996134cc0947691dc09c5f26687:/src/msw/pnghand.cpp diff --git a/src/msw/pnghand.cpp b/src/msw/pnghand.cpp index 0cb773c7c0..543e96f6a2 100644 --- a/src/msw/pnghand.cpp +++ b/src/msw/pnghand.cpp @@ -32,10 +32,11 @@ #endif #include -#include -#include -#include -#include +#include "wx/palette.h" +#include "wx/bitmap.h" +#include "wx/utils.h" +#include "wx/msw/pngread.h" +#include "wx/msw/dibutils.h" extern "C" { #include "../png/png.h" @@ -130,9 +131,9 @@ wxPNGReader::Create(int width, int height, int depth, int colortype) } RawImage = 0; Palette = 0; - lpbi = DibCreate(Depth, Width, Height); + lpbi = wxDibCreate(Depth, Width, Height); if (lpbi) { - RawImage = (ImagePointerType)DibPtr(lpbi); + RawImage = (ImagePointerType)wxDibPtr(lpbi); EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4; imageOK = TRUE; } @@ -216,7 +217,7 @@ bool wxPNGReader::SetPalette(wxPalette* colourmap) return FALSE; ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); Palette = colourmap; - return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } bool @@ -230,7 +231,7 @@ wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b) if (!b) b = g; Palette->Create(n, r, g, b); ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); - return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } bool @@ -256,7 +257,7 @@ wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct) Palette->Create(n, r, g, b); ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); - return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + return (wxDibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } void wxPNGReader::NullData() @@ -312,8 +313,9 @@ bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap) bitmap->SetDepth(GetDepth()); if ( GetDepth() > 1 && Palette ) bitmap->SetPalette(*Palette); +#if WXWIN_COMPATIBILITY_2 bitmap->SetOk(TRUE); - +#endif // WXWIN_COMPATIBILITY_2 // Make a mask if appropriate if ( bgindex > -1 ) @@ -385,35 +387,30 @@ wxMask *wxPNGReader::CreateMask() bool wxPNGReader::ReadFile(wxChar * ImageFileName) { - int number_passes; - if (ImageFileName) wxStrcpy(filename, ImageFileName); - FILE *fp; - png_struct *png_ptr; - png_info *info_ptr; - /* open the file */ - fp = fopen(wxConvFile.cWX2MB(filename), "rb"); + FILE *fp = fopen(wxConvFile.cWX2MB(filename), "rb"); if (!fp) return FALSE; /* allocate the necessary structures */ - png_ptr = new (png_struct); + png_struct *png_ptr = new (png_struct); if (!png_ptr) { fclose(fp); return FALSE; } - info_ptr = new (png_info); + png_info *info_ptr = new (png_info); if (!info_ptr) { fclose(fp); delete(png_ptr); return FALSE; } + /* set error handling */ if (setjmp(png_ptr->jmpbuf)) { @@ -477,6 +474,7 @@ bool wxPNGReader::ReadFile(wxChar * ImageFileName) byte *row_pointers = new byte[row_stride]; /* turn on interlace handling */ + int number_passes; if (info_ptr->interlace_type) number_passes = png_set_interlace_handling(png_ptr); else @@ -768,7 +766,7 @@ bool wxPNGReader::SaveXPM(wxChar *filename, wxChar *name) return TRUE; } -#include +#include "wx/msw/pnghand.h" IMPLEMENT_DYNAMIC_CLASS(wxPNGFileHandler, wxBitmapHandler)