Creating a bitmap (probably not what you're thinking)

Started by
3 comments, last by KevinG 20 years ago
So I''m trying to create this map editing program, but I''ve run into a small problem. I''m using a paletted directdraw to draw graphics in my game, so I saw it useless to use bitmaps (would take up more storage space/memory). My graphics are set up like this: (An 8x8 cross where one is a color specified in the palette) 0,0,0,1,1,0,0,0 0,0,0,1,1,0,0,0 0,0,0,1,1,0,0,0 1,1,1,1,1,1,1,1 1,1,1,1,1,1,1,1 0,0,0,1,1,0,0,0 0,0,0,1,1,0,0,0 0,0,0,1,1,0,0,0 How do I convert this simple format into a bitmap so that my Win32 editor can display it (using the palette I''ve made)?
I cant think of a decent signature right now...try back later...MUCH later.
Advertisement
Im not sure do I follow but you would draw that cross like this:

BYTE cross[] = {0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0};int main(){int width = 8;int height = 8;for(int y = 0; y < height; y++){	for(int x = 0; x < width; x++)	{	 DrawPixel(x,y,palette[cross[x+y*width]]);	}}return 0;}


[edited by - Craazer on April 3, 2004 4:58:59 PM]
quote:Original post by KevinG
so I saw it useless to use bitmaps (would take up more storage space/memory).
It's only a few bytes more (some bytes for header and info, and 768 bytes for the palette). Why the hassle?

So, you are asking how to display your 8x8 cross in your Win32 editor?

edit:
add teh quote.
misread OP question.


[edited by - alnite on April 3, 2004 5:37:44 PM]
Simply use 8 bit palleted bitmap like alnite said.

You can allways save your bitmap in a raw format for use in your game/program, but for editing write a small utility that combines your image data with the palette in standard bitmap format. Then use another small utility (or same one with different parameters) to break them apart again.
If your program is not yet loading any bitmaps, and you only need one or two, then it sounds fine. I wouldn't recommend coding your bitmaps otherwise. You definitely are not saving any memory. You have to realize that even if you code your function to draw each pixel in a specific location, the function itself will require at least as much memory as your bitmap, and that memory will allocate every time the function is called (instead of just loading it at startup).

The only way it would save memory is if you made intelligent loops to run through lines. (make a VLine and HLine function, then create a DrawCross function which relies on them).

quote:Original post by alnite
and 768 bytes for the palette). Why the hassle?

His palette would still require 768 bytes, even with code-bitmaps.

EDIT: You could also do this:

RectFill 3x3 at location 0,0 with color 0
RectFill 2x3 at location 3,0 with color 1
RectFill 3x3 at location 5,0 with color 0
RectFill 8x2 at location 0,3 with color 1
RectFill 3x3 at location 0,5 with color 0
RectFill 2x3 at location 3,5 with color 1
RectFill 3x3 at location 5,5 with color 0

If the corners are meant to be transparent, you can delete the "with color 0" lines, and have only 3 lines of code. I'm sure you could optimize it even further. I would just load bitmaps.

[edited by - Jiia on April 3, 2004 12:11:09 AM]

This topic is closed to new replies.

Advertisement