How to render a bitmap on a basic window?

Im currently learning c++ (well ive read through 1.5 tutorials and remember everything i could use some day) and trying to learn win32 (mostly just basics)

now, can someone tell me how do i render a bitmap (a 2 dimension array) on a basic window? thats all i need... as i want to edit the bits one by one on the array and then render it...
Just BitBlt()
Hundreds of samples in MSDN (doc, KB, SDK, etc...)
BitBlt is necessary.

Also, CreateDIBSection is the one to know if you want quick pixel-level access.

I might post an example when I'm not at work. In the meantime you can search MSDN/the web.
ok. ill wait for the example so i dont need to read through a ton of tutorials and convert them from c to c++ >.>
well to be honest I totally forgot about this thread yesterday, so I didn't get around to it. Sorry.

Maybe tonight.
ok.
i can read some ways to program stuff while waiting (or play a game...)
I started to write some examples but I got lazy and forgot how much fun WinAPI ain't.

So here's links to CreateDIBSection and BitBlt because I'm lazy:

http://msdn.microsoft.com/en-us/library/dd183494(VS.85).aspx CreateDIBSection
http://msdn.microsoft.com/en-us/library/aa930997.aspx

If you have specific questions, I can answer them, but I don't have the energy for a full detailed explanation/tutorial right now. Sorry.
i need this to make a simple header to display a 2 dimension array on a window... how do i convert the array to the right form, or is there a better way than array to do it (like making a Bitmap and using a function to draw a pixel on it?)
*waits*



*no answer*


*reads microsoft documents*


*cant find the Conver2DArrayToBitMap() function*
*sad face <;C*
*finds out that array to store enuf data for color,depth and bump would take just 12 million bytes for a 1200*1000 screen*

ok i think ive now read enough of microsoft references to be able to make something working.... wich means ill try to do it tomorrow if i have time, or after few days because im uber lazy.
Last edited on
O.e too... complex...

i dont know what of those to use... there are too many things that would need to be somehow connected together...
Oh alright.. it's the weekend... I'll whip together an example for you.

Hold.

EDIT:

but note that I'm not on Windows so I won't actually be able to test what I write.


EDIT 2:

Here. I made a whole class for you: http://pastebin.com/m4822d4ff

I *think* colors are in the form 0xAARRGGBB so full red would be 0xFFFF0000 and full blue would be 0xFF0000FF. But you'll want to test that out. Like I said I couldn't test this code (or even compile it) because I don't have a windows machine handy.

You're probably fine leaving AA as 00, since I don't think alpha blending works with BitBlt anyway.

Also, I think WinAPI has a RGB macro for this which you might be able to use.

Example usage:

1
2
3
4
5
6
7
8
9
10
// make a 100x100 bitmap
Bitmap32 foo(100,100);

// set pixel 40,32 to be full green
foo(40,32) = 0xFF00FF00;

// blit to another dc
HDC screen = /*get the screen dc or whatever */
HDC mydc = foo.GetDC();
BitBlt( /*blit from 'mydc' to 'screen'*/ );
Last edited on
> O.e too... complex...

???
It's 8 lines of code.
Copy-paste any of the 1500 MSDN samples, C and C++ : done in 2 seconds (!)
Topic archived. No new replies allowed.