Transparent Text auf DC
-
Hallo!
Ich habe folgenden Code:
BITMAPINFO bmInfo; ZeroMemory(&bmInfo, sizeof(BITMAPINFO)); bmInfo.bmiHeader.biBitCount = 24; bmInfo.bmiHeader.biHeight = -height; bmInfo.bmiHeader.biPlanes = 1; bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmInfo.bmiHeader.biWidth = width; bmInfo.bmiHeader.biCompression = BI_RGB; HDC desktopDC = GetDC(GetDesktopWindow()); HBITMAP myBitmap = CreateCompatibleBitmap(desktopDC,width, height); assert(myBitmap); HDC myCompatibleDC = CreateCompatibleDC(desktopDC); assert(myCompatibleDC); int nResult = SetDIBits(myCompatibleDC, myBitmap, 0, height, rgb->data, &bmInfo, 0); SelectObject(myCompatibleDC, myBitmap); SetBkColor(myCompatibleDC, TRANSPARENT); SetTextColor(myCompatibleDC, RGB(rand()%255,rand()%255,rand()%255)); TextOut(myCompatibleDC, 0,0, "This is a test", 14); StretchBlt(desktopDC,0,0, width, height, myCompatibleDC,0,height-1,width, -height, SRCCOPY); DeleteObject(myBitmap); DeleteDC(desktopDC); DeleteDC(myCompatibleDC);
Mein Problem ist, dass der text nicht transparent ausgegeben wird. Woran könnte das liegen?
Danke
-
Falsch:
SetBkColor(myCompatibleDC, TRANSPARENT);
Richtig:
SetBkMode(myCompatibleDC, TRANSPARENT);
-
Ich kann nicht glauben dass ich das übersehen hab.
Danke SRI.
-
bei mir kommen beim Compilieren folgende Fehlermeldungen:
Undefiniertes Symbol: height, width, rgb
Für height und width habe ich Screen->Height und Screen->Width genommen. Aber was muss rgb sein?
Und noch ne Frage: warum steht da ein minus vor dem height? Weiter unten ist das nochmal so.bmInfo.bmiHeader.biHeight = -height;
-
is hier niemand im Forum mehr unterwegs oder wollt ihr mir die Frage nicht beantworten?
-
biHeight
Specifies the height of the bitmap, in pixels. If biHeight is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If biHeight is negative, the bitmap is a top-down DIB and its origin is the upper-left corner.
-
thx:D
Aber leider werd ich trotzdem aus der angabe mit rgb nciht schlau
-
Der Code ist nicht vollständig, daher wirst Du ihn so nicht kompilieren können.
-
ja, es fehlt irgendwas mit dem rgb. Das muss ja vorher noch irgendwie definiert werden, aber ich weis halt nicht wie. Darin stehen doch Informationen über die Farben des Bitmaps?