Refactor tile data access in Bitmap and update color writing in WriteColor method
This commit is contained in:
@@ -437,9 +437,8 @@ void Bitmap::Get8x8Tile(int tile_index, int x, int y,
|
|||||||
int tile_x = (x * 8) % width_;
|
int tile_x = (x * 8) % width_;
|
||||||
int tile_y = (y * 8) % height_;
|
int tile_y = (y * 8) % height_;
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
int row_offset = tile_offset + ((tile_y + i) * width_);
|
|
||||||
for (int j = 0; j < 8; j++) {
|
for (int j = 0; j < 8; j++) {
|
||||||
int pixel_offset = row_offset + (tile_x + j);
|
int pixel_offset = tile_offset + (tile_y + i) * width_ + tile_x + j;
|
||||||
int pixel_value = data_[pixel_offset];
|
int pixel_value = data_[pixel_offset];
|
||||||
tile_data[tile_data_offset] = pixel_value;
|
tile_data[tile_data_offset] = pixel_value;
|
||||||
tile_data_offset++;
|
tile_data_offset++;
|
||||||
@@ -478,6 +477,8 @@ void Bitmap::WriteColor(int position, const ImVec4 &color) {
|
|||||||
|
|
||||||
// Write the color index to the pixel data
|
// Write the color index to the pixel data
|
||||||
pixel_data_[position] = index;
|
pixel_data_[position] = index;
|
||||||
|
data_[position] = ConvertRgbToSnes(color);
|
||||||
|
|
||||||
modified_ = true;
|
modified_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ class Tilesheet {
|
|||||||
int sheet_offset = 0);
|
int sheet_offset = 0);
|
||||||
void ModifyTile16(const std::vector<uint8_t>& graphics_buffer,
|
void ModifyTile16(const std::vector<uint8_t>& graphics_buffer,
|
||||||
const TileInfo& top_left, const TileInfo& top_right,
|
const TileInfo& top_left, const TileInfo& top_right,
|
||||||
const TileInfo& bottom_left, const TileInfo& bottom_right, int tile_id,
|
const TileInfo& bottom_left, const TileInfo& bottom_right,
|
||||||
int sheet_offset = 0);
|
int tile_id, int sheet_offset = 0);
|
||||||
|
|
||||||
void ComposeAndPlaceTilePart(const std::vector<uint8_t>& graphics_buffer,
|
void ComposeAndPlaceTilePart(const std::vector<uint8_t>& graphics_buffer,
|
||||||
const TileInfo& tile_info, int baseX, int baseY);
|
const TileInfo& tile_info, int baseX, int baseY);
|
||||||
@@ -61,16 +61,12 @@ class Tilesheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bitmap GetTile16(int tile_id) {
|
Bitmap GetTile16(int tile_id) {
|
||||||
std::cout << "GetTile16: " << tile_id << std::endl;
|
|
||||||
int tiles_per_row = bitmap_->width() / tile_width_;
|
int tiles_per_row = bitmap_->width() / tile_width_;
|
||||||
int tile_x = (tile_id % tiles_per_row) * tile_width_;
|
int tile_x = (tile_id % tiles_per_row) * tile_width_;
|
||||||
int tile_y = (tile_id / tiles_per_row) * tile_height_;
|
int tile_y = (tile_id / tiles_per_row) * tile_height_;
|
||||||
std::cout << "Tile X: " << tile_x << " Tile Y: " << tile_y << std::endl;
|
|
||||||
|
|
||||||
std::vector<uint8_t> tile_data(tile_width_ * tile_height_, 0x00);
|
std::vector<uint8_t> tile_data(tile_width_ * tile_height_, 0x00);
|
||||||
int tile_data_offset = 0;
|
int tile_data_offset = 0;
|
||||||
bitmap_->Get16x16Tile(tile_x, tile_y, tile_data, tile_data_offset);
|
bitmap_->Get16x16Tile(tile_x, tile_y, tile_data, tile_data_offset);
|
||||||
|
|
||||||
return Bitmap(16, 16, bitmap_->depth(), tile_data);
|
return Bitmap(16, 16, bitmap_->depth(), tile_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user