Solved

How to Obtain HBITMAP from LPBITMAPINFOHEADER

Posted on 2004-08-23
10
1,190 Views
Last Modified: 2008-03-10
I must be missing something pretty simple here. I have a fully populated LPBITMAPINFOHEADER structure:

LPBITMAPINFOHEADER *ppbi = new LPBITMAPINFOHEADER;
GetVideoFrame(0, 0, ppbi);   // gets first frame of first stream (array begins with zero)

This part works. I now need to pass an HBITMAP to another function that will ultimately StretchBlt() it into a surface.

How do I obtain an HBITMAP from this LPBITMAPINFOHEADER?

THANKS
0
Comment
Question by:PMH4514
  • 4
  • 4
  • 2
10 Comments
 
LVL 13

Assisted Solution

by:SteH
SteH earned 20 total points
ID: 11871805
Did you had a look at
http://www.codeguru.com/bitmap/dib_to_ddb.shtml

You need to create this HBITMAP from the info supplied using LPBITMAPINFOHEADER (CreateDIBitmap or CreateBitmap)
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 30 total points
ID: 11871882
Having a BITMAPINFOHEADER structure doesn't means that it exists a bitmap object, that why you can't find a reference to HBITMAP inside the structure.
You can create a new bitmap object based on BITMAPINFOHEADER by calling CreateDIBBitmap() function:
http://msdn.microsoft.com/library/en-us/gdi/bitmaps_5d4g.asp
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11871892
sorry, simultaneous writting
0
 
LVL 13

Expert Comment

by:SteH
ID: 11871904
Don't worry, that can happen.
0
 

Author Comment

by:PMH4514
ID: 11872501
you both I believe are referring me to the CreateDIBitmap () method?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 13

Expert Comment

by:SteH
ID: 11872629
It depends on the data you got. Is it a device dependent bitmap? That means is the information of it prepared for display on the screen or was it displayed on the screen already? If yes it is most likely device dependant and you should use CreateBitmap (...). If it is calculated from some other parameters or prepared for writing to disk it is more likely a device independant bitmap and you should use CreateDIBitmap (...).

If it is a capture from a video stream I would guess to be in dependant form whereas an image extracted from a stream should be still an independant bitmap.

And what is the difference now. DIBs are normally 24 bit color, 8bit greyscale or black and white. No lookup table for colors is needed since full information is stored for each pixel. DDBs are reduced in color space to the screen resolution they should be displayed on. Either a color table defines what color corresponds to each pixel value (ie 16 or 256 colors) or only reduced set of colors is available (64k or millions of colors).
0
 

Author Comment

by:PMH4514
ID: 11872918
it's coming from a 24bit AVI stream:

in header:
PGETFRAME m_pVideoPGF[MAX_VIDEO_STREAMS];

in code:
PGETFRAME &pgf = m_pVideoPGF[nStreamNum];
*ppbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, lFrame);

and so I am left with the LPBITMAPINFOHEADER which I need to derive a CBItmap handle from.

I'll go take a look and see what I see with the CreateDIBitmap method.
0
 
LVL 13

Expert Comment

by:SteH
ID: 11872934
For 24 bit the difference should be marginal if there is one.
0
 

Author Comment

by:PMH4514
ID: 11872995
I'm confused about how to get the lpbInit and lpbmi paramaters for CreateDIBitmap() from my LPBITMAPINFOHEADER structure.
0
 

Author Comment

by:PMH4514
ID: 11874989
I figured it out :)

hBMP = ::CreateDIBitmap(hdcScreen, lpbi, CBM_INIT, pData, m_pVideoFormats[nStreamNum], DIB_PAL_COLORS);

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now