Пример #1
0
void gr_rle_expand_scanline(ubyte *dest, ubyte *src, int x1, int x2) {
	int i = 0;
	ubyte count;
	ubyte color = 0;

	if (x2 < x1) return;

	count = 0;
	while (i < x1) {
		color = *src++;
		if (color == RLE_CODE) return;
		if ((color & RLE_CODE) == RLE_CODE) {
			count = color & (~RLE_CODE);
			color = *src++;
		}
		else {
			// unique
			count = 1;
		}
		i += count;
	}
	count = i - x1;
	i = x1;
	// we know have '*count' pixels of 'color'.

	if (x1 + count > x2) {
		count = x2 - x1 + 1;
		rle_stosb(dest, count, color);
		return;
	}

	rle_stosb(dest, count, color);
	dest += count;
	i += count;

	while (i <= x2) {
		color = *src++;
		if (color == RLE_CODE) return;
		if ((color & RLE_CODE) == RLE_CODE) {
			count = color & (~RLE_CODE);
			color = *src++;
		}
		else {
			// unique
			count = 1;
		}
		// we know have '*count' pixels of 'color'.
		if (i + count <= x2) {
			rle_stosb(dest, count, color);
			i += count;
			dest += count;
		}
		else {
			count = x2 - i + 1;
			rle_stosb(dest, count, color);
			i += count;
			dest += count;
		}
	}
}
Пример #2
0
Файл: rle.c Проект: paud/d2x-xl
// Given pointer to start of one scanline of rle data, uncompress it to
// dest, from source pixels x1 to x2.
void gr_rle_expand_scanline_masked (ubyte *dest, ubyte *src, int x1, int x2 )
{
	int i = 0;
	ubyte count;
	ubyte color=0;

	if (x2 < x1) return;

	count = 0;
	while (i < x1)	{
		color = *src++;
		if (color == RLE_CODE) return;
		if (IS_RLE_CODE (color))	{
			count = color & (~RLE_CODE);
			color = *src++;
		} else {
			// unique
			count = 1;
		}
		i += count;
	}
	count = i - x1;
	i = x1;
	// we know have '*count' pixels of 'color'.
	
	if (x1+count > x2)	{
		count = x2-x1+1;
		if (color != TRANSPARENCY_COLOR)	
			rle_stosb ((char* )dest, count, color);
		return;
	}

	if (color != TRANSPARENCY_COLOR)	
		rle_stosb ((char* )dest, count, color);
	dest += count;
	i += count;

	while (i <= x2)		{
		color = *src++;
		if (color == RLE_CODE) return;
		if (IS_RLE_CODE (color))	{
			count = color & (~RLE_CODE);
			color = *src++;
		} else {
			// unique
			count = 1;
		}
		// we know have '*count' pixels of 'color'.
		if (i+count <= x2)	{
			if (color != TRANSPARENCY_COLOR)
				rle_stosb ((char* )dest, count, color);
			i += count;
			dest += count;
		} else {
			count = x2-i+1;
			if (color != TRANSPARENCY_COLOR)
				rle_stosb ((char* )dest, count, color);
			i += count;
			dest += count;
		}

	}	
}