fixed completely broken CheckForTransparency()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-07-23 12:48:11 +00:00
parent cef338d391
commit 36308e0e02

View File

@@ -74,7 +74,7 @@ enum Transparency
// return the kind of transparency needed for this image assuming that it does // return the kind of transparency needed for this image assuming that it does
// have transparent pixels, i.e. either Transparency_Alpha or Transparency_Mask // have transparent pixels, i.e. either Transparency_Alpha or Transparency_Mask
static Transparency static Transparency
CheckTransparency(const unsigned char *ptr, CheckTransparency(unsigned char **lines,
png_uint_32 x, png_uint_32 y, png_uint_32 w, png_uint_32 h, png_uint_32 x, png_uint_32 y, png_uint_32 w, png_uint_32 h,
size_t numColBytes); size_t numColBytes);
@@ -210,13 +210,13 @@ PNGLINKAGEMODE wx_png_warning(png_structp png_ptr, png_const_charp message)
// need a full blown alpha channel in wxImage // need a full blown alpha channel in wxImage
// //
// parameters: // parameters:
// ptr the start of the data to examine // lines raw PNG data
// x, y starting position // x, y starting position
// w, h size of the image // w, h size of the image
// numColBytes number of colour bytes (1 for grey scale, 3 for RGB) // numColBytes number of colour bytes (1 for grey scale, 3 for RGB)
// (NB: alpha always follows the colour bytes) // (NB: alpha always follows the colour bytes)
Transparency Transparency
CheckTransparency(const unsigned char *ptr, CheckTransparency(unsigned char **lines,
png_uint_32 x, png_uint_32 y, png_uint_32 w, png_uint_32 h, png_uint_32 x, png_uint_32 y, png_uint_32 w, png_uint_32 h,
size_t numColBytes) size_t numColBytes)
{ {
@@ -225,15 +225,16 @@ CheckTransparency(const unsigned char *ptr,
// suppose that a mask will suffice and check all the remaining alpha // suppose that a mask will suffice and check all the remaining alpha
// values to see if it does // values to see if it does
unsigned const char *ptr2 = ptr; for ( ; y < h; y++ )
for ( png_uint_32 y2 = y; y2 < h; y2++ )
{ {
unsigned const char *ptr = lines[y] + x;
for ( png_uint_32 x2 = x; x2 < w; x2++ ) for ( png_uint_32 x2 = x; x2 < w; x2++ )
{ {
// skip the grey or colour byte(s) // skip the grey or colour byte(s)
ptr2 += numColBytes; ptr += numColBytes;
unsigned char a2 = *ptr2++; unsigned char a2 = *ptr++;
if ( !IsTransparent(a2) && !IsOpaque(a2) ) if ( !IsTransparent(a2) && !IsOpaque(a2) )
{ {
@@ -365,7 +366,7 @@ void CopyDataFromPNG(wxImage *image,
// only, otherwisewe need the latter // only, otherwisewe need the latter
transparency = CheckTransparency transparency = CheckTransparency
( (
ptrSrc, lines,
x, y, x, y,
width, height, width, height,
1 1
@@ -437,7 +438,7 @@ void CopyDataFromPNG(wxImage *image,
{ {
transparency = CheckTransparency transparency = CheckTransparency
( (
ptrSrc, lines,
x, y, x, y,
width, height, width, height,
3 3