How can i create a device independent bitmap from a rgb buffe 
Author Message
 How can i create a device independent bitmap from a rgb buffe

Hi guys,
     I am trying to create a (device independent) bitmap from rgb buffer in
24bits/pixel format. I tried CreateDIBSection but it creates the bitmap with
bit values as 0s. I can write the rgb data to a file in bmp format ( 24bpp)
and use SHLoadDIBitmap and it works. So how can i create the bitmap from the
buffer?

Thanks,
Krishna



Mon, 05 Jan 2004 09:23:58 GMT  
 How can i create a device independent bitmap from a rgb buffe
Here is an answer two your question:
http://www.spbteam.com/pocketpc/qa/offscreen_buffer.html

Vassili Philippov

-------------------------------------------------------------------

How to implement offscreen buffer?

Question
I need to output function graphic. When I draw the graphic using GDI
function I see flicker. I want to create an offscreen buffer to prevent this
flicker. How can I do that?

Answer
You have to create a bitmap as a buffer. Then create memory device context
and select this bitmap into the device context. Then draw into this memory
context and then copy the memory device context into the target device
context using BitBlt function.

Or you can use STScreenBuffer library that encapsulates most of this work
and make implementation of a screen buffer simpler. More over
CSTScreenBuffer class gives you fast access to points that could not be done
using GDI functions.

Source code:
The following code gives example of an offscreen buffer using STScreenBuffer
library.
void CMyView::OnDraw(CDC* pDC)
{
 CSTScreenBuffer sb;
 sb.Create(pDC, CRect(0 , 0, 100, 80));
 sb.GetDC()->Rectangle(10, 10, 20, 20);
 sb.Draw(pDC, CPoint(0,0));

Quote:
}

The following code gives example of an offscreen buffer using MFC functions.
void CMyView::OnDraw(CDC* pDC)
{
 CDC memDc;
 if (!memDc.CreateCompatibleDC(pDC)) {
  return;
 }

 CBitmap bmp;
 bmp.CreateCompatibleBitmap(pDC, 100, 80);

 HBITMAP m_hOldBitmap = (HBITMAP)::SelectObject(memDc.GetSafeHdc(),
bmp.GetSafeHandle());
 memDc.BitBlt(0,0, 100, 80, pDC, 0, 0, SRCCOPY);

 memDc.Rectangle(10, 10, 20,20);

 pDC->BitBlt(0, 0, 100 ,80, &memDc, 0, 0, SRCCOPY);
 ::SelectObject(memDc.GetSafeHdc(), m_hOldBitmap);
 memDc.DeleteDC();

Quote:
}



Mon, 05 Jan 2004 17:21:42 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How can i create a device independent bitmap from a rgb buffer

2. How to pass a .tif image to the DIB(Device Independent Bitmap) format

3. Device independent Bitmap (DIB), from memory to file.

4. Creating 24-bit bitmap/Device Context

5. Creating 24-bit bitmap/Device Context

6. Cast a Win32 Device Independent Bitmap to a .NET Bitmap class?

7. SUMMARY: output device independent graphics pack.

8. Output device independent graphics package

9. Does VC++ 6.0 support device independent printer routines?

10. Getting the RGB data as an array out of Bitmap

11. Set bitmap in RGB ???

12. RGB in bitmap

 

 
Powered by phpBB® Forum Software