Displaying byte array

Started by
0 comments, last by xiangping 22 years, 5 months ago
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!
Advertisement
Where do you actually put something into the bitmap?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement