Jump to content
  • Advertisement

Archived

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

Zipster

Help me plz!

This topic is 6933 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

I posted this message before, but you ppl seem to like flaming kieron_j on that dumb ass MP3 post rather than help me! . Here''s a duplicated. I changed the topic to get your attention : 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.CreateCompatibleDC(&dc);
workDC.SelectPalette(&m_pPalette, false);
memDC.SelectObject(m_bBitmap);
int x , y , z;
z=1;
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);
					workDC.SelectObject(old);
					TemplateMain.m_listGraphics.AddTail(bWork);
					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);
	m_cCombo.SetWindowText(temp);
	if(pDoc->m_bTemplateLoaded)
	{
		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.SetBitmap((HBITMAP)m_bBitmap);
	}  
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
None of you "expert" programmers can solve this? What is the world coming to that no one knows MFC well enough? Well if you guyz don''t know, thats ok.... I didn''t expect you to know anyway .

Did that provoke you any?

Share this post


Link to post
Share on other sites
A few things:
CBitmaps are screwy.
I can''t see anything wrong with your code the way it is, but I always run a trace on my code which usually makes the bug fall out.
I''m not sure that BitBlt will be happy about what you''re trying to make it do. Perhaps you should write to the smaller bitmaps manually.
Check all handles and contexts involved for invalid values.

g''luck.
-fel

Share this post


Link to post
Share on other sites
I copy this code directly out of "Programming in MFC" by Microsoft press, and it said it would work. I NEED to use CBitmapso i can use the CStaic::SetBitmap function later on!

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!