MCPcopy Create free account
hub / github.com/audacity/audacity / MaskedImage

Method MaskedImage

libraries/lib-theme/Theme.cpp:292–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292wxImage ThemeBase::MaskedImage( char const ** pXpm, char const ** pMask )
293{
294 wxBitmap Bmp1( pXpm );
295 wxBitmap Bmp2( pMask );
296
297// wxLogDebug( wxT("Image 1: %i Image 2: %i"),
298// Bmp1.GetDepth(), Bmp2.GetDepth() );
299
300 // We want a 24-bit-depth bitmap if all is working, but on some
301 // platforms it might just return -1 (which means best available
302 // or not relevant).
303 // JKC: \todo check that we're not relying on 24 bit elsewhere.
304 wxASSERT( Bmp1.GetDepth()==-1 || Bmp1.GetDepth()==24);
305 wxASSERT( Bmp1.GetDepth()==-1 || Bmp2.GetDepth()==24);
306
307 int i,nBytes;
308 nBytes = Bmp1.GetWidth() * Bmp1.GetHeight();
309 wxImage Img1( Bmp1.ConvertToImage());
310 wxImage Img2( Bmp2.ConvertToImage());
311
312// unsigned char *src = Img1.GetData();
313 unsigned char *mk = Img2.GetData();
314 //wxImage::setAlpha requires memory allocated with malloc, not NEW
315 MallocString<unsigned char> alpha{
316 static_cast<unsigned char*>(malloc( nBytes )) };
317
318 // Extract alpha channel from second XPM.
319 for(i=0;i<nBytes;i++)
320 {
321 alpha[i] = mk[0];
322 mk+=3;
323 }
324
325 Img1.SetAlpha( alpha.release() );
326
327 //dmazzoni: the top line does not work on wxGTK
328 //wxBitmap Result( Img1, 32 );
329 //wxBitmap Result( Img1 );
330
331 return Img1;
332}
333
334// Legacy function to allow use of an XPM where no theme image was defined.
335// Bit depth and mask needs review.

Callers

nothing calls this directly

Calls 4

GetHeightMethod · 0.80
GetWidthMethod · 0.45
GetDataMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected