Original Post
i was wondering if this would be beneficial in reading/loading sprites when using SDL or DirectDraw.
here''s an excerpt explaining it a little:
quote:or are there far better ways? or is what''s in SDL/DDraw enough?
RLE transparent sprites Doing a compare for each pixel is a slow way to draw a transparent sprite. A better (one of many better ways) is to encode the sprite with RLE (Run Length Encoding). RLE is a simple compression method that we will alter to speed up drawing transparent sprites. This is a two step process, 1. The sprite is converted to a RLE sprite, 2. We draw the RLE sprite. A RLE sprite has codes imbedded in it that tell us to skip, or draw strings of pixels. A string of pixels just means some pixels in a row. To make a RLE sprite we read in the sprite, and count zero, and non zero pixels. These are then replaced with codes that indicate when we skip, and when we draw. This speeds things up because we only have to do a compare at the end of each string, instead of for each pixel. Example A zero byte means the next byte is the number of bytes to SKIP. A non-zero bytes means the next byte is the number of pixels to draw, and it will be followed by that number of pixels. Lets look at one line of a simple bitmap that has zero bytes on each end. 000000000111224567864450000000 This will be encoded as follows: 00,09,01,14, 11122456786445, 00,07 a b c d e f g Byte a is a zero, so the next byte will be the number of pixels to skip. Byte b is 9, the number of pixels to skip Byte c is a 1 so the next byte will be the number of pixels to draw. Byte d is 14 which means the there are 14 pixels to draw Byte e is the start of the 14 pixels to draw Byte f is zero so the next byte is the number of pixels to skip Byte g is the number of pixels to skip which brings us to the end of the line There are also other methods, for example a sprite can be compiled which turns it into code that draws the sprite. You then draw the sprite by actually ''calling'' the sprite as a function.