Thread: DDB vs. DIB (Clarification needed)

  1. #1
    Registered User
    Join Date
    Aug 2006

    DDB vs. DIB (Clarification needed)

    Okay, I have read up on both Device Dependent Bitmaps & Device Independent Bitmaps, but still unsure as to which one I should be using for my application. Right now I'm just using DDBs and everything works perfectly fine (no complaints or issues seen so far)
    deck_cards BITMAP Cards.bmp
    HBITMAP cardsBmp = LoadBitmap(instance,"deck_cards");
    Here is what I'm creating:
    - A Win32 application.
    - At this stage it is basically a solitaire game similar to the one supplied with Windows.
    - All bitmaps will be stored in the program's resources.
    - Bitmaps will range in type from 4-bits up to 24-bits.
    - My application is only intended to run on a machine with 16-bit+ color depth support.

    So, any reason I should not be using DDBs? Drawbacks? Potential problems of using DDBs? Why should I switch over to DIB?

    Didn't really pay much attention to the problem until I read this from a Win32API Superbible I have (published way back in 1998):
    All Win32 applications should use device-independent bitmaps,
    because most of the functions that deal with DDBs are provided in Win32 only for compatibility with the
    Win16 API. These functions may not be available in future versions of the Win32 API
    P.S. Oh yeah, how are bitmaps stored in program resource? DIB? If so,when I use a i.e. LoadBitmap(). What is that doing? Is it converting my DIB->DDB?

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    DIBs are used when access to the bits is required. For example, storing an image in a file, transmitting it over a network, or manipulating the pixels of an image.

    Otherwise DDBs are used and preferred.

    Bitmaps in a resource or a file are stored as DIBs. LoadBitmap or LoadImage (unless the LR_CREATEDIBSECTION flag is used) converts the DIB to a DDB.

    The book is assumably referring to the functions GetBitmapBits and SetBitmapBits. These functions provide the bits of a image in DDB format. As stated above, this is a no no, and these functions are obsolete.

    It should be noted that while DDBs are GDI objects, a DIB is just a byte format for bitmap images. It is not a GDI object. (There is a GDI object, known as a dib section, that differs from a DDB by allowing access to its pixels in DIB format).

    In short, what you are doing now, is likely to be fine.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Ah, thats good news! I was feeling lazy .. glad to hear I can keep as is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  2. Singly Linked Lists: Clarification Needed
    By jedispy in forum C++ Programming
    Replies: 4
    Last Post: 12-14-2006, 05:30 PM
  3. [VC++/WinAPI] DDB to DIB
    By jagi in forum Windows Programming
    Replies: 19
    Last Post: 03-26-2005, 12:27 PM
  4. DIB & DDB
    By samsam1 in forum Windows Programming
    Replies: 3
    Last Post: 01-19-2003, 12:33 PM
  5. How can I do the following..
    By Dual-Catfish in forum C++ Programming
    Replies: 14
    Last Post: 05-01-2002, 03:38 AM