Remove PackedPixel.

The RGBX format takes more space but it is more efficient to handle.
master
Fabien Freling 2014-07-16 20:47:43 +02:00
parent a992cba5ed
commit afd89f5238
1 changed files with 0 additions and 58 deletions

View File

@ -40,24 +40,6 @@ std::basic_ostream<Elem, Traits>& operator << (std::basic_ostream<Elem, Traits>&
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;