Problem mit MemoryDC
-
Hi,
also: ich habe diesen code geschrieben:HBITMAP hBmp; CString cFilename; dcFontDC.CreateCompatibleDC(NULL); cFilename = "c:\\Bild.bmp"; hBmp = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), cFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); DrawTransparent(&dcFontDC, hBmp, 0, 0, BildSize_X, BildSize_Y); // (selber geschrieben, funktioniert auch) COLORREF Pixel = dcFontDC.GetPixel(0,0);jetzt müsste ich doch eingentlich mit 'GetRValue(Pixel)', 'GetGValue(Pixel)' und 'GetBValue(Pixel)' die einzelnen pixel abfragen können.
das hab ich zum testen gemacht, aber er zeigt mir immer 255,255,255 an. das ist die farbe für SetBkColor(RGB(255,255,255)) in der 'DrawTransparent(...)' -funktion.also hat er das bitmap nicht gemalt sondern nur das feld für die angegeben maße; oder

ich habe das bild schon auf meinem normalen dialogfeld gemalt und es hat geklappt.kann mir jemand helfen ??
mfg RedSkall
-
Da das problem in DrawTransparent liegt, wärs womöglich ganz net wenn du uns dem code der funktion zeigst, nicht das ausen rum

(und die bitamp ist auf pixel 0,0 auch wirklich nicht wieß ?
)
-
ne, die funktion funktioniert ja, habe ich ja getestet, aber ok:
void CMeinProgramm::DrawTransparent(CDC * pDC, HBITMAP hBmp, int x, int y, int iWidth, int iHight) { COLORREF crOldBack = pDC->SetBkColor(RGB(255, 255, 255)); COLORREF crOldText = pDC->SetTextColor(RGB(0, 0, 0)); CBitmap bBitmap; CDC dcImage, dcTrans; // Attach bitmap bBitmap.Attach(hBmp); // Create two memory dcs for the image and the mask dcImage.CreateCompatibleDC(pDC); dcTrans.CreateCompatibleDC(pDC); // Select the image into the appropriate dc CBitmap* pOldBitmapImage = dcImage.SelectObject(&bBitmap); // Create the mask bitmap CBitmap bitmapTrans; bitmapTrans.CreateBitmap(iWidth, iHight, 1, 1, NULL); // Select the mask bitmap into the appropriate dc CBitmap* pOldBitmapTrans = dcTrans.SelectObject(&bitmapTrans); // Build mask based on transparent colour dcImage.SetBkColor(crTransparent); dcTrans.BitBlt(0, 0, iWidth, iHight, &dcImage, 0, 0, SRCCOPY); // Do the work - True Mask method - cool if not actual display pDC->BitBlt(x, y, iWidth, iHight, &dcImage, 0, 0, SRCINVERT); pDC->BitBlt(x, y, iWidth, iHight, &dcTrans, 0, 0, SRCAND); pDC->BitBlt(x, y, iWidth, iHight, &dcImage, 0, 0, SRCINVERT); // Restore settings dcImage.SelectObject(pOldBitmapImage); dcTrans.SelectObject(pOldBitmapTrans); bBitmap.Detach(); pDC->SetBkColor(crOldBack); pDC->SetTextColor(crOldText); }die pixel sind auch bestimmt nicht weiß

-
hey das ist wichtig, weiß keiner ne lösung ??