Click to See Complete Forum and Search --> : Device Context,DIB,DDB


rodolphe
December 18th, 2005, 05:16 AM
Anybody can explain me what is the Device Context,the DIB and the DDB?If we have a BMP file, what is the sequence to follow in order to read the file and modify it and redisplay the modified image.

golanshahar
December 18th, 2005, 05:36 AM
Anybody can explain me what is the Device Context,the DIB and the DDB?



Device-Dependent Bitmaps (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_5a0j.asp)
Device-Independent Bitmaps (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_9c6r.asp)




If we have a BMP file, what is the sequence to follow in order to read the
file and modify it and redisplay the modified image.

look at this threads:

LoadImage (http://www.codeguru.com/forum/showthread.php?t=354024)
loading raw image in a frame (http://www.codeguru.com/forum/showthread.php?t=349556)


Cheers

rodolphe
December 18th, 2005, 07:10 AM
golanshahar: many thanks.
Can anybody brief me in few lines what do "device context", DIB and DDB stand for? Do we have 16-bit RGB images, or an RGB image should be 24 bit? When we talk abut a 24-bit image, does that refer to every color? (so 24bit for red color, 24 bit for green and 24 bit for blue).

golanshahar
December 18th, 2005, 07:51 AM
Can anybody brief me in few lines what do "device context", DIB and DDB stand for?

here is info about Device Contexts (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_0g6r.asp), about DIB and DDB i posted you links above.


Do we have 16-bit RGB images, or an RGB image should be 24 bit? When we talk abut a 24-bit image, does that refer to every color? (so 24bit for red color, 24 bit for green and 24 bit for blue).
the (#)bits for image represent the numbers of bits for each pixel, when we talk about pixel that mean we include the (RGB) inside.
so when you talk about 16 bit image each pixel is seperated to 5 6 5 bits (this is in windows) meaning:

red = 5 bits
green = 6 bits
blue = 5 bits


in 24 bit image each seperation (r,g,b) has 8 bits.

hope its clear now. ;)

Cheers

rodolphe
December 18th, 2005, 09:34 AM
golanshahar: thanks a lot. It's clear now for the number of bits. However, I'll be very grateful if you could post "short" links about what does the "device context mean.ditto for DIB and DDB.

golanshahar
December 18th, 2005, 05:52 PM
golanshahar: thanks a lot.

You are welcome :wave:


However, I'll be very grateful if you could post "short" links about what does the "device context mean.ditto for DIB and DDB.

i dont know what are "short" links, i posted you the links above and i think it can help you understand the concept, if its not helping, you can google it or search these boards and you will find enough hits about the subject, until you will find the exact information/explaination or so called "short" links you are looking for. ;)

if you have something specific that you dont understand, dont hesitate to ask and we will try to help. :cool:

Cheers

Marc G
December 19th, 2005, 03:35 AM
[ moved thread ]

rodolphe
December 19th, 2005, 06:53 AM
golanshahar: thanks. In fact, what I need is the following: After loading a BMP image, what sequence to follow to read its content and do some modifications on. I do not need code, I only need a sequence of operation and on the light of this I can proceed to programming.

golanshahar
December 19th, 2005, 07:11 AM
golanshahar: thanks. In fact, what I need is the following: After loading a BMP image, what sequence to follow to read its content and do some modifications on. I do not need code, I only need a sequence of operation and on the light of this I can proceed to programming.

you can look at the threads above i posted you - there is even sample code for that.

the sequeance is:

::LoadImage(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/loadimage.asp) to load bmp file from disc ( which will return you a handle to the bitmap)
from that handle you can get info about the image ( width, height , bps etc ) you can get it using ::GetObject(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_912s.asp)
now to modify the image you need to work on the image bits to do so you can use ::GetBitmapBits(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7gmr.asp)/::GetDIBits(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7gms.asp).
after that you will have the raw bits of the image and you can work on that to modify the image.


Cheers

rodolphe
December 19th, 2005, 08:27 AM
golanshahar: Thanks. It's Ok for LoadImage and GetObject. However,when it comes to the GetDIBits, I would like to know why do we need to use the "CreateCompatibleDC" and all the other functions shown on the codes which are posted.I hope u can give me a hand here.