TransparentBlt()-Funktion
-
Hiho!
Ich benutze den minGW5.0-compiler, sollte also der neuste sein, aber mein Problem ist, beim compilieren von Quellcode kommt folgende Fehlermeldung:
"'TransparentBlt' undeclared (first use this funktion)"
, also es scheint so, als wäre diese Funktion in der header "windows.h" nciht definiert ...
Aber in meinem DeveloperKit griegt ich extra Infos, wenn ich mit der Maus über die Funktion fahre, sprich die Parameter etc. ...
in der MSDN ist die Funktion aufgeführt: http://msdn.microsoft.com/library/en-us/gdi/bitmaps_2y9g.asp, also muss es sie auch gebennun meine Frage, hängt meine Fehlermeldung von meinem Compiler ab, sprich muss ich VisualC++ nutzen, um auch diese Funktion zu haben, oder warum ist die Funktion nciht definiert?
hat jmd. ähnliche Erfahrungen?
-
#define _WIN32_WINNT 0x0501
dürfte unter Umständen helfen
Greetz
-
ändert leider nciths, nein
Was sollte das denn genau bewirken?
Dankeschön trotzdem!
-
Such doch mal in den H-Files Deiner Entwicklungsumgebung... wenn Du da die Funktion nicht findest, dann hast Du sie auch nicht.
Du musst dann ein aktuelles PSDK installieren und diese bei Dir einbinden.Oder Du verwendest gleich VC++ Express mit dem aktuelle PSDK.
-
Okay ... das PSDK hatte ich vorrausgesetzt ^^
M.T.
-
gehört das PDSK nciht zum VisualC++-compiler?
die header-Files meiner Entwicklungsumgebung zu durchsuchen wäre wohl ein bissl krank *g*, weil mein sch.. Suchassistent nciht in .txt Files sucht ... und manuell, nein Danke
-
Ich dachte Du verwendest mingW...
Und VC++ 6 hat z.B. viele Funktionen nicht in den mitgelieferten Headern, da z.B. die meisten XP-Funktion erst erfunden wurden wo VC6 schon längst ausgeliefert war...
Wenn Du also VC2005-Express vverwendest musst Du ja eh das aktuelle PSDK runterladen und hast somit keine Probleme...
-
Aber nicht die aktuellen Dateien.
Lad die Teile einfach mal von msdn.microsoft.com neu runter und versuch sUnd n Datei-Durchsuch-Programm findest du doch bestimmt, um die /Include Ordner im PSDK-Verzeichnis zu durchstöbern.
Greetz
-
Jochen ... duuuu .... beim nächsten Mal gewinn ich wieder :p
Greetz :xmas1:
-
-
Also sin in dem PDSK die neusten Header und Liberies etc. enthalten, die ich dann in meinem Compiler ersetzen muss, hab ich das richtig verstanden?
und ja, ich benutze den minGW-compiler und möchte ncith umbedingt auf VC++ umsteigen ...
-
Du kannst auch die DrawTransparentBitmap() in deinen
Quellcode einbinden.
So hatte ich es mal gemacht, weil die TransparentBlt() nicht
mit WinXP läuft.
http://support.microsoft.com/default.aspx?scid=kb;en-us;79212Die funktioniert wie die TransparentBlt().
void DrawTransparentBitmap(HDC hdc, HBITMAP hBitmap, short xStart, short yStart, COLORREF cTransparentColor) { BITMAP bm; COLORREF cColor; HBITMAP bmAndBack, bmAndObject, bmAndMem, bmSave; HBITMAP bmBackOld, bmObjectOld, bmMemOld, bmSaveOld; HDC hdcMem, hdcBack, hdcObject, hdcTemp, hdcSave; POINT ptSize; hdcTemp = CreateCompatibleDC(hdc); SelectObject(hdcTemp, hBitmap); // Select the bitmap GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm); ptSize.x = bm.bmWidth; // Get width of bitmap ptSize.y = bm.bmHeight; // Get height of bitmap DPtoLP(hdcTemp, &ptSize, 1); // Convert from device // to logical points // Create some DCs to hold temporary data. hdcBack = CreateCompatibleDC(hdc); hdcObject = CreateCompatibleDC(hdc); hdcMem = CreateCompatibleDC(hdc); hdcSave = CreateCompatibleDC(hdc); // Create a bitmap for each DC. DCs are required for a number of // GDI functions. // Monochrome DC bmAndBack = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL); // Monochrome DC bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL); bmAndMem = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y); bmSave = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y); // Each DC must select a bitmap object to store pixel data. bmBackOld = SelectObject(hdcBack, bmAndBack); bmObjectOld = SelectObject(hdcObject, bmAndObject); bmMemOld = SelectObject(hdcMem, bmAndMem); bmSaveOld = SelectObject(hdcSave, bmSave); // Set proper mapping mode. SetMapMode(hdcTemp, GetMapMode(hdc)); // Save the bitmap sent here, because it will be overwritten. BitBlt(hdcSave, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY); // Set the background color of the source DC to the color. // contained in the parts of the bitmap that should be transparent cColor = SetBkColor(hdcTemp, cTransparentColor); // Create the object mask for the bitmap by performing a BitBlt // from the source bitmap to a monochrome bitmap. BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY); // Set the background color of the source DC back to the original // color. SetBkColor(hdcTemp, cColor); // Create the inverse of the object mask. BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, NOTSRCCOPY); // Copy the background of the main DC to the destination. BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdc, xStart, yStart, SRCCOPY); // Mask out the places where the bitmap will be placed. BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND); // Mask out the transparent colored pixels on the bitmap. BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND); // XOR the bitmap with the background on the destination DC. BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT); // Copy the destination to the screen. BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, 0, 0, SRCCOPY); // Place the original bitmap back into the bitmap sent here. BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcSave, 0, 0, SRCCOPY); // Delete the memory bitmaps. DeleteObject(SelectObject(hdcBack, bmBackOld)); DeleteObject(SelectObject(hdcObject, bmObjectOld)); DeleteObject(SelectObject(hdcMem, bmMemOld)); DeleteObject(SelectObject(hdcSave, bmSaveOld)); // Delete the memory DCs. DeleteDC(hdcMem); DeleteDC(hdcBack); DeleteDC(hdcObject); DeleteDC(hdcSave); DeleteDC(hdcTemp); }
Aufruf:
DrawTransparentBitmap(hdc, // The destination DC. hBitmap, // The bitmap to be drawn. xPos, // X coordinate. yPos, // Y coordinate. 0x00FFFFFF); // The color for transparent // pixels (white, in this // example).
-
Das Selbe passiert mit der "DrawTransparentBitmap"-Funktion, also genau der Selbe Fehler, trotzdem THX!
-
Hast Du WINVER auf 0x0400 gesetzt?
Folgendes lässt sich bei mir ohne Probleme übersetzen:#define WINVER 0x0400 #include <windows.h> #include <tchar.h> int _tmain() { TransparentBlt(NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0); }
-
Und das PSDK dürfte folgendes sein:
http://www.microsoft.com/downloads/details.aspx?FamilyID=eba0128f-a770-45f1-86f3-7ab010b398a3&DisplayLang=enEinfach downloaden, installieren, die Pfade in deinem Compiler setzen und glücklich sein.
Greetz :xmas2:
-
Hast du die DrawTransparentBitmap() denn so wie ich sie gepostet habe
in deinen Quellcode eingesetzt?
Also den kompletten Code als eigene Funktionsdefinition.
-
Hast du die DrawTransparentBitmap() denn so wie ich sie gepostet habe in deinen Quellcode eingesetzt? Also den kompletten Code als eigene Funktionsdefinition.
Ja, dann später :D, aber mein compiler hat rumgemeckert bei der Zeile
bmBackOld = SelectObject(hdcBack, bmAndBack);
von wegen er könne von "void*" nciht nach "hBITMAP*" konvertieren ...ich nehm das PDSK:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm
weil bei dem anderen gabs ne Fehlermeldung bei der Installation ...
ich bin ncoh beim downloaden, mal schauen ...@ Jochen, dann kommt auchdie ganz oben genannte Meldung ..
-
Ja, stimmt, du mußt noch für den MingW eine Typecasting vornehmen.
bmBackOld = (HBITMAP)SelectObject(hdcBack, bmAndBack); bmObjectOld = (HBITMAP)SelectObject(hdcObject, bmAndObject); bmMemOld = (HBITMAP)SelectObject(hdcMem, bmAndMem); bmSaveOld = (HBITMAP)SelectObject(hdcSave, bmSave);
Dann läufts aber.
Für den Fall, daß das PDSK nicht läuft.
Ich ziehe es auch gerade..
-
Danke!
so, k, jetzt meckert mein Compiler nicht bei der Funktion, aber irgendwie wird dabei ein schwarzes rechteck auf dem Bildschirm ausgeruckt, anstatt eins, wo ein Teil transparent ist ...und das SDK hab ich jetzt, ich werde mal die ein bissl kopieren und einfügen und mal schauen, wieviel ich kaputt mache
-
Dann haste wahrscheinlich die falsche Bitmap übergeben oder
eine falsche Transparenzfarbe.
Wenn du ein praktisches Beispiel brauchst, kann ich dir gerne
nochmal eines posten.
Bei mir hat es gut funktioniert und ich kann
eine Bitmap transparent auf eine andere Bitmap draufblitten.Aber teste erstmal das PDSK.
Ich werde es auch gleich mal durchtesten.
-
Hm, also das mit dem "einfachen" kopieren hat schonmal garnicht geklappt, beim compilieren von simpelsten Anwendungen kommen 100 Fehlermeldungen mit irgendwelchen includefiles, also genau da, wo ich was verändert hab ...
ich hab den kompletten inhalt aus "Include" und "Lib"`kopiert und gegenfalls ersetzt oder halt einfach hinzugefügt, aber das funzt garnciht ...
mit der anderen FunktION muss ich später mal gucken welchen hdc ich nehmen muss etc.