Tech Support > Microsoft Windows > Development Resources > Convert Char *buffer to HBitmap
Convert Char *buffer to HBitmap
Posted by Rasheed on May 23rd, 2008


Hi,
i have a char pointer buffer which will hold the bitmap buffer, So i
need to convert char *buffer as a bitmap.
becuase when i draw on the Dialog using char *buffer. Nothing will be
dispalyed.

So kindly can any body help me how to convert char *buffer to bitmap.

i want the solution in C++

regards
Rasheed

Posted by Jerry Coffin on May 24th, 2008


In article <f09a30e4-f9a6-4de2-8dd6-4657040e0728
@y22g2000prd.googlegroups.com>, sk.rasheedfarhan@gmail.com says...
Contrary to what its name implies, CreateDIBitmap creates a device
dependent bitmap, (optionally) using a buffer of data to initialize the
bitmap.

Another possibility is to use CreateDibSection. This gives you access to
the content of the bitmap as an array of bytes, so you can copy your
data into it.

Note the difference: CreateDIBitmap just creates a normal bitmap,
initializing it from your array of bytes. A DIB Section allows you to
manipulate the data either as a bitmap or an array of bytes on an
ongoing basis. If you really want that ongoing view both as bitmap and
array of bytes, definitely go for the DIB section. If you JUST want to
initialize the bitmap from your data, CreateDIBitmap should be enough.

--
Later,
Jerry.

The universe is a figment of its own imagination.

Posted by Rasheed on May 26th, 2008


please help me out how to fill the BITMAPINFOHEADER & BITMAPINFO
structure or Provide any sample application on CreateDIBitmap willl be
great help.


regards
Rasheed

Posted by r_z_aret@pen_fact.com on May 27th, 2008


On Mon, 26 May 2008 11:21:52 -0700 (PDT), Rasheed
<sk.rasheedfarhan@gmail.com> wrote:

I just used google (http://www.google.com/advanced_search?hl=en) to
look up
createdibitmap sample
in this newsgroup and got 3130 hits. I took a quick look and didn't
see anything directly useful, but I'm pretty sure a bit of wading
would turn up leads to sample code.

I couldn't find any samples in the help that came with my copy of
Visual studio (I used Help->Search to look up createdibitmap), but
it's an easy search, and your copy may have something. I don't have
samples loaded with my copy of visual studio, but they are often
valuable.

Finally, I went to www.microsoft.com, searched for
createdibitmap sample
and got 141 hits. I took a quick look at the first one, and it looks
relevant and useful.




-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 400
Boston, MA 02116
www.penfact.com
Useful reading (be sure to read its disclaimer first):
http://catb.org/~esr/faqs/smart-questions.html


Similar Posts