Пример #1
0
static void sw_blit_replace_generic(struct surface_t * dst, struct rect_t * dst_rect, struct surface_t * src, struct rect_t * src_rect)
{
	struct color_t col;
	u32_t dc, sc;
	s32_t dx, dy, dw, dh;
	s32_t sx, sy;
	s32_t i, j;

	dx = dst_rect->x;
	dy = dst_rect->y;
	dw = dst_rect->w;
	dh = dst_rect->h;

	sx = src_rect->x;
	sy = src_rect->y;

	for(j = 0; j < dh; j++)
	{
		for(i = 0; i < dw; i++)
		{
			sc = surface_sw_get_pixel(src, sx + i, sy + j);
			unmap_pixel_color(&src->info, sc, &col);
			dc = map_pixel_color(&dst->info, &col);
			surface_sw_set_pixel(dst, dx + i, dy + j, dc);
		}
	}
}
Пример #2
0
bool_t map_software_point(struct surface_t * surface, s32_t x, s32_t y, u32_t c, enum blend_mode mode)
{
	s32_t minx, miny;
	s32_t maxx, maxy;

	if (!surface)
		return FALSE;

	if (!surface->pixels)
		return FALSE;

	if (surface->info.bits_per_pixel < 8)
		return FALSE;

	minx = surface->clip.x;
	maxx = surface->clip.x + surface->clip.w - 1;
	miny = surface->clip.y;
	maxy = surface->clip.y + surface->clip.h - 1;

	if (x < minx || x > maxx || y < miny || y > maxy)
	{
		return TRUE;
	}

	if(mode == BLEND_MODE_REPLACE)
	{
		surface_sw_set_pixel(surface, x, y, c);
	}
	else if(mode == BLEND_MODE_ALPHA)
	{
		surface_sw_set_pixel_with_alpha(surface, x, y, c);
	}
	else
	{
		return FALSE;
	}

	return TRUE;
}