Pass tile to rotate_pixel() instead of image.

master
Fabien Freling 2014-07-04 00:23:54 +02:00
parent 80975f6138
commit 7f29bd192a
1 changed files with 4 additions and 6 deletions

View File

@ -694,9 +694,9 @@ Image* rotate(Image const& src, double angle)
// //
template<unsigned int W, unsigned int H> template<unsigned int W, unsigned int H>
void rotate_pixel(TiledImage<W, H> const& src, TiledImage<W, H>& rotated, void rotate_pixel(TiledImage<W, H> const& src,
DPoint const& src_rotated_point, DPoint const& src_rotated_point,
unsigned int rot_tile_index, unsigned int rot_index) uint8_t* rot_tile, unsigned int rot_index)
{ {
uint8_t const* src_index_1 = src.access_pixel((int) src_rotated_point.x, (int) src_rotated_point.y); uint8_t const* src_index_1 = src.access_pixel((int) src_rotated_point.x, (int) src_rotated_point.y);
@ -708,7 +708,6 @@ void rotate_pixel(TiledImage<W, H> const& src, TiledImage<W, H>& rotated,
// special case if we can directly map the src to the dest // special case if we can directly map the src to the dest
if (x_delta == 0 && y_delta == 0) if (x_delta == 0 && y_delta == 0)
{ {
uint8_t* rot_tile = rotated.tiles[rot_tile_index];
memcpy(&rot_tile[rot_index], src_index_1, 3 * sizeof (uint8_t)); memcpy(&rot_tile[rot_index], src_index_1, 3 * sizeof (uint8_t));
return; return;
} }
@ -743,7 +742,6 @@ void rotate_pixel(TiledImage<W, H> const& src, TiledImage<W, H>& rotated,
top_left = _mm_add_ps(top_left, bottom_left); top_left = _mm_add_ps(top_left, bottom_left);
// convert float values to uint8_t // convert float values to uint8_t
uint8_t* rot_tile = rotated.tiles[rot_tile_index];
rot_tile[rot_index] = top_left[3]; rot_tile[rot_index] = top_left[3];
rot_tile[rot_index + 1] = top_left[2]; rot_tile[rot_index + 1] = top_left[2];
rot_tile[rot_index + 2] = top_left[1]; rot_tile[rot_index + 2] = top_left[1];
@ -797,9 +795,9 @@ rotate(TiledImage<W, H> const& src, double angle)
|| src_rotated_point.y < 0 || src_rotated_point.y > src.height) || src_rotated_point.y < 0 || src_rotated_point.y > src.height)
continue; continue;
rotate_pixel(src, *rotated, rotate_pixel(src,
src_rotated_point, src_rotated_point,
rot_tile_index, rot_index); rotated->tiles[rot_tile_index], rot_index);
src_rotated_point.x += src_delta_x.x; src_rotated_point.x += src_delta_x.x;
src_rotated_point.y += src_delta_x.y; src_rotated_point.y += src_delta_x.y;