Memory Device context
-
Hi I have 5 seperate Device contexts in which i load 5 bmp's and position them on the screen such that it looks as if it is 1 bmp. How to combine these 5 dc's into 1. Thanks and regards, Salil
-
Hi I have 5 seperate Device contexts in which i load 5 bmp's and position them on the screen such that it looks as if it is 1 bmp. How to combine these 5 dc's into 1. Thanks and regards, Salil
I assume they are memory dc.... Cant you make one more memory dc and bitblt each dc onto this memory dc? this way you convert all 5 memdc's to one dc.
MSN Messenger. prakashnadar@msn.com "If history isn't good, just burn it." - Sidhuism.
-
I assume they are memory dc.... Cant you make one more memory dc and bitblt each dc onto this memory dc? this way you convert all 5 memdc's to one dc.
MSN Messenger. prakashnadar@msn.com "If history isn't good, just burn it." - Sidhuism.
Hi, This is how my OnDraw() looks like and i am having trouble scrolling it Thanks and regards, Salil. CString szFilename("d:\\vc\\mfc\\2001.bmp"); HBITMAP hBmp = (HBITMAP)::LoadImage(NULL,szFilename, IMAGE_BITMAP,0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); CBitmap bmp; bmp.Attach(hBmp); CClientDC dc(this); CDC bmDC; bmDC.CreateCompatibleDC(&dc); CBitmap *pOldbmp = bmDC.SelectObject(&bmp); BITMAP bi; bmp.GetBitmap(&bi); dc.StretchBlt (0,0,len_in_pix,ht_in_pix,&bmDC,0,0,bi.bmWidth ,bi.bmHeight,SRCCOPY); bmDC.SelectObject(pOldbmp); CString szFilename1("d:\\vc\\mfc\\2002.bmp"); HBITMAP hBmp1 = (HBITMAP)::LoadImage(NULL,szFilename1, IMAGE_BITMAP,0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); CBitmap bmp1; bmp1.Attach(hBmp1); CClientDC dc1(this); CDC bmDC1; bmDC1.CreateCompatibleDC(&dc1); CBitmap *pOldbmp1 = bmDC1.SelectObject(&bmp1); BITMAP bi1; bmp1.GetBitmap(&bi1); dc1.StretchBlt (0,br_in_pix,len_in_pix,ht_in_pix,&bmDC1,0,0,bi.bmWidth ,bi.bmHeight,SRCCOPY); bmDC1.SelectObject(pOldbmp1); CString szFilename2("d:\\vc\\mfc\\2003.bmp"); HBITMAP hBmp2 = (HBITMAP)::LoadImage(NULL,szFilename2, IMAGE_BITMAP,0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); CBitmap bmp2; bmp2.Attach(hBmp2); CClientDC dc2(this); CDC bmDC2; bmDC2.CreateCompatibleDC(&dc2); CBitmap *pOldbmp2 = bmDC2.SelectObject(&bmp2); BITMAP bi2; bmp2.GetBitmap(&bi2); dc2.StretchBlt (0,br_in_pix+ht_in_pix,len_in_pix,br_in_pix,&bmDC2,0,0,bi.bmWidth ,bi.bmHeight,SRCCOPY); bmDC2.SelectObject(pOldbmp2); CString szFilename3("d:\\vc\\mfc\\2004.bmp"); HBITMAP hBmp3 = (HBITMAP)::LoadImage(NULL,szFilename3, IMAGE_BITMAP,0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); CBitmap bmp3; bmp3.Attach(hBmp3); CClientDC dc3(this); CDC bmDC3; bmDC3.CreateCompatibleDC(&dc3); CBitmap *pOldbmp3 = bmDC3.SelectObject(&bmp3); BITMAP bi3; bmp3.GetBitmap(&bi3); dc3.StretchBlt (0,2*br_in_pix+ht_in_pix,len_in_pix,ht_in_pix,&bmDC3 ,0,0,bi.bmWidth,bi.bmHeight,SRCCOPY); bmDC3.SelectObject(pOldbmp3); CString szFilename4("d:\\vc\\mfc\\2005.bmp"); HBITMAP hBmp4 = (HBITMAP)::LoadImage(NULL,szFilename4,
-
Hi I have 5 seperate Device contexts in which i load 5 bmp's and position them on the screen such that it looks as if it is 1 bmp. How to combine these 5 dc's into 1. Thanks and regards, Salil
- Create 2 compatible device contexts: a DC (dcTemp) to temporarly hold current bitmap and a DC (dcOut) to hold the results of bliting. 2) Create a compatible bitmap large enough to hold all 5 bmp's. 3) Select large bitmap into dcOut. (save pOldOutBitmap here) 4) Select bitmap[0] into dcTemp. (save pOldBitmap here - need when finished) 5) Determine what position to blit bigmap to. 6) Blit bitmap[0] (dcTemp) to position in dcOut. 7) Select bitmap[1] into dcTemp. 8) Determine what position to blit bigmap to. 9) Blit bitmap[1] (dcTemp) to position in dcOut. .... // Now all the bitmaps are in 1 DC. N) Select pOldBitmap (dcTemp.SelectObject(pOldBitmap);). N+1) Blit result to client area (pDC->BitBlt(...,&dcOut,...);). N+2) Select pOldOutBitmap (dcTemp.SelectObject(pOldOutBitmap);). That is all there is to it. If you want to increase draw speed then you should create the large bitmap as a member variable and then create a function to copy, using above method, the 5 bitmaps to it. That way you do not need to do all the coping in the OnDraw function, just blit the stored bitmap to the client area. If you want to you could create an array of bitmap IDs and use a loop to preform the repeated select, calc. position, and dcOut blits. That is how I whould do it, because then to add another bitmap all you need do is add its ID to the array. Well I hope this helps. Good Luck! INTP