X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f2c8079119e5887329d1cba5677498d9f6443f62..0f5378d414cb68caaa535199c1af12dec1720c3d:/src/common/imagpng.cpp?ds=inline diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index c0b1939510..81c411619b 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -43,7 +43,7 @@ // constants // ---------------------------------------------------------------------------- -// image can not have any transparent pixels at all, have only 100% opaque +// image cannot have any transparent pixels at all, have only 100% opaque // and/or 100% transparent pixels in which case a simple mask is enough to // store this information in wxImage or have a real alpha channel in which case // we need to have it in wxImage as well @@ -116,11 +116,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler) // First, let me describe what's the problem: libpng uses jmp_buf in // its png_struct structure. Unfortunately, this structure is // compiler-specific and may vary in size, so if you use libpng compiled -// as DLL with another compiler than the main executable, it may not work -// (this is for example the case with wxMGL port and SciTech MGL library -// that provides custom runtime-loadable libpng implementation with jmpbuf -// disabled altogether). Luckily, it is still possible to use setjmp() & -// longjmp() as long as the structure is not part of png_struct. +// as DLL with another compiler than the main executable, it may not work. +// Luckily, it is still possible to use setjmp() & longjmp() as long as the +// structure is not part of png_struct. // // Sadly, there's no clean way to attach user-defined data to png_struct. // There is only one customizable place, png_struct.io_ptr, which is meant @@ -558,7 +556,7 @@ wxPNGHandler::LoadFile(wxImage *image, image->Create((int)width, (int)height, (bool) false /* no need to init pixels */); - if (!image->Ok()) + if (!image->IsOk()) goto error; // initialize all line pointers to NULL to ensure that they can be safely @@ -569,7 +567,7 @@ wxPNGHandler::LoadFile(wxImage *image, for (i = 0; i < height; i++) { - if ((lines[i] = (unsigned char *)malloc( (size_t)(width * (sizeof(unsigned char) * 4)))) == NULL) + if ((lines[i] = (unsigned char *)malloc( (size_t)(width * 4))) == NULL) goto error; } @@ -660,7 +658,7 @@ error: wxLogError(_("Couldn't load a PNG image - file is corrupted or not enough memory.")); } - if ( image->Ok() ) + if ( image->IsOk() ) { image->Destroy(); } @@ -795,15 +793,13 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos #endif ; - png_color_8 mask; + png_color_8 mask = { 0, 0, 0, 0, 0 }; if (bHasMask) { mask.red = image->GetMaskRed(); mask.green = image->GetMaskGreen(); mask.blue = image->GetMaskBlue(); - mask.alpha = 0; - mask.gray = 0; } PaletteMap palette;