49 constexpr int kWidth = 512;
50 constexpr int kHeight = 512;
51 constexpr int kPixelCount = kWidth * kHeight;
54 static int last_room_id = -1;
55 if (room.
id() != last_room_id) {
56 last_room_id = room.
id();
57 LOG_DEBUG(
"LayerManager",
"Room %03X: BG1_Layout(vis=%d,blend=%d) "
58 "BG1_Objects(vis=%d,blend=%d) BG2_Layout(vis=%d,blend=%d) "
59 "BG2_Objects(vis=%d,blend=%d) MergeType=%d",
73 if (output.
width() != kWidth || output.
height() != kHeight) {
74 output.
Create(kWidth, kHeight, 8,
75 std::vector<uint8_t>(kPixelCount, 255));
82 bool palette_copied =
false;
91 auto CopyPaletteIfNeeded = [&](
const gfx::Bitmap& src_bitmap) {
92 if (!palette_copied && src_bitmap.surface()) {
93 ApplySDLPaletteToBitmap(src_bitmap.surface(), output);
94 palette_copied =
true;
116 const auto& src_bitmap = buffer.
bitmap();
117 if (!src_bitmap.is_active() || src_bitmap.width() == 0)
return;
122 CopyPaletteIfNeeded(src_bitmap);
124 const auto& src_data = src_bitmap.data();
130 for (
int idx = 0; idx < kPixelCount; ++idx) {
131 uint8_t src_pixel = src_data[idx];
138 switch (blend_mode) {
141 dst_data[idx] = src_pixel;
149 dst_data[idx] = src_pixel;
158 dst_data[idx] = src_pixel;
163 dst_data[idx] = src_pixel;
169 dst_data[idx] = src_pixel;
196 if (!palette_copied) {
197 const auto& bg1_bitmap = room.
bg1_buffer().bitmap();
198 if (bg1_bitmap.surface()) {
199 ApplySDLPaletteToBitmap(bg1_bitmap.surface(), output);
210 SDL_SetColorKey(output.
surface(), SDL_TRUE, 255);
211 SDL_SetSurfaceBlendMode(output.
surface(), SDL_BLENDMODE_BLEND);
217 SDL_SetSurfaceColorMod(output.
surface(), 128, 128, 128);
220 SDL_SetSurfaceColorMod(output.
surface(), 255, 255, 255);
void Create(int width, int height, int depth, std::span< uint8_t > data)
Create a bitmap with the given dimensions and data.