Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Device Contexts and CBitmap

This topic is 6939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, its me again, still working on that same program, only a different problem. What I have here is a CBitmap (lets call it m_bBitmap), and a CObList name m_list. What im trying to do is take m_bBitmap and divide it into smaller CBitmaps, and place all the smaller CBitmap''s into the CObList. This is my code:
CDC workDC;
workDC.SelectPalette(&m_pPalette, false);
int x , y , z;
for(y = 0; y < m_nBitmapHeight; y++)
   for(x = 0; x < m_nBitmapWidth; x++)
	    CBitmap *bWork = (CBitmap *)new CBitmap;
					            bWork->CreateCompatibleBitmap(&dc, m_nTileWidth, m_nTileHeight);
	    CBitmap *old = workDC.SelectObject(bWork);
	    workDC.BitBlt(0,0, m_nTileWidth, m_nTileHeight, &memDC, x*m_nTileWidth, y*m_nTileHeight, SRCCOPY);
					delete bWork;
Above, memDC contains the CBitmap i want to cut-up, and dc is a divide context i created using
CClient dc(NULL); 
My entire problem is that after i do the "cuting up", i try to draw all the little CBitmap''s into a CStatic, but all the CBitmap''s just contain grey. I know i loaded the bmp file right becuase when i draw the big CBitmap, it works, but it won''t draw any of the smaller CBitmaps. Here''s the code for that part:
CString temp;
	CBitmap* m_bBitmap;
	m_cCombo.GetLBText(m_cCombo.GetCurSel(), temp);
		pDoc->TemplateMain.m_pos = pDoc->TemplateMain.m_listGraphics.FindIndex(m_cCombo.GetCurSel());
		m_bBitmap = (CBitmap *)pDoc->TemplateMain.m_listGraphics.GetAt(pDoc->TemplateMain.m_pos);

m_cPreview is the CStatic, and m_cCombo is a combo box used to reference the CObList. What am i doing wrong?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!