Looking for a solution to a drawing dilemma

BlitzMax Forums/BlitzMax Programming/Looking for a solution to a drawing dilemma

SpaceAce(Posted 2008) [#1]
I'm fiddling around with a program to interpret and display graphics that come packaged in a kind of funny format. All drawing is done using 6x12 tiles, each tile consisting of two colors. Each pixel inside the tile can be either set to 0 or 1, each number corresponding to one of the tile's colors.

The data comes in packets of 24 bytes, some packets contain drawing instructions, others do not. The packets that contain drawing information look like this:

Byte 1-8: Not important, here.
Byte 9: Color 0
Byte 10: Color 1
Byte 11: Row (all positioning is done by row/column multiplied by six or twelve to get screen coordinates.)
Byte 12: Column
Bytes 13-24: Graphics data using only the bottom six bits of each byte. 0 bits = color 0, 1 bits = color 1. So, this byte:
00010110
would be masked off to 010110, corresponding to three color 0 pixels and three color 1 pixels.

The drawing area is 300x216, broken up into 6x12 rows and columns. Each drawing instruction can contain a maximum of 6x12 pixels, but a series of instructions one after the other could potentially force the redrawing of the entire 300x216 area.

Still with me? OK. Plot() is way, way, way too slow as far as I can tell. Speed is important for this application. I've been fiddling around with Pixmaps (and the DrawPixmapFast function that's been floating around these forums forever), but even that seems to be a little on the slow side if a lot of drawing gets done.

So, are Pixmaps by best bet, here? One problem is that the drawing instructions can call for the use of a transparent color. I haven't used BlitzMax much, lately, but isn't that a no-go with Pixmaps? Can I gain any speed by breaking the drawing area into multiple pixmaps and only redrawing "dirty" pixmaps each frame? If all the pixmaps become dirty at once, or one right after the other, will I be facing a big speed penalty if I need to draw and show several pixmaps at once? Finally, the drawing instructions can call for shifting or scrolling of the tiles, where pixels shifted off one side appear on the other. This is pretty easy (and quick enough) with regular images and a DrawImageRect() function, but how should I approach the problem when using Pixmaps?

Thanks,
SpaceAce


Warpy(Posted 2008) [#2]
I suggest creating an image for each tile, then using LockImage and UnlockImage to make them as pixmaps. You can then do scrolling and whatever very easily using DrawImage.


SpaceAce(Posted 2008) [#3]
Interesting, I considered that but I thought all the locking and unlocking would be slow. Thanks for the suggestion, I'll play around with it and see what I come up with.

In the meantime, I am open to more suggestions.

SpaceAce


Warpy(Posted 2008) [#4]
It will be slow, but you should only need to do it once, when you load the image.


Arowx(Posted 2008) [#5]
There shouldn't be a problem with the transparency as the pixmap format supports an alpha channel (PF_RGBA8888 or PF_BGRA8888).


SpaceAce(Posted 2008) [#6]
Marx,
I realized that after I typed the original post. I think I was confused by a problem I remember having with MaxGUI, involving transparency and pixmaps.

SpaceAce