BitBlt problem ?????????????
-
Hi, guyz. Hope you can help me with this one. I'm encountering a problem using BitBlt. I might implemented it wrong, please help me check it. code: .h: static CBitmap m_bitmap; OnDraw(CDC *pDC) { CDC BitmapDc; CBitmap *old_bitmap; BitmapDC.CreateCompatibleDC(pDC); old_bitmap=BitmapDC.SelectObject(&m_bitmap); // Drawing code here BitmapDc.Rectangle(top,bottom,right,bottom); ..................... .................... //****************************** // 1st CBitmap bitmap; CDC memDC; bitmap.LoadBitmap(L"START_BITMAP"); memDC.CretaeCompatibleDC(pDC); BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY); //****************************** // another drawing code for lines ................ ................. pDc->BitBlt(top,left,right,bottom,&BitmapDC,0,0,SRCCOPY); BitmapDC.SelectedObject(old_bitmap); // end of code From the above code, there's no problem work as expected. Image appears at the background of the lines. But, if i use HDC instead of the bitmap, the image were not seen and has been overlapped by a white fill. //****************************** // 2nd CDC memDC; memDC.Attach(m_hDC); BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY); //****************************** // m_hDC was returned from other class What is the difference with the 2? Why is the image were not seen using the 2nd code }
-
Hi, guyz. Hope you can help me with this one. I'm encountering a problem using BitBlt. I might implemented it wrong, please help me check it. code: .h: static CBitmap m_bitmap; OnDraw(CDC *pDC) { CDC BitmapDc; CBitmap *old_bitmap; BitmapDC.CreateCompatibleDC(pDC); old_bitmap=BitmapDC.SelectObject(&m_bitmap); // Drawing code here BitmapDc.Rectangle(top,bottom,right,bottom); ..................... .................... //****************************** // 1st CBitmap bitmap; CDC memDC; bitmap.LoadBitmap(L"START_BITMAP"); memDC.CretaeCompatibleDC(pDC); BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY); //****************************** // another drawing code for lines ................ ................. pDc->BitBlt(top,left,right,bottom,&BitmapDC,0,0,SRCCOPY); BitmapDC.SelectedObject(old_bitmap); // end of code From the above code, there's no problem work as expected. Image appears at the background of the lines. But, if i use HDC instead of the bitmap, the image were not seen and has been overlapped by a white fill. //****************************** // 2nd CDC memDC; memDC.Attach(m_hDC); BitmapDC.BitBlt(top,left,right,bottom,&memDC,0,0,SRCCOPY); //****************************** // m_hDC was returned from other class What is the difference with the 2? Why is the image were not seen using the 2nd code }
TooShy2Talk wrote:
old_bitmap=BitmapDC.SelectObject(&m_bitmap);
Before SelectObject(), have you created m_bitmap??? if not use CreateCompaitbleBitmap() to create the bitmap. And since the m_bitmap is a member variable, you should create it only once.
nave [OpenedFileFinder]
-
TooShy2Talk wrote:
old_bitmap=BitmapDC.SelectObject(&m_bitmap);
Before SelectObject(), have you created m_bitmap??? if not use CreateCompaitbleBitmap() to create the bitmap. And since the m_bitmap is a member variable, you should create it only once.
nave [OpenedFileFinder]
Yes, it was already initialized. Upon debugging, I noticed the effect of the BitmapDC.Rectangle(). The fill color that cover the image was somehow related to the Rectangle fill. Is it possible to create rectangle(BitmapDC.Rectangle()) without fill? But when 1st code is used this is not happening. Do you know why?
-
Yes, it was already initialized. Upon debugging, I noticed the effect of the BitmapDC.Rectangle(). The fill color that cover the image was somehow related to the Rectangle fill. Is it possible to create rectangle(BitmapDC.Rectangle()) without fill? But when 1st code is used this is not happening. Do you know why?
TooShy2Talk wrote:
Is it possible to create rectangle
Yes use the Draw3dRect() function for that. I thing Selecting a NULL brush to the BitmapDC and then calling the Rectangle() function will also work.
nave [OpenedFileFinder]
-
TooShy2Talk wrote:
Is it possible to create rectangle
Yes use the Draw3dRect() function for that. I thing Selecting a NULL brush to the BitmapDC and then calling the Rectangle() function will also work.
nave [OpenedFileFinder]
I have tried using BitmapDc.SelectBrush(NULL_BRUSH); before creating the rectangle BitmapDC.Rectangle(left,top,right,bottom); but then the cover fill become black. The image is still invisible.
-
I have tried using BitmapDc.SelectBrush(NULL_BRUSH); before creating the rectangle BitmapDC.Rectangle(left,top,right,bottom); but then the cover fill become black. The image is still invisible.
TooShy2Talk wrote:
BitmapDc.SelectBrush(NULL_BRUSH);
SelectBrush()?? Is there function like that in the CDC class? How about
Draw3dRect()
function?nave [OpenedFileFinder]