From afd89f5238060a25d51158f90743b80410bed01e Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 16 Jul 2014 20:47:43 +0200 Subject: [PATCH] Remove PackedPixel. The RGBX format takes more space but it is more efficient to handle. --- rotation.cpp | 58 ---------------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/rotation.cpp b/rotation.cpp index 6450367..b86bad7 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -40,24 +40,6 @@ std::basic_ostream& operator << (std::basic_ostream& return o; } -struct PackedPixel { - uint32_t r; - uint32_t g; - uint32_t b; - - PackedPixel() - : r(0) - , g(0) - , b(0) - {} -}; - -uint8_t interpolate_packed(uint32_t pack, double x, double x_inv, double y, double y_inv) -{ - return (((pack >> 24) & 0x000f) * x_inv + ((pack >> 16) & 0x000f) * x) * y_inv - + (((pack >> 8) & 0x000f) * x_inv + (pack & 0x000f) * x) * y; -} - // @@ -338,31 +320,6 @@ struct TiledImage : public Image { return tile + tile_j * tile_width + (tile_i * PIXEL_SIZE); } - PackedPixel - get_packed_pixels(unsigned int x, unsigned int y) const - { - PackedPixel pack; - - this->insert_pixel(pack, x, y); - pack.r = pack.r << 8; - pack.g = pack.g << 8; - pack.b = pack.b << 8; - - this->insert_pixel(pack, x + 1, y); - pack.r = pack.r << 8; - pack.g = pack.g << 8; - pack.b = pack.b << 8; - - this->insert_pixel(pack, x, y + 1); - pack.r = pack.r << 8; - pack.g = pack.g << 8; - pack.b = pack.b << 8; - - this->insert_pixel(pack, x + 1, y + 1); - - return pack; - } - void print_tile(unsigned int index) const { @@ -418,21 +375,6 @@ struct TiledImage : public Image { protected: - void insert_pixel(PackedPixel& pack, unsigned int x, unsigned int y) const - { - unsigned int const tile_width = tile_w * 3; - unsigned int const tile_index = (y / tile_h) * nb_col_tile + (x / tile_w); - if (tile_index >= nb_col_tile * nb_row_tile) - return; - uint8_t const* tile = tiles[tile_index]; - unsigned int const tile_j = y % tile_h; - unsigned int const tile_i = x % tile_w; - unsigned int index = tile_j * tile_width + (tile_i * 3); - pack.r += tile[index]; - pack.g += tile[index + 1] + 1; - pack.b += tile[index + 2] + 1; - } - void allocate_memory(unsigned int w, unsigned int h) { width = w;