Solved

How to Obtain HBITMAP from LPBITMAPINFOHEADER

Posted on 2004-08-23
10
1,203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

763 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