Re: What's the difference between DDB and DIB?
On Jan 3, 1:03 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
No. A DDB is a Device Dependent Bitmap. There is nothing in the specification of a DDB
that suggests, implies, or requires that it be in a memory buffer on a graphics card, and
in fact the opposite is true: it is a bunch of bits in your main memory, and the graphics
card memory is not really involved in it at all.
A DIB is a device-independent bitmap. It represents abstract colors. A .BMP file is a
FILE representation of a DIB, and as such, the FILE has a file header, color palette,
etc., but a TIFF file, JPEG file, PNG file, or GIF file can represent a DIB.
In memory, a DIB is a bunch of bits that represent (typically) 24-bit color, or if you
have alpha channel, 32-bit color. When transferred to your card, there is a
transformation made from the DIB representation to the DDB representation. For
efficiency, it is often better to maintain a DDB representation of data, but note that for
a 24-bit graphics card, the DIB and the DDB could be the same.
A Windows GDI object can be a DIB or a DDB, and is represented by an HBITMAP object. So
an HBITMAP is a representative of a kernel copy of the bits, but the bits exist as DIB or
DDB representations independent of being committed to an HBITMAP. That comes later.
joe
On Wed, 2 Jan 2008 17:38:04 -0800 (PST), Asm23 <Asmwarr...@gmail.com> wrote:
As I have learned, the DDB is a memory buffer located in graphic card,
for example, If my screen color depth is 16bit, the DDB' raster data
my contain two bytes for each pixel on the screen.
The DIB is like some file "X.BMP" in windows, It hase some File
header, File infor ,color palette,and the raster data.
I searched by google, and found some articles discussing :
http://www.codeproject.com/KB/graphics/DFB_vs_DIB.aspx
But I still confused on these terms. more, in Win32 programing, We
also hase some sturcture like: BITMAP HBITMAP CBitmap, and some
function like CreateDibSetction...
What's the difference between the DDB, DIB and the windows GDI
objects?
Thanks very much! I'd appreciate to any suggestions!
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm- Hide quoted text -
- Show quoted text -
Thanks, Joseph. This is the second time you help me! thanks
I find out the code like below:
http://www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article.php/c4905/
===================================================================
Step 5: Get the Block of Pixels from memoryDC to the Screen
Use CClientDC's BitBlt function. Next, re-select the old BMP. The
complete code is as follows:
void AppView::OnButton1()
{
CString szFilename("C:\\Talla\\yourimg.bmp");
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL,szFilename,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp;
bmp.Attach(hBmp);//********************Q1
CClientDC dc(this);
CDC bmDC;
bmDC.CreateCompatibleDC(&dc);
CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
BITMAP bi; //*************************Q2
bmp.GetBitmap(&bi);
dc.BitBlt(0,0,bi.bmWidth,bi.bmHeight,&bmDC,0,0,SRCCOPY);
bmDC.SelectObject(pOldbmp);
}
======================================================================
Q1: Why I have to create two isntance of both CBitmap and HBITMAP. Can
I just only use CBitmap to load XXX.bmp?
Q2: this is another sturcture "BITMAP", now, how many buffers contian
the raster data of my image in Memory?
thanks.