UnRef();
wxCHECK_MSG( image.IsOk(), false, wxT("invalid image") );
- wxCHECK_MSG( depth == -1 || depth == 1, false, wxT("invalid bitmap depth") );
if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
return false;
- // create pixbuf if image has alpha and requested depth is compatible
- if (image.HasAlpha() && (depth == -1 || depth == 32))
+ if (depth == 32 || (depth == -1 && image.HasAlpha()))
return CreateFromImageAsPixbuf(image);
// otherwise create pixmap, if alpha is present it will be converted to mask
bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
{
- wxASSERT(image.HasAlpha());
-
int width = image.GetWidth();
int height = image.GetHeight();
for (int y = 0; y < height; y++, out += rowpad)
{
- for (int x = 0; x < width; x++, alpha++, out += 4, in += 3)
+ for (int x = 0; x < width; x++, out += 4, in += 3)
{
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
- out[3] = *alpha;
+ if (alpha)
+ out[3] = *alpha++;
}
}