How can I create a bitmap and direct the drawing methods onto it?

Hello!

I draw an image from an array pixel after pixel in my program as follow:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  const char* a_box[100] = {
            	"1","1","1","1","1","1","1","1","1","1",
		"1","0","0","0","0","0","0","0","0","1",
		"1","0","0","0","0","0","0","0","0","1",
		"1","0","0","0","0","0","0","0","0","1",
		"1","0","0","0","0","0","0","0","0","1",
		"1","0","0","0","0","0","0","0","0","1",
		"1","0","0","0","0","0","0","0","0","1",
		"1","0","0","0","0","0","0","0","0","1",
		"1","0","0","0","0","0","0","0","0","1",
		"1","1","1","1","1","1","1","1","1","1",
};

        void drawbox(HDC mygraphhandler) {
            xkoord = xplace;
            ykoord = yplace;
                for (int i=0; i<100; i++) {
                    if (i % 10 == 0) {xkoord = xplace; ykoord += 1;}
                    else if (a_box[i]=="0") {xkoord += 1;}
                    else {SetPixel(mygraphhandler,xkoord,ykoord,RGB(255,255,255)); xkoord += 1;};
                }
	};


It works correctly, but I would like draw these pixels (in this case) onto a 10*10 bitmap image to avoid continuous plotting with a loop and unnecessary overload of the program.
But how can I create and prepare a bitmap and direct the drawing methods onto it in C++?
Last edited on
Topic archived. No new replies allowed.