diff --git a/src/app/editor/overworld/overworld_editor.cc b/src/app/editor/overworld/overworld_editor.cc index 84f37862..1cdf330d 100644 --- a/src/app/editor/overworld/overworld_editor.cc +++ b/src/app/editor/overworld/overworld_editor.cc @@ -1077,8 +1077,8 @@ absl::Status OverworldEditor::LoadGraphics() { util::logf("Loading overworld tile16 graphics."); // Loop through the tiles and copy their pixel data into separate vectors for (unsigned int i = 0; i < zelda3::kNumTile16Individual; i++) { - tile16_individual_[i].Create(kTile16Size, kTile16Size, 0x08, - kTile16Size * kTile16Size); + std::vector tile16_data(kTile16Size * kTile16Size); + tile16_individual_[i].Create(kTile16Size, kTile16Size, 0x08, tile16_data); // Copy the pixel data for the current tile into the vector for (int ty = 0; ty < kTile16Size; ty++) { diff --git a/src/app/gfx/bitmap.cc b/src/app/gfx/bitmap.cc index 84d0db9a..1b69a9c0 100644 --- a/src/app/gfx/bitmap.cc +++ b/src/app/gfx/bitmap.cc @@ -6,9 +6,11 @@ #endif #include +#include #include #include "absl/status/status.h" +#include "app/core/platform/renderer.h" #include "app/gfx/snes_palette.h" #include "util/macro.h" @@ -209,10 +211,6 @@ void Bitmap::SaveSurfaceToFile(std::string_view filename) { SDL_SaveBMP(surface_.get(), filename.data()); } -Bitmap::Bitmap(int width, int height, int depth, int data_size) { - Create(width, height, depth, std::vector(data_size, 0)); -} - void Bitmap::Initialize(int width, int height, int depth, std::span &data) { width_ = width; diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index af9dd990..32807533 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -67,8 +67,6 @@ void ConvertPngToSurface(const std::vector &png_data, class Bitmap { public: Bitmap() = default; - - Bitmap(int width, int height, int depth, int data_size); Bitmap(int width, int height, int depth, const std::vector &data) : width_(width), height_(height), depth_(depth), data_(data) { Create(width, height, depth, data); @@ -85,6 +83,7 @@ class Bitmap { std::cerr << "Error applying palette in bitmap constructor." << std::endl; } } + void Initialize(int width, int height, int depth, std::span &data); #if YAZE_LIB_PNG == 1 std::vector GetPngData(); @@ -92,11 +91,6 @@ class Bitmap { void SaveSurfaceToFile(std::string_view filename); - void Initialize(int width, int height, int depth, std::span &data); - - void Create(int width, int height, int depth, int data_size) { - Create(width, height, depth, std::vector(data_size, 0)); - } void Create(int width, int height, int depth, std::span data); void Create(int width, int height, int depth, const std::vector &data); diff --git a/src/app/gfx/tilesheet.cc b/src/app/gfx/tilesheet.cc index 0c3bcdba..7efa5a00 100644 --- a/src/app/gfx/tilesheet.cc +++ b/src/app/gfx/tilesheet.cc @@ -44,8 +44,8 @@ absl::StatusOr CreateTilesheetFromGraphicsBuffer( } void Tilesheet::Init(int width, int height, TileType tile_type) { - bitmap_ = std::make_shared(width, height, 8, 0x20000); internal_data_.resize(0x20000); + bitmap_ = std::make_shared(width, height, 8, internal_data_); tile_type_ = tile_type; if (tile_type_ == TileType::Tile8) { tile_width_ = 8;