Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Obtain HBITMAP from LPBITMAPINFOHEADER

Posted on 2004-08-23
10
Medium Priority
?
1,219 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 80 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 120 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 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