+// image can not 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
+enum Transparency
+{
+ Transparency_None,
+ Transparency_Mask,
+ Transparency_Alpha
+};
+
+// ----------------------------------------------------------------------------
+// local functions
+// ----------------------------------------------------------------------------
+
+// return the kind of transparency needed for this image assuming that it does
+// have transparent pixels, i.e. either Transparency_Alpha or Transparency_Mask
+static Transparency
+CheckTransparency(unsigned char **lines,
+ png_uint_32 x, png_uint_32 y, png_uint_32 w, png_uint_32 h,
+ size_t numColBytes);
+
+// init the alpha channel for the image and fill it with 1s up to (x, y)
+static unsigned char *InitAlpha(wxImage *image, png_uint_32 x, png_uint_32 y);
+
+// find a free colour for the mask in the PNG data array
+static void
+FindMaskColour(unsigned char **lines, png_uint_32 width, png_uint_32 height,
+ unsigned char& rMask, unsigned char& gMask, unsigned char& bMask);
+
+// is the pixel with this value of alpha a fully opaque one?
+static inline
+bool IsOpaque(unsigned char a)
+{
+ return a == 0xff;
+}
+
+// is the pixel with this value of alpha a fully transparent one?
+static inline
+bool IsTransparent(unsigned char a)
+{
+ return !a;
+}
+
+// ============================================================================
+// wxPNGHandler implementation
+// ============================================================================