Jump to content
  • Advertisement


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


Displaying byte array

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

hi,all: I got a 2D byte array with every element represent a RGB color value(0-255),the two dimension stand for row and col,now i want to display them into a window.I''ve been using the win32 function SetPixel and each time fetching 3 byte from the array to form a RGB value.It works but the speed is too slow,since the byte array data are static,it''s no reason to display them every time in the OnDraw callback function(I use VC). So i think of the bitmap.Here is the code i use: //in initial setup function //pByte is the 2D byte array,we have construct it with RGB order ... m_pBitmap = new CBitmap; m_pdcMemory = new CDC; m_pBitmap->CreateBitmap(cols,rows,24,24,NULL); m_pBitmap->SetBitmapBits(3*cols*rows,pByte); CClientDC dc(this); OnPrepareDC(&dc); m_pdcMemory->CreateCompatibleDC(&dc); m_pdcMemory->SelectObject(m_pBitmap); //in OnDraw callback function pDC->BitBlt(0,0,cols,rows,m_pdcMemory,0,0,SRCCOPY); That is it.But nothing displays in the window.Where does things get wrong?(If i use LoadBitmap member function of CBitmap in the setup function then everything is ok) I think maybe bitmap is not the best way of deeling with this situation,but it''s far more better then SetPixel. Anybody can help me find the mistake or just give me another way to do this thing? thinks a lot!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!