48 constexpr int kWidth = 512;
49 constexpr int kHeight = 512;
50 constexpr int kPixelCount = kWidth * kHeight;
53 if (output.
width() != kWidth || output.
height() != kHeight) {
54 output.
Create(kWidth, kHeight, 8,
55 std::vector<uint8_t>(kPixelCount, 255));
62 bool palette_copied =
false;
71 auto CopyPaletteIfNeeded = [&](
const gfx::Bitmap& src_bitmap) {
72 if (!palette_copied && src_bitmap.surface()) {
73 ApplySDLPaletteToBitmap(src_bitmap.surface(), output);
74 palette_copied =
true;
96 const auto& src_bitmap = buffer.
bitmap();
97 if (!src_bitmap.is_active() || src_bitmap.width() == 0)
return;
102 CopyPaletteIfNeeded(src_bitmap);
104 const auto& src_data = src_bitmap.data();
110 for (
int idx = 0; idx < kPixelCount; ++idx) {
111 uint8_t src_pixel = src_data[idx];
118 switch (blend_mode) {
121 dst_data[idx] = src_pixel;
129 dst_data[idx] = src_pixel;
138 dst_data[idx] = src_pixel;
143 dst_data[idx] = src_pixel;
149 dst_data[idx] = src_pixel;
176 if (!palette_copied) {
177 const auto& bg1_bitmap = room.
bg1_buffer().bitmap();
178 if (bg1_bitmap.surface()) {
179 ApplySDLPaletteToBitmap(bg1_bitmap.surface(), output);
190 SDL_SetColorKey(output.
surface(), SDL_TRUE, 255);
191 SDL_SetSurfaceBlendMode(output.
surface(), SDL_BLENDMODE_BLEND);
197 SDL_SetSurfaceColorMod(output.
surface(), 128, 128, 128);
200 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.