Solved

How to Obtain HBITMAP from LPBITMAPINFOHEADER

Posted on 2004-08-23
10
1,210 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
Technology Partners: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 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.

635 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