Skip to content
Permalink
Browse files

SLUDGE: Fix png displaying

  • Loading branch information...
yinsimei authored and sev- committed May 29, 2017
1 parent ca2ee02 commit 6e5dec313788be6ac3083e9d3ca30a9b66243894
Showing with 12 additions and 3 deletions.
  1. +9 −3 engines/sludge/backdrop.cpp
  2. +3 −0 engines/sludge/main_loop.cpp
@@ -58,6 +58,7 @@
#include "common/debug.h"
#include "image/png.h"
#include "graphics/surface.h"
#include "graphics/palette.h"
#include "sludge.h"

namespace Sludge {
@@ -81,6 +82,7 @@ GLuint snapshotTextureName = 0;

Graphics::Surface backdropSurface;


float snapTexW = 1.0;
float snapTexH = 1.0;

@@ -1017,6 +1019,8 @@ bool loadPng(int &picWidth, int &picHeight, int &realPicWidth,
return false;
}
backdropSurface.copyFrom(*(png.getSurface()));
const byte *palette = png.getPalette();
g_system->getPaletteManager()->setPalette(palette, 0, 256);
picWidth = realPicWidth = backdropSurface.w;
picHeight = realPicHeight = backdropSurface.h;
return true;
@@ -1137,11 +1141,12 @@ bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth,
bool loadImage(int &picWidth, int &picHeight, int &realPicWidth,
int &realPicHeight, Common::SeekableReadStream *stream, int x, int y,
bool reserve) {
debug(kSludgeDebugGraphics, "Loading back drop image.");
debug(kSludgeDebugGraphics, "Loading back drop image at file position: %i", stream->pos());
if (!loadPng(picWidth, picHeight, realPicWidth, realPicHeight, stream,
reserve)) {
if (!loadByteArray(picWidth, picHeight, realPicWidth, realPicHeight,
stream, reserve)) {
debug(kSludgeDebugGraphics, "Back drop loading failed");
return false;
}
}
@@ -1151,9 +1156,10 @@ bool loadImage(int &picWidth, int &picHeight, int &realPicWidth,
if (y == IN_THE_CENTRE)
y = (sceneHeight - realPicHeight) >> 1;
if (x < 0 || x + realPicWidth > sceneWidth || y < 0
|| y + realPicHeight > sceneHeight)
|| y + realPicHeight > sceneHeight) {
debug(kSludgeDebugGraphics, "Illegal back drop size");
return false;

}
return true;
}

@@ -74,6 +74,7 @@
#include "graphics.h"
#include "helpers.h"
#include "graphics/surface.h"
#include "common/debug.h"

namespace Sludge {

@@ -480,7 +481,9 @@ int main_loop(char *filename)
g_system->copyRectToScreen(backdropSurface.getPixels(),
backdropSurface.pitch, 0, 0, backdropSurface.w,
backdropSurface.h);
//g_system->getPaletteManager()->setPalette(_image->getPalette(), 0, 256);
g_system->updateScreen();
g_system->delayMillis(100);
#if 0
Wait_Frame();
#endif

0 comments on commit 6e5dec3

Please sign in to comment.
You can’t perform that action at this time.