Code:
//Create the bitmaps and devices
HBITMAP oldBMP,bitBMP;
HDC memdc,transparentdc;
//Initiate the devices
transparentdc = CreateCompatibleDC(NULL);
memdc = CreateCompatibleDC(NULL);
//Select the bitmaps into devices...
oldBMP = (HBITMAP)SelectObject(transparentdc, bitmap);
//Create a empty bitmap for use when transfering bits.. this can the error point. Don't thinks so still.
bitBMP = CreateCompatibleBitmap(hdc,width,height);
SelectObject(memdc,bitBMP);
if(transparent)//Om jag har en transparentpixel(color of my choice)
//getPixelColor is local funtion that gets color of a pixel... works..
{
if(!TransparentBlt(memdc,0,0,width,height,transparentdc,0,0,width,height,getPixelColor(transparentpixel.x,transparentpixel.y)))
{
MessageBox(NULL,"Transparent","TransparentBlt Error ",MB_OK);
}
}
else
{
//If there is no transparentpixel just ship it of...
BitBlt(memdc,0,0,width,height,transparentdc,0,0,SRCCOPY);
}
if(alphablend)//if there are some alphablend to be done...
{
BLENDFUNCTION bf;
bf.AlphaFormat = 0;
bf.BlendFlags = 0;
bf.BlendOp = AC_SRC_OVER;
bf.SourceConstantAlpha = alphavalue;
AlphaBlend(hdc,x,y,width,height,memdc,0,0,width,height,bf);
}
else
{
BitBlt(hdc,x,y,width,height,memdc,0,0,SRCCOPY);
}
// Now if alphablend and transparent was set there should be a bitmap that has been removed of transparent color and alphablended...
//the alphablend part is correct... but the transparentBlt doesn't work..
SelectObject(transparentdc, oldBMP);
DeleteDC(memdc);
DeleteDC(transparentdc);
Bookmarks