Click here to Skip to main content
15,895,084 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how can I display a bitmap with an alpha chanel? Pin
rp_suman7-Jul-08 2:36
rp_suman7-Jul-08 2:36 
GeneralRe: how can I display a bitmap with an alpha chanel? Pin
danginkgo7-Jul-08 3:04
danginkgo7-Jul-08 3:04 
GeneralRe: how can I display a bitmap with an alpha chanel? Pin
rp_suman7-Jul-08 3:43
rp_suman7-Jul-08 3:43 
GeneralRe: how can I display a bitmap with an alpha chanel? Pin
danginkgo7-Jul-08 19:30
danginkgo7-Jul-08 19:30 
GeneralRe: how can I display a bitmap with an alpha chanel? Pin
rp_suman8-Jul-08 4:36
rp_suman8-Jul-08 4:36 
QuestionRe: how can I display a bitmap with an alpha chanel? Pin
Mark Salsbery7-Jul-08 6:25
Mark Salsbery7-Jul-08 6:25 
AnswerRe: how can I display a bitmap with an alpha chanel? Pin
danginkgo7-Jul-08 19:17
danginkgo7-Jul-08 19:17 
GeneralRe: how can I display a bitmap with an alpha chanel? Pin
Mark Salsbery8-Jul-08 6:12
Mark Salsbery8-Jul-08 6:12 
danginkgo wrote:
When I display the image using AlphaBlend() function the image looks the same as when I displayed it using BitBlt().


Then all the alpha channel values must be 255.

danginkgo wrote:
Is it posible using this function?


Yes. Try something like this, creating and rendering your own 32bpp ARGB bitmap:
LONG lImageWidth = 640;
LONG lImageHeight = 480;
WORD wBitsPerPixel = 32;
 
LONG lStride = lImageWidth * 4;
 
BYTE* pBitmapBits;
 
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = lImageWidth;
bmi.bmiHeader.biHeight = lImageHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = wBitsPerPixel;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = lStride * lImageHeight;
//bmi.bmiHeader.biXPelsPerMeter = 0;
//bmi.bmiHeader.biYPelsPerMeter = 0;
//bmi.bmiHeader.biClrUsed = 0;
//bmi.bmiHeader.biClrImportant = 0;

HDC hdcMem = ::CreateCompatibleDC(0);

HBITMAP hBitmap = ::CreateDIBSection(hdcMem, &bmi, DIB_RGB_COLORS, (void**)&pBitmapBits, NULL, 0);

if (hBitmap)
{   
	memset(pBitmapBits, 0, bmi.bmiHeader.biSizeImage);
	RGBQUAD *pCurPixel = (RGBQUAD *)pBitmapBits;
	int PixelCount = lImageWidth * lImageHeight;
	while (PixelCount > 0)
	{
		(*pCurPixel).rgbRed =      0x00;
		(*pCurPixel).rgbGreen =    0x00;
		(*pCurPixel).rgbBlue =     0xA0;
		(*pCurPixel).rgbReserved = 0x80;
		pCurPixel++;
		PixelCount--;
	}

	HGDIOBJ hOldBitmap = ::SelectObject(hdcMem, hBitmap);

	HDC hClientDC = ::GetDC(*this);

	HPEN hPen = ::CreatePen(PS_SOLID, 10, RGB(255,0,128));
	HGDIOBJ hOldPen = ::SelectObject(hClientDC, hPen);
	::MoveToEx(hClientDC, 0, 0, NULL);
	::LineTo(hClientDC, 650, 490);
	::SelectObject(hClientDC, hOldPen);
	::DeleteObject(hPen);

	BLENDFUNCTION bf;
	bf.BlendOp = AC_SRC_OVER;
	bf.BlendFlags = 0;
	bf.SourceConstantAlpha = 0xFF;
	bf.AlphaFormat = AC_SRC_ALPHA;

	::AlphaBlend(hClientDC, 0, 0, lImageWidth, lImageHeight,
						hdcMem, 0, 0, lImageWidth, lImageHeight, bf);

	::ReleaseDC(*this, hClientDC);
	::SelectObject(hdcMem, hOldBitmap);
	::DeleteObject(hBitmap);
}

::DeleteDC(hdcMem);




QuestionIE in my app Pin
Ajay L D7-Jul-08 1:15
Ajay L D7-Jul-08 1:15 
AnswerRe: IE in my app Pin
Varghese Paul M7-Jul-08 1:22
Varghese Paul M7-Jul-08 1:22 
GeneralRe: IE in my app Pin
Ajay L D7-Jul-08 1:39
Ajay L D7-Jul-08 1:39 
GeneralRe: IE in my app Pin
ThatsAlok7-Jul-08 2:41
ThatsAlok7-Jul-08 2:41 
GeneralRe: IE in my app Pin
Ajay L D7-Jul-08 3:21
Ajay L D7-Jul-08 3:21 
AnswerRe: IE in my app Pin
KarstenK7-Jul-08 3:52
mveKarstenK7-Jul-08 3:52 
QuestionIncrease the hight of the status bar in MDI Pin
ptr_Electron7-Jul-08 1:12
ptr_Electron7-Jul-08 1:12 
AnswerRe: Increase the hight of the status bar in MDI Pin
James R. Twine7-Jul-08 1:14
James R. Twine7-Jul-08 1:14 
AnswerRe: Increase the hight of the status bar in MDI Pin
Varghese Paul M7-Jul-08 18:37
Varghese Paul M7-Jul-08 18:37 
Questionstatic IP address Pin
an897-Jul-08 1:08
an897-Jul-08 1:08 
AnswerRe: static IP address Pin
James R. Twine7-Jul-08 1:12
James R. Twine7-Jul-08 1:12 
QuestionI have a problem about function "PlaySound" in synchronize mode (SND_SYNC) Pin
xanagan6667-Jul-08 0:48
xanagan6667-Jul-08 0:48 
AnswerRe: I have a problem about function "PlaySound" in synchronize mode (SND_SYNC) Pin
Varghese Paul M7-Jul-08 1:11
Varghese Paul M7-Jul-08 1:11 
AnswerRe: I have a problem about function "PlaySound" in synchronize mode (SND_SYNC) Pin
Iain Clarke, Warrior Programmer7-Jul-08 1:39
Iain Clarke, Warrior Programmer7-Jul-08 1:39 
GeneralRe: I have a problem about function "PlaySound" in synchronize mode (SND_SYNC) Pin
xanagan6667-Jul-08 15:40
xanagan6667-Jul-08 15:40 
QuestionMove a captionless dialog on clicking the icon of the dialog on title bar . Pin
Ummar Muhammad7-Jul-08 0:43
Ummar Muhammad7-Jul-08 0:43 
AnswerRe: Move a captionless dialog on clicking the icon of the dialog on title bar . Pin
Yajnesh Narayan Behera8-Jul-08 2:10
Yajnesh Narayan Behera8-Jul-08 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.