Is it possible to get bitmap image with transparency channel(RGBA 32 bits)?
If so how? In Direct3D demo bitmap for texture returned with black background.
Zeratul wrote:Is it possible to get bitmap image with transparency channel(RGBA 32 bits)? If so how?
Zeratul wrote:In Direct3D demo bitmap for texture returned with black background.
Code: Select all
// Create FlashPlayerControl as a hidden child control
// in transparent mode (see style FPCS_TRANSPARENT)
g_hwndFlashPlayerControl =
CreateWindowEx(WS_EX_LAYERED,
WC_FLASH,
NULL,
WS_POPUP | WS_VISIBLE,
0,
0,
320,
240,
g_hDlg,
NULL,
NULL,
NULL);
Code: Select all
MoveWindow(g_hwndFlashPlayerControl, 0, 0, m_mode->width, m_mode->height, TRUE);
SFPCGetFrameBitmap FPCGetFrameBitmap = { 0 };
::SendMessage(g_hwndFlashPlayerControl, FPCM_GET_FRAME_BITMAP, 0, (LPARAM)&FPCGetFrameBitmap);
HBITMAP pwebcam_HBITMAP = FPCGetFrameBitmap.hBitmap;
HPALETTE hpal = (HPALETTE) GetStockObject(DEFAULT_PALETTE);
Bitmap* pflash_bitmap = Bitmap::FromHBITMAP(pwebcam_HBITMAP, hpal);
amit wrote:The movie is displayed in a transparent window (I use WS_VISIBLE so I can see the flash window) but the bitmap I get has black background.
Code: Select all
SFPCGetFrameBitmap FPCGetFrameBitmap = { 0 };
::SendMessage(m_hwndFlashPlayerControl, FPCM_GET_FRAME_BITMAP, 0, (LPARAM)&FPCGetFrameBitmap);
HBITMAP hBitmap = FPCGetFrameBitmap.hBitmap;
BITMAP bmp_info;
GetObject(hBitmap, sizeof(bmp_info), &bmp_info);
DWORD* pBitmapBits = (DWORD*)bmp_info.bmBits;
const DWORD dwNewColor = 0x00ff0000;
for (int j = 0; j < bmp_info.bmHeight; j++)
for (int i = 0; i < bmp_info.bmWidth; i++)
{
DWORD dwPixelColor = *pBitmapBits;
// dwPixelColor = 0xAARRGGBB
if ( 0 == ( dwPixelColor & 0xff000000 ) )
{
dwPixelColor = (dwPixelColor & 0xff000000) | dwNewColor;
*pBitmapBits = dwPixelColor;
}
pBitmapBits++;
}
// For testing
CImage Image;
Image.Attach(hBitmap);
Image.Save(_T("1.bmp"));
Image.Detach();
Code: Select all
SFPCGetFrameBitmap FPCGetFrameBitmap = { 0 };
::SendMessage(g_hwndFlashPlayerControl, FPCM_GET_FRAME_BITMAP, 0, (LPARAM)&FPCGetFrameBitmap);
HBITMAP pflash_HBITMAP = FPCGetFrameBitmap.hBitmap;
BITMAP flash_BITMAP;
GetObject(pflash_HBITMAP, sizeof(flash_BITMAP), &flash_BITMAP);
BYTE* pflash_buffer = (BYTE*)flash_BITMAP.bmBits;
pflash_buffer = pflash_buffer + flash_BITMAP.bmWidth * (flash_BITMAP.bmHeight - 1) * NUM_RGBA_CHANNELS;
INT stride = - (INT)flash_BITMAP.bmWidth * NUM_RGBA_CHANNELS;
Bitmap* pflash_bitmap = new Bitmap(
(INT)flash_BITMAP.bmWidth,
(INT)flash_BITMAP.bmHeight,
stride,
PixelFormat32bppPARGB,
pflash_buffer
);
...
Graphics graphics(panother_bitmap);
graphics.SetCompositingMode(CompositingModeSourceOver);
Status status = graphics.DrawImage(
pflash_bitmap,
0,
0
);
Users browsing this forum: No registered users and 140 guests