Click here to Skip to main content
15,910,603 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: static library in two modules Pin
Mark Salsbery2-Apr-08 6:24
Mark Salsbery2-Apr-08 6:24 
GeneralEditor Pin
suhi1-Apr-08 20:02
suhi1-Apr-08 20:02 
GeneralRe: Editor Pin
Cedric Moonen1-Apr-08 21:47
Cedric Moonen1-Apr-08 21:47 
GeneralRe: Editor Pin
Hamid_RT7-Apr-08 3:49
Hamid_RT7-Apr-08 3:49 
QuestionMFC application For Tablet PC Pin
SSanket1-Apr-08 19:19
SSanket1-Apr-08 19:19 
GeneralRe: MFC application For Tablet PC Pin
rp_suman1-Apr-08 22:24
rp_suman1-Apr-08 22:24 
Question32 bitbmp with alpha channel Pin
trioum1-Apr-08 18:55
trioum1-Apr-08 18:55 
GeneralRe: 32 bitbmp with alpha channel Pin
Mark Salsbery1-Apr-08 19:10
Mark Salsbery1-Apr-08 19:10 
You can use the AlphaBlend() function...

Here's an example:
LONG lImageWidth = 640;//TransparentSrcBitmap.GetWidth();
LONG lImageHeight = 480;//TransparentSrcBitmap.GetHeight();
WORD wBitsPerPixel = 32;
 
//LONG lBytesPerRow = (((lImageWidth * (long)wBitsPerPixel + 31L) & (~31L)) / 8L);
LONG lBytesPerRow = 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 = lBytesPerRow * lImageHeight;
//bmi.bmiHeader.biXPelsPerMeter = 0;
//bmi.bmiHeader.biYPelsPerMeter = 0;
//bmi.bmiHeader.biClrUsed = 0;
//bmi.bmiHeader.biClrImportant = 0;

HDC hdc = ::CreateCompatibleDC(0);

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

if (hBitmap)
{   
    <font color="Green">// Clear the pixels in the DIBsection to a shade of blue, setting alpha channel to 50% blend</font>
    RGBQUAD *pCurPixel = (RGBQUAD *)pBitmapBits;
    int PixelCount = lImageWidth * lImageHeight;
    while (PixelCount > 0)
    {
        (*pCurPixel).rgbRed =      0x00;
        (*pCurPixel).rgbGreen =    0x00;
        (*pCurPixel).rgbBlue =     0xA0;
        (*pCurPixel).rgbReserved = 0x80; <font color="Green">// alpha channel value</font>
        pCurPixel++;
        PixelCount--;
    }

    HGDIOBJ hOldBitmap = ::SelectObject(hdc, 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,
                        hdc, 0, 0, lImageWidth, lImageHeight, bf);

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

::DeleteDC(hdc);

Using GDI+ it's easier Smile | :)

Mark




Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: 32 bitbmp with alpha channel Pin
trioum3-Apr-08 2:07
trioum3-Apr-08 2:07 
GeneralRe: 32 bitbmp with alpha channel Pin
Mark Salsbery3-Apr-08 5:32
Mark Salsbery3-Apr-08 5:32 
GeneralRe: 32 bitbmp with alpha channel Pin
Hamid_RT7-Apr-08 3:49
Hamid_RT7-Apr-08 3:49 
QuestionHow to swap data from physical momery to virtual momery? [modified] Pin
hanlei00000000091-Apr-08 17:02
hanlei00000000091-Apr-08 17:02 
AnswerRe: How to swap data from physical momery to virtual momery? Pin
CPallini1-Apr-08 21:16
mveCPallini1-Apr-08 21:16 
GeneralI don't know what your means Pin
hanlei00000000091-Apr-08 22:31
hanlei00000000091-Apr-08 22:31 
GeneralRe: I don't know what your means Pin
CPallini1-Apr-08 22:48
mveCPallini1-Apr-08 22:48 
GeneralRSSI (Wireless) display - ActiveX control... Pin
abupriabi@yahoo.com1-Apr-08 11:00
abupriabi@yahoo.com1-Apr-08 11:00 
GeneralRe: RSSI (Wireless) display - ActiveX control... Pin
led mike1-Apr-08 11:15
led mike1-Apr-08 11:15 
QuestionRe: RSSI (Wireless) display - ActiveX control... Pin
CPallini1-Apr-08 22:18
mveCPallini1-Apr-08 22:18 
GeneralRe: RSSI (Wireless) display - ActiveX control... Pin
abupriabi@yahoo.com2-Apr-08 6:42
abupriabi@yahoo.com2-Apr-08 6:42 
GeneralRe: RSSI (Wireless) display - ActiveX control... Pin
CPallini2-Apr-08 8:31
mveCPallini2-Apr-08 8:31 
Questionhow to reverse a vertical slider Pin
reteset1-Apr-08 8:12
reteset1-Apr-08 8:12 
AnswerRe: how to reverse a vertical slider Pin
David Crow1-Apr-08 8:48
David Crow1-Apr-08 8:48 
GeneralRe: how to reverse a vertical slider Pin
led mike1-Apr-08 8:58
led mike1-Apr-08 8:58 
GeneralRe: how to reverse a vertical slider Pin
ThatsAlok1-Apr-08 9:22
ThatsAlok1-Apr-08 9:22 
GeneralRe: how to reverse a vertical slider Pin
reteset2-Apr-08 4:53
reteset2-Apr-08 4:53 

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.