I just wrote my own, if anyone knows how to have qt do this internally or a better way to do this let me know, here's the code in case anyone else is having the same problem:

Qt Code:
  1. QImage CreateAlphaMask( const QImage& srcImage )
  2. {
  3. // QImage one only creates alpha mask for alpha values greater than 128... need it to be all alpha greater than 0
  4.  
  5. int nWidth = m_PatchSetImage.width();
  6. int nHeight = m_PatchSetImage.height();
  7. int nDepth = m_PatchSetImage.depth();
  8.  
  9. QImage alphaMask( nWidth, nHeight, QImage::Format_MonoLSB );
  10. alphaMask.setColor( 0, 0xffffffff );
  11. alphaMask.setColor( 1, 0xff000000 );
  12.  
  13. // initialize everything to 0 first
  14. memset( alphaMask.bits(), 0, alphaMask.numBytes() );
  15.  
  16. switch ( nDepth )
  17. {
  18. case 32:
  19. for ( int y = 0; y < nHeight; ++y )
  20. {
  21. unsigned char* pMaskData = alphaMask.scanLine( y );
  22. unsigned int* pSrcData = (unsigned int*)srcImage.scanLine( y );
  23.  
  24. for ( int x = 0; x < nWidth; ++x )
  25. {
  26. if ( *pSrcData++ >> 24 )
  27. {
  28. pMaskData[x/8] |= 1 << (x % 8);
  29. }
  30. }
  31. }
  32. break;
  33. default:
  34. // Set mask to all 1's if not 32 bit depth
  35. memset( alphaMask.bits(), 0xFF, alphaMask.numBytes() );
  36. break;
  37. }
  38.  
  39. return alphaMask;
  40. }
To copy to clipboard, switch view to plain text mode