Jump to content
  • Advertisement
Sign in to follow this  
qzole

How to create a bitmap from vector of color int GDI

This topic is 3758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all! //problem after this phrase I want to use png images in my program, with gdi, and because of the lack of time, I wanted a fast solution for loading png images. Well, I looked at libpng and... I really only need to load png files, I don't want to make a new photshop :) So I luckly found Lode's greate png decoder/encoder, and downloaded from his site the great picoPNG, just what I need, doesn't do anything fancy just loads png images, easy to use, compiles without problems, as for understanding, as I said I don't have the time now to learn about pngs. //problem So the problem is I used picoPNG, I got the vector, but I don't really know how can I create a Bitmap from it for the GDI (not GDI+). Tried whit CreateBitmap HBITMAP CreateBitmap( int nWidth, // bitmap width, in pixels int nHeight, // bitmap height, in pixels UINT cPlanes, // number of color planes UINT cBitsPerPel, // number of bits to identify color CONST VOID *lpvBits // color data array ); But I don't really know the number of color planes, or what does it represent, and I don't know for sure, if it accepts the vector as the color data array, I tired, but it returned with a NULL handle, which means error. Could someone help, or point somewhere where it writes it down clearly? Thank you in advance, And thanks Lode for the great PNG decoder, Q.

Share this post


Link to post
Share on other sites
Advertisement
You should use CreateDIBitmap. It can be a bit complicated if this is your first time playing with this stuff but you should be able to google lots of code demonstrating how to use it.

The number of planes will be 1. Unless you are posting from the 80's and you're having issues with your EGA card. biSizeImage, *PelsPerMeter, biClrUsed, and biClrImportant can all be left as 0.

A common error is that CreateDIBitmap requires scanlines to be padded out to be a multiple of a DWORD. This can be an issue with color depths less than 32bpp.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!