EMI: Directly use converted buffer

Data is already converted to the correct format by copyBuffer, so write
it directly to save file.
This fixes save game screenshots taken with TinyGL renderer: Bitmap
constructor calls graphic driver's createBitmap method, and TinyGL's
converts the buffer to its own buffer pixel format - undoing the conversion
storeSaveGameImage did just before.
This commit is contained in:
Vincent Pelletier 2017-04-26 12:57:29 +00:00
parent a8612e130f
commit 66d24776ec

View File

@ -221,25 +221,19 @@ void EMIEngine::storeSaveGameImage(SaveGame *state) {
// screenshots are not using the whole size of the texture
// copy the actual screenshot to the correct position
unsigned int texWidth = 256, texHeight = 128;
Graphics::PixelBuffer buffer = Graphics::PixelBuffer::createBuffer<565>(texWidth * texHeight, DisposeAfterUse::YES);
unsigned int size = texWidth * texHeight;
Graphics::PixelBuffer buffer = Graphics::PixelBuffer::createBuffer<565>(size, DisposeAfterUse::YES);
buffer.clear(texWidth * texHeight);
for (unsigned int j = 0; j < 120; j++) {
buffer.copyBuffer(j * texWidth, j * width, width, screenshot->getData(0));
}
Bitmap *newscreenshot = new Bitmap(buffer, texWidth, texHeight, "screenshot");
state->beginSection('SIMG');
if (newscreenshot) {
int size = newscreenshot->getWidth() * newscreenshot->getHeight();
uint16 *data = (uint16 *)newscreenshot->getData(0).getRawBuffer();
for (int l = 0; l < size; l++) {
state->writeLEUint16(data[l]);
}
} else {
error("Unable to store screenshot");
uint16 *data = (uint16 *)buffer.getRawBuffer();
for (unsigned int l = 0; l < size; l++) {
state->writeLEUint16(data[l]);
}
state->endSection();
delete newscreenshot;
delete screenshot;
}