Bug: can't add user-defined images using .xpm

Feedback and Reviews for Audacity 2.x
Forum rules
This board is ONLY for general feedback and discussion about Audacity 2.X.

If you require help, or think you have found a "bug", please post on the forum board relevant to your operating system.
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
jik
Posts: 3
Joined: Tue Aug 15, 2017 4:35 pm
Operating System: Windows 7

Bug: can't add user-defined images using .xpm

Post by jik » Tue Aug 15, 2017 5:03 pm

There is a bug in overloaded function RegisterImage(iIndex, pXpm, Name). This function is used if we want to add user-defined image using .xpm file. The Mask is not set. As a result, initAlpha() clears the image. SetMaskColour() should be added before initAlpha():

Code: Select all

void ThemeBase::RegisterImage( int &iIndex, char const ** pXpm, const wxString & Name ) {
   wxASSERT( iIndex == -1 ); // Don't initialise same bitmap twice!
   wxImage Img(pXpm);
   Img.SetMaskColour(0xDE, 0xDE, 0xDE); // <-- missed call
   Img.InitAlpha();
   RegisterImage( iIndex, Img, Name );
}

steve
Site Admin
Posts: 47254
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Bug: can't add user-defined images using .xpm

Post by steve » Tue Aug 15, 2017 5:16 pm

Which version are you looking at? That does not appear to quite match the current code: https://github.com/audacity/audacity/bl ... /Theme.cpp
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

jik
Posts: 3
Joined: Tue Aug 15, 2017 4:35 pm
Operating System: Windows 7

Re: Bug: can't add user-defined images using .xpm

Post by jik » Tue Aug 15, 2017 5:24 pm

line 457 by your github link:

Code: Select all

void ThemeBase::RegisterImage( int &iIndex, char const ** pXpm, const wxString & Name )
{
   wxASSERT( iIndex == -1 ); // Don't initialise same bitmap twice!
   wxBitmap Bmp( pXpm ); // a 24 bit bitmap.
   wxImage Img( Bmp.ConvertToImage() );
   Img.SetMaskColour(0xDE, 0xDE, 0xDE); // <-- missed call
   Img.InitAlpha();
   RegisterImage( iIndex, Img, Name );
}

steve
Site Admin
Posts: 47254
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Bug: can't add user-defined images using .xpm

Post by steve » Tue Aug 15, 2017 5:41 pm

I'm not familiar with this part of the code, so all I can do is pass this on to the developer's mailing list, or you can do that yourself if you prefer.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

jik
Posts: 3
Joined: Tue Aug 15, 2017 4:35 pm
Operating System: Windows 7

Re: Bug: can't add user-defined images using .xpm

Post by jik » Tue Aug 15, 2017 5:58 pm

Function wxImage::InitAlpha() check the Mask. If there is no Mask it just clears the image:

Code: Select all

    if ( HasMask() )
    {
      ...
    }
    else // no mask
    {
        // make the image fully opaque
        memset(alpha, wxIMAGE_ALPHA_OPAQUE, lenAlpha);
    }
Could you please pass the report on the developer's mailing list?

steve
Site Admin
Posts: 47254
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Bug: can't add user-defined images using .xpm

Post by steve » Tue Aug 15, 2017 6:04 pm

jik wrote:Could you please pass the report on the developer's mailing list?
Sure, will do. Thanks.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply