1 #ifndef __RLE_BITMAP_H__
2 #define __RLE_BITMAP_H__
4 /* Limit streak count per scanline so we can directly jump to specific scanline
6 #define RLE_STREAKS_PER_SCANLINE 4
8 /* Streaks will not exceed this many pixels. This allows us to optimize with a
9 * padded framebuffer. If a streak start position happens to lie within
10 * framebuffer, we will blit it without checking for out of bounds */
11 #define RLE_MAX_STREAK_LENGTH 32
13 /* Using the following type for storing start and for storing length in (start,
15 #define RLE_TYPE unsigned char
17 /* For now, keep a static fill color. We can change this. Not that much about
18 * speed, but let's keep function definitions more compact. */
19 #define RLE_FILL_COLOR 0
21 /* Two entries of RLE_FILL_COLOR (16 bits) packed one after the other. */
22 #define RLE_FILL_COLOR_32 ((RLE_FILL_COLOR << 16) | RLE_FILL_COLOR)
24 /* For fixed-point arithmetic. Used for scaling. */
25 #define RLE_FIXED_BITS 16
27 /* This is a bitmap (image in 1bpp), encoded as streaks of consecutive pixels.
32 /* Each scan is RLE_BYTES_PER_SCANLINE long and contains pairs of
38 RleBitmap *rleCreate(unsigned int w, unsigned int h);
41 void rleDestroy(RleBitmap *rle);
43 /* Clears 'rle' to "all transparent" */
44 void rleClear(RleBitmap *rle);
46 /* Encode 'pixels' into 'rle' and also return it. Pixels are either 0 or 1. This
47 * will create an RleBitmap of 'h' scanlines. */
48 RleBitmap *rleEncode(RleBitmap *rle, unsigned char *pixels, unsigned int pixelsW,
49 unsigned int pixelsH);
51 /* Rearranges the streaks to make it less frequent that they produce garbege when interpolated */
52 void rleDistributeStreaks(RleBitmap *rle);
54 /* Blits without scaling */
55 void rleBlit(RleBitmap *rle, unsigned short *dst, int dstW, int dstH, int dstStride, int blitX,
59 void rleBlitScale(RleBitmap *rle, unsigned short *dst, int dstW, int dstH, int dstStride, int blitX,
60 int blitY, float scaleX, float scaleY);
62 /* Inverted blit (upside down) */
63 void rleBlitScaleInv(RleBitmap *rle, unsigned short *dst, int dstW, int dstH, int dstStride,
64 int blitX, int blitY, float scaleX, float scaleY);
66 #endif // __RLE_BITMAP_H__