aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp32
-rw-r--r--backends/graphics/sdl/sdl-graphics.cpp10
-rw-r--r--backends/platform/android/gfx.cpp4
-rw-r--r--backends/platform/android/texture.cpp16
-rw-r--r--backends/platform/dc/display.cpp2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp6
-rw-r--r--backends/platform/iphone/osys_video.cpp2
-rw-r--r--backends/platform/n64/osys_n64_base.cpp2
-rw-r--r--backends/platform/ps2/Gs2dScreen.cpp4
-rw-r--r--backends/platform/ps2/systemps2.cpp2
-rw-r--r--backends/platform/psp/default_display_client.cpp2
-rw-r--r--backends/platform/wii/osystem_gfx.cpp4
-rw-r--r--backends/vkeybd/virtual-keyboard-gui.cpp10
-rw-r--r--engines/agos/agos.cpp18
-rw-r--r--engines/draci/surface.cpp2
-rw-r--r--engines/gob/videoplayer.cpp2
-rw-r--r--engines/groovie/graphics.cpp4
-rw-r--r--engines/groovie/roq.cpp13
-rw-r--r--engines/hugo/dialogs.cpp8
-rw-r--r--engines/hugo/intro.cpp6
-rw-r--r--engines/lastexpress/data/animation.cpp2
-rw-r--r--engines/lastexpress/data/sequence.cpp2
-rw-r--r--engines/lastexpress/graphics.cpp11
-rw-r--r--engines/m4/dialogs.cpp2
-rw-r--r--engines/m4/graphics.cpp10
-rw-r--r--engines/m4/graphics.h8
-rw-r--r--engines/made/pmvplayer.cpp2
-rw-r--r--engines/made/resource.cpp6
-rw-r--r--engines/made/screen.cpp6
-rw-r--r--engines/mohawk/bitmap.cpp14
-rw-r--r--engines/mohawk/cursors.cpp2
-rw-r--r--engines/mohawk/graphics.cpp14
-rw-r--r--engines/mohawk/video.cpp4
-rw-r--r--engines/parallaction/balloons.cpp6
-rw-r--r--engines/parallaction/disk.cpp2
-rw-r--r--engines/parallaction/disk_br.cpp2
-rw-r--r--engines/parallaction/disk_ns.cpp2
-rw-r--r--engines/parallaction/graphics.cpp4
-rw-r--r--engines/parallaction/gui_br.cpp2
-rw-r--r--engines/parallaction/gui_ns.cpp4
-rw-r--r--engines/parallaction/input.cpp6
-rw-r--r--engines/parallaction/inventory.cpp2
-rw-r--r--engines/saga/gfx.cpp2
-rw-r--r--engines/saga/render.cpp2
-rw-r--r--engines/sci/video/robot_decoder.cpp2
-rw-r--r--engines/sci/video/seq_decoder.cpp2
-rw-r--r--engines/scumm/charset.cpp16
-rw-r--r--engines/scumm/cursor.cpp2
-rw-r--r--engines/scumm/gfx.cpp91
-rw-r--r--engines/scumm/gfx.h4
-rw-r--r--engines/scumm/gfx_towns.cpp2
-rw-r--r--engines/scumm/scumm.cpp2
-rw-r--r--engines/sword25/fmv/movieplayer.cpp2
-rw-r--r--engines/sword25/fmv/theora_decoder.cpp2
-rw-r--r--engines/sword25/gfx/graphicengine.cpp6
-rw-r--r--engines/sword25/gfx/image/renderedimage.cpp9
-rw-r--r--engines/sword25/gfx/screenshot.cpp4
-rw-r--r--engines/teenagent/scene.cpp2
-rw-r--r--engines/teenagent/surface.cpp2
-rw-r--r--engines/tinsel/tinsel.cpp4
-rw-r--r--engines/toon/movie.cpp2
-rw-r--r--engines/toon/toon.cpp2
-rw-r--r--engines/tsage/graphics.cpp6
-rw-r--r--graphics/VectorRendererSpec.cpp38
-rw-r--r--graphics/font.cpp6
-rw-r--r--graphics/fonts/scummfont.cpp4
-rw-r--r--graphics/fonts/winfont.cpp8
-rw-r--r--graphics/iff.cpp2
-rw-r--r--graphics/imagedec.cpp2
-rw-r--r--graphics/jpeg.cpp4
-rw-r--r--graphics/pict.cpp2
-rw-r--r--graphics/png.cpp29
-rw-r--r--graphics/scaler/thumbnail_intern.cpp18
-rw-r--r--graphics/sjis.cpp2
-rw-r--r--graphics/surface.cpp56
-rw-r--r--graphics/surface.h16
-rw-r--r--graphics/thumbnail.cpp10
-rw-r--r--gui/ThemeEngine.cpp6
-rw-r--r--gui/widget.cpp9
-rw-r--r--video/codecs/cdtoons.cpp2
-rw-r--r--video/codecs/cinepak.cpp2
-rw-r--r--video/codecs/indeo3.cpp8
-rw-r--r--video/codecs/mjpeg.cpp2
-rw-r--r--video/codecs/msrle.cpp2
-rw-r--r--video/codecs/msvideo1.cpp3
-rw-r--r--video/codecs/qtrle.cpp2
-rw-r--r--video/codecs/rpza.cpp2
-rw-r--r--video/codecs/smc.cpp2
-rw-r--r--video/codecs/truemotion1.cpp2
-rw-r--r--video/coktel_decoder.cpp59
-rw-r--r--video/dxa_decoder.cpp2
-rw-r--r--video/flic_decoder.cpp4
-rw-r--r--video/qt_decoder.cpp4
-rw-r--r--video/smk_decoder.cpp2
94 files changed, 382 insertions, 356 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 2fb02ba36c..b85cac809e 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -356,9 +356,9 @@ void OpenGLGraphicsManager::copyRectToScreen(const byte *buf, int pitch, int x,
// Copy buffer data to game screen internal buffer
const byte *src = buf;
- byte *dst = (byte *)_screenData.pixels + y * _screenData.pitch + x * _screenData.bytesPerPixel;
+ byte *dst = (byte *)_screenData.pixels + y * _screenData.pitch + x * _screenData.format.bytesPerPixel;
for (int i = 0; i < h; i++) {
- memcpy(dst, src, w * _screenData.bytesPerPixel);
+ memcpy(dst, src, w * _screenData.format.bytesPerPixel);
src += pitch;
dst += _screenData.pitch;
}
@@ -467,7 +467,7 @@ void OpenGLGraphicsManager::clearOverlay() {
}
void OpenGLGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) {
- assert(_overlayData.bytesPerPixel == sizeof(buf[0]));
+ assert(_overlayData.format.bytesPerPixel == sizeof(buf[0]));
const byte *src = (byte *)_overlayData.pixels;
for (int i = 0; i < _overlayData.h; i++) {
// Copy overlay data to buffer
@@ -520,7 +520,7 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch
const byte *src = (const byte *)buf;
byte *dst = (byte *)_overlayData.pixels + y * _overlayData.pitch;
for (int i = 0; i < h; i++) {
- memcpy(dst + x * _overlayData.bytesPerPixel, src, w * _overlayData.bytesPerPixel);
+ memcpy(dst + x * _overlayData.format.bytesPerPixel, src, w * _overlayData.format.bytesPerPixel);
src += pitch * sizeof(buf[0]);
dst += _overlayData.pitch;
}
@@ -617,8 +617,8 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int
// Allocate space for cursor data
if (_cursorData.w != w || _cursorData.h != h ||
- _cursorData.bytesPerPixel != _cursorFormat.bytesPerPixel)
- _cursorData.create(w, h, _cursorFormat.bytesPerPixel);
+ _cursorData.format.bytesPerPixel != _cursorFormat.bytesPerPixel)
+ _cursorData.create(w, h, _cursorFormat);
// Save cursor data
memcpy(_cursorData.pixels, buf, h * _cursorData.pitch);
@@ -700,13 +700,13 @@ void OpenGLGraphicsManager::refreshGameScreen() {
int w = _screenDirtyRect.width();
int h = _screenDirtyRect.height();
- if (_screenData.bytesPerPixel == 1) {
+ if (_screenData.format.bytesPerPixel == 1) {
// Create a temporary RGB888 surface
byte *surface = new byte[w * h * 3];
// Convert the paletted buffer to RGB888
const byte *src = (byte *)_screenData.pixels + y * _screenData.pitch;
- src += x * _screenData.bytesPerPixel;
+ src += x * _screenData.format.bytesPerPixel;
byte *dst = surface;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
@@ -726,7 +726,7 @@ void OpenGLGraphicsManager::refreshGameScreen() {
} else {
// Update the texture
_gameTexture->updateBuffer((byte *)_screenData.pixels + y * _screenData.pitch +
- x * _screenData.bytesPerPixel, _screenData.pitch, x, y, w, h);
+ x * _screenData.format.bytesPerPixel, _screenData.pitch, x, y, w, h);
}
_screenNeedsRedraw = false;
@@ -742,13 +742,13 @@ void OpenGLGraphicsManager::refreshOverlay() {
int w = _overlayDirtyRect.width();
int h = _overlayDirtyRect.height();
- if (_overlayData.bytesPerPixel == 1) {
+ if (_overlayData.format.bytesPerPixel == 1) {
// Create a temporary RGB888 surface
byte *surface = new byte[w * h * 3];
// Convert the paletted buffer to RGB888
const byte *src = (byte *)_overlayData.pixels + y * _overlayData.pitch;
- src += x * _overlayData.bytesPerPixel;
+ src += x * _overlayData.format.bytesPerPixel;
byte *dst = surface;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
@@ -768,7 +768,7 @@ void OpenGLGraphicsManager::refreshOverlay() {
} else {
// Update the texture
_overlayTexture->updateBuffer((byte *)_overlayData.pixels + y * _overlayData.pitch +
- x * _overlayData.bytesPerPixel, _overlayData.pitch, x, y, w, h);
+ x * _overlayData.format.bytesPerPixel, _overlayData.pitch, x, y, w, h);
}
_overlayNeedsRedraw = false;
@@ -1176,9 +1176,9 @@ void OpenGLGraphicsManager::loadTextures() {
_oldVideoMode.screenHeight != _videoMode.screenHeight)
_screenData.create(_videoMode.screenWidth, _videoMode.screenHeight,
#ifdef USE_RGB_COLOR
- _screenFormat.bytesPerPixel
+ _screenFormat
#else
- 1
+ Graphics::PixelFormat::createFormatCLUT8()
#endif
);
@@ -1186,7 +1186,7 @@ void OpenGLGraphicsManager::loadTextures() {
if (_oldVideoMode.overlayWidth != _videoMode.overlayWidth ||
_oldVideoMode.overlayHeight != _videoMode.overlayHeight)
_overlayData.create(_videoMode.overlayWidth, _videoMode.overlayHeight,
- _overlayFormat.bytesPerPixel);
+ _overlayFormat);
_screenNeedsRedraw = true;
_overlayNeedsRedraw = true;
@@ -1388,7 +1388,7 @@ void OpenGLGraphicsManager::updateOSD() {
const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kOSDFont);
if (_osdSurface.w != _osdTexture->getWidth() || _osdSurface.h != _osdTexture->getHeight())
- _osdSurface.create(_osdTexture->getWidth(), _osdTexture->getHeight(), 2);
+ _osdSurface.create(_osdTexture->getWidth(), _osdTexture->getHeight(), _overlayFormat);
else
// Clear everything
memset(_osdSurface.pixels, 0, _osdSurface.h * _osdSurface.pitch);
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index 41f5c2acbb..b3e1138e77 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -1288,9 +1288,9 @@ Graphics::Surface *SdlGraphicsManager::lockScreen() {
_framebuffer.h = _screen->h;
_framebuffer.pitch = _screen->pitch;
#ifdef USE_RGB_COLOR
- _framebuffer.bytesPerPixel = _screenFormat.bytesPerPixel;
+ _framebuffer.format = _screenFormat;
#else
- _framebuffer.bytesPerPixel = 1;
+ _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
#endif
return &_framebuffer;
@@ -2055,7 +2055,11 @@ void SdlGraphicsManager::displayMessageOnOSD(const char *msg) {
dst.w = _osdSurface->w;
dst.h = _osdSurface->h;
dst.pitch = _osdSurface->pitch;
- dst.bytesPerPixel = _osdSurface->format->BytesPerPixel;
+ dst.format = Graphics::PixelFormat(_osdSurface->format->BytesPerPixel,
+ 8 - _osdSurface->format->Rloss, 8 - _osdSurface->format->Gloss,
+ 8 - _osdSurface->format->Bloss, 8 - _osdSurface->format->Aloss,
+ _osdSurface->format->Rshift, _osdSurface->format->Gshift,
+ _osdSurface->format->Bshift, _osdSurface->format->Ashift);
// The font we are going to use:
const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kOSDFont);
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index 86232030ff..fae428d29f 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -628,13 +628,13 @@ void OSystem_Android::grabOverlay(OverlayColor *buf, int pitch) {
GLTHREADCHECK;
const Graphics::Surface *surface = _overlay_texture->surface_const();
- assert(surface->bytesPerPixel == sizeof(buf[0]));
+ assert(surface->format.bytesPerPixel == sizeof(buf[0]));
const byte *src = (const byte *)surface->pixels;
uint h = surface->h;
do {
- memcpy(buf, src, surface->w * surface->bytesPerPixel);
+ memcpy(buf, src, surface->w * surface->format.bytesPerPixel);
src += surface->pitch;
// This 'pitch' is pixels not bytes
buf += pitch;
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index a6b28ca485..2d73783309 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -147,7 +147,7 @@ void GLESBaseTexture::setLinearFilter(bool value) {
void GLESBaseTexture::allocBuffer(GLuint w, GLuint h) {
_surface.w = w;
_surface.h = h;
- _surface.bytesPerPixel = _pixelFormat.bytesPerPixel;
+ _surface.format = _pixelFormat;
if (w == _texture_width && h == _texture_height)
return;
@@ -241,14 +241,14 @@ void GLESTexture::allocBuffer(GLuint w, GLuint h) {
delete[] _buf;
delete[] _pixels;
- _pixels = new byte[w * h * _surface.bytesPerPixel];
+ _pixels = new byte[w * h * _surface.format.bytesPerPixel];
assert(_pixels);
_surface.pixels = _pixels;
fillBuffer(0);
- _buf = new byte[w * h * _surface.bytesPerPixel];
+ _buf = new byte[w * h * _surface.format.bytesPerPixel];
assert(_buf);
}
@@ -257,10 +257,10 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
setDirtyRect(Common::Rect(x, y, x + w, y + h));
const byte *src = (const byte *)buf;
- byte *dst = _pixels + y * _surface.pitch + x * _surface.bytesPerPixel;
+ byte *dst = _pixels + y * _surface.pitch + x * _surface.format.bytesPerPixel;
do {
- memcpy(dst, src, w * _surface.bytesPerPixel);
+ memcpy(dst, src, w * _surface.format.bytesPerPixel);
dst += _surface.pitch;
src += pitch_buf;
} while (--h);
@@ -301,10 +301,10 @@ void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
_tex = _buf;
byte *src = _pixels + _dirty_rect.top * _surface.pitch +
- _dirty_rect.left * _surface.bytesPerPixel;
+ _dirty_rect.left * _surface.format.bytesPerPixel;
byte *dst = _buf;
- uint16 l = dwidth * _surface.bytesPerPixel;
+ uint16 l = dwidth * _surface.format.bytesPerPixel;
for (uint16 i = 0; i < dheight; ++i) {
memcpy(dst, src, l);
@@ -373,7 +373,7 @@ void GLESFakePaletteTexture::allocBuffer(GLuint w, GLuint h) {
GLESBaseTexture::allocBuffer(w, h);
- _surface.bytesPerPixel = 1;
+ _surface.format = Graphics::PixelFormat::createFormatCLUT8();
_surface.pitch = w;
if (_surface.w == oldw && _surface.h == oldh) {
diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp
index b297022775..78fa2182dc 100644
--- a/backends/platform/dc/display.cpp
+++ b/backends/platform/dc/display.cpp
@@ -720,7 +720,7 @@ Graphics::Surface *OSystem_Dreamcast::lockScreen()
_framebuffer.w = _screen_w;
_framebuffer.h = _screen_h;
_framebuffer.pitch = SCREEN_W*2;
- _framebuffer.bytesPerPixel = (_screenFormat == 0? 1 : 2);
+ _framebuffer.format = screenFormats[_screenFormat];
return &_framebuffer;
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 576b70dd2a..49818a0034 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -243,7 +243,7 @@ void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) {
}
bool OSystem_DS::grabRawScreen(Graphics::Surface *surf) {
- surf->create(DS::getGameWidth(), DS::getGameHeight(), 1);
+ surf->create(DS::getGameWidth(), DS::getGameHeight(), Graphics::PixelFormat::createFormatCLUT8());
// Ensure we copy using 16 bit quantities due to limitation of VRAM addressing
@@ -756,7 +756,7 @@ Graphics::Surface *OSystem_DS::createTempFrameBuffer() {
_framebuffer.w = DS::getGameWidth();
_framebuffer.h = DS::getGameHeight();
_framebuffer.pitch = DS::getGameWidth();
- _framebuffer.bytesPerPixel = 1;
+ _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
} else {
@@ -781,7 +781,7 @@ Graphics::Surface *OSystem_DS::createTempFrameBuffer() {
_framebuffer.w = width;
_framebuffer.h = height;
_framebuffer.pitch = width;
- _framebuffer.bytesPerPixel = 1;
+ _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
}
diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp
index c5e7ab8413..a10efeff40 100644
--- a/backends/platform/iphone/osys_video.cpp
+++ b/backends/platform/iphone/osys_video.cpp
@@ -334,7 +334,7 @@ Graphics::Surface *OSystem_IPHONE::lockScreen() {
_framebuffer.w = _screenWidth;
_framebuffer.h = _screenHeight;
_framebuffer.pitch = _screenWidth;
- _framebuffer.bytesPerPixel = 1;
+ _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
return &_framebuffer;
}
diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp
index 54eab0fd52..232037899b 100644
--- a/backends/platform/n64/osys_n64_base.cpp
+++ b/backends/platform/n64/osys_n64_base.cpp
@@ -610,7 +610,7 @@ Graphics::Surface *OSystem_N64::lockScreen() {
_framebuffer.w = _gameWidth;
_framebuffer.h = _gameHeight;
_framebuffer.pitch = _screenWidth;
- _framebuffer.bytesPerPixel = 1;
+ _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
return &_framebuffer;
}
diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp
index a460b919fd..e43ea0f376 100644
--- a/backends/platform/ps2/Gs2dScreen.cpp
+++ b/backends/platform/ps2/Gs2dScreen.cpp
@@ -398,7 +398,7 @@ Graphics::Surface *Gs2dScreen::lockScreen() {
_framebuffer.w = _width;
_framebuffer.h = _height;
_framebuffer.pitch = _width; // -not- _pitch; ! It's EE mem, not Tex
- _framebuffer.bytesPerPixel = 1;
+ _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
return &_framebuffer;
}
@@ -441,7 +441,7 @@ void Gs2dScreen::grabPalette(uint8 *pal, uint8 start, uint16 num) {
void Gs2dScreen::grabScreen(Graphics::Surface *surf) {
assert(surf);
WaitSema(g_DmacSema);
- surf->create(_width, _height, 1);
+ surf->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
memcpy(surf->pixels, _screenBuf, _width * _height);
SignalSema(g_DmacSema);
}
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index 77de74eb5b..e95a026d01 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -727,7 +727,7 @@ void OSystem_PS2::msgPrintf(int millis, const char *format, ...) {
int maxWidth = 0;
Graphics::Surface surf;
- surf.create(300, 200, 1);
+ surf.create(300, 200, Graphics::PixelFormat::createFormatCLUT8());
char *lnSta = resStr;
while (*lnSta && (posY < 180)) {
diff --git a/backends/platform/psp/default_display_client.cpp b/backends/platform/psp/default_display_client.cpp
index bb42406c3e..34b1a70711 100644
--- a/backends/platform/psp/default_display_client.cpp
+++ b/backends/platform/psp/default_display_client.cpp
@@ -199,7 +199,7 @@ Graphics::Surface *Screen::lockAndGetForEditing() {
_frameBuffer.w = _buffer.getSourceWidth();
_frameBuffer.h = _buffer.getSourceHeight();
_frameBuffer.pitch = _buffer.getBytesPerPixel() * _buffer.getWidth();
- _frameBuffer.bytesPerPixel = _buffer.getBytesPerPixel();
+ _frameBuffer.format = _pixelFormat;
// We'll set to dirty once we unlock the screen
return &_frameBuffer;
diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp
index cb9a8c72e9..c2be608999 100644
--- a/backends/platform/wii/osystem_gfx.cpp
+++ b/backends/platform/wii/osystem_gfx.cpp
@@ -537,10 +537,10 @@ Graphics::Surface *OSystem_Wii::lockScreen() {
_surface.h = _gameHeight;
#ifdef USE_RGB_COLOR
_surface.pitch = _gameWidth * _pfGame.bytesPerPixel;
- _surface.bytesPerPixel = _pfGame.bytesPerPixel;
+ _surface.format = _pfGame;
#else
_surface.pitch = _gameWidth;
- _surface.bytesPerPixel = 1;
+ _surface.format = Graphics::PixelFormat::createFormatCLUT8();
#endif
return &_surface;
diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp
index 050ab5c5a2..9ffda6e3a7 100644
--- a/backends/vkeybd/virtual-keyboard-gui.cpp
+++ b/backends/vkeybd/virtual-keyboard-gui.cpp
@@ -36,7 +36,7 @@
namespace Common {
static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16 x, int16 y, OverlayColor transparent) {
- if (surf_dst->bytesPerPixel != sizeof(OverlayColor) || surf_src->bytesPerPixel != sizeof(OverlayColor))
+ if (surf_dst->format.bytesPerPixel != sizeof(OverlayColor) || surf_src->format.bytesPerPixel != sizeof(OverlayColor))
return;
const OverlayColor *src = (const OverlayColor *)surf_src->pixels;
@@ -133,7 +133,7 @@ void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) {
_dispI = 0;
_dispForeColor = forecolor;
_dispBackColor = _dispForeColor + 0xFF;
- _dispSurface.create(r.width(), _dispFont->getFontHeight(), sizeof(OverlayColor));
+ _dispSurface.create(r.width(), _dispFont->getFontHeight(), _system->getOverlayFormat());
_dispSurface.fillRect(Rect(_dispSurface.w, _dispSurface.h), _dispBackColor);
_displayEnabled = true;
}
@@ -163,7 +163,7 @@ void VirtualKeyboardGUI::run() {
_system->showOverlay();
_system->clearOverlay();
}
- _overlayBackup.create(_screenW, _screenH, sizeof(OverlayColor));
+ _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat());
_system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w);
setupCursor();
@@ -265,7 +265,7 @@ void VirtualKeyboardGUI::screenChanged() {
_screenW = newScreenW;
_screenH = newScreenH;
- _overlayBackup.create(_screenW, _screenH, sizeof(OverlayColor));
+ _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat());
_system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w);
if (!_kbd->checkModeResolutions()) {
@@ -358,7 +358,7 @@ void VirtualKeyboardGUI::redraw() {
if (w <= 0 || h <= 0) return;
Graphics::Surface surf;
- surf.create(w, h, sizeof(OverlayColor));
+ surf.create(w, h, _system->getOverlayFormat());
OverlayColor *dst = (OverlayColor *)surf.pixels;
const OverlayColor *src = (OverlayColor *) _overlayBackup.getBasePtr(_dirtyRect.left, _dirtyRect.top);
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index 94346e2f90..56501b5294 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -566,33 +566,33 @@ Common::Error AGOSEngine::init() {
// allocate buffers
_backGroundBuf = new Graphics::Surface();
- _backGroundBuf->create(_screenWidth, _screenHeight, 1);
+ _backGroundBuf->create(_screenWidth, _screenHeight, Graphics::PixelFormat::createFormatCLUT8());
if (getGameType() == GType_FF || getGameType() == GType_PP) {
_backBuf = new Graphics::Surface();
- _backBuf->create(_screenWidth, _screenHeight, 1);
+ _backBuf->create(_screenWidth, _screenHeight, Graphics::PixelFormat::createFormatCLUT8());
_scaleBuf = new Graphics::Surface();
- _scaleBuf->create(_screenWidth, _screenHeight, 1);
+ _scaleBuf->create(_screenWidth, _screenHeight, Graphics::PixelFormat::createFormatCLUT8());
}
if (getGameType() == GType_SIMON2) {
_window4BackScn = new Graphics::Surface();
- _window4BackScn->create(_screenWidth, _screenHeight, 1);
+ _window4BackScn->create(_screenWidth, _screenHeight, Graphics::PixelFormat::createFormatCLUT8());
} else if (getGameType() == GType_SIMON1) {
_window4BackScn = new Graphics::Surface();
- _window4BackScn->create(_screenWidth, 134, 1);
+ _window4BackScn->create(_screenWidth, 134, Graphics::PixelFormat::createFormatCLUT8());
} else if (getGameType() == GType_WW || getGameType() == GType_ELVIRA2) {
_window4BackScn = new Graphics::Surface();
- _window4BackScn->create(224, 127, 1);
+ _window4BackScn->create(224, 127, Graphics::PixelFormat::createFormatCLUT8());
} else if (getGameType() == GType_ELVIRA1) {
_window4BackScn = new Graphics::Surface();
if (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_DEMO)) {
- _window4BackScn->create(224, 196, 1);
+ _window4BackScn->create(224, 196, Graphics::PixelFormat::createFormatCLUT8());
} else {
- _window4BackScn->create(224, 144, 1);
+ _window4BackScn->create(224, 144, Graphics::PixelFormat::createFormatCLUT8());
}
_window6BackScn = new Graphics::Surface();
- _window6BackScn->create(48, 80, 1);
+ _window6BackScn->create(48, 80, Graphics::PixelFormat::createFormatCLUT8());
}
setupGame();
diff --git a/engines/draci/surface.cpp b/engines/draci/surface.cpp
index 532d87a19f..37a76dbe0e 100644
--- a/engines/draci/surface.cpp
+++ b/engines/draci/surface.cpp
@@ -29,7 +29,7 @@
namespace Draci {
Surface::Surface(int width, int height) {
- this->create(width, height, 1);
+ this->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
this->markClean();
_transparentColor = kDefaultTransparent;
}
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index 8222c99ef3..de149c9787 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -720,7 +720,7 @@ bool VideoPlayer::copyFrame(int slot, Surface &dest,
if (!surface)
return false;
- Surface src(surface->w, surface->h, surface->bytesPerPixel, (byte *)surface->pixels);
+ Surface src(surface->w, surface->h, surface->format.bytesPerPixel, (byte *)surface->pixels);
dest.blit(src, left, top, left + width - 1, top + height - 1, x, y, transp);
return true;
diff --git a/engines/groovie/graphics.cpp b/engines/groovie/graphics.cpp
index 3eaadbe1c7..71ee231b80 100644
--- a/engines/groovie/graphics.cpp
+++ b/engines/groovie/graphics.cpp
@@ -36,8 +36,8 @@ namespace Groovie {
GraphicsMan::GraphicsMan(GroovieEngine *vm) :
_vm(vm), _changed(false), _fading(0) {
// Create the game surfaces
- _foreground.create(640, 320, _vm->_pixelFormat.bytesPerPixel);
- _background.create(640, 320, _vm->_pixelFormat.bytesPerPixel);
+ _foreground.create(640, 320, _vm->_pixelFormat);
+ _background.create(640, 320, _vm->_pixelFormat);
}
GraphicsMan::~GraphicsMan() {
diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp
index 8b40fa8a1f..be9c4f6921 100644
--- a/engines/groovie/roq.cpp
+++ b/engines/groovie/roq.cpp
@@ -179,7 +179,7 @@ void ROQPlayer::buildShowBuf() {
// Skip to the next pixel
out += _vm->_pixelFormat.bytesPerPixel;
if (!(x % _scaleX))
- in += _currBuf->bytesPerPixel;
+ in += _currBuf->format.bytesPerPixel;
}
#ifdef DITHER
_dither->nextLine();
@@ -332,8 +332,13 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) {
_prevBuf->free();
// Allocate new buffers
- _currBuf->create(width, height, 3);
- _prevBuf->create(width, height, 3);
+ // These buffers use YUV data, since we can not describe it with a
+ // PixelFormat struct we just add some dummy PixelFormat with the
+ // correct bytes per pixel value. Since the surfaces are only used
+ // internally and no code assuming RGB data is present is used on
+ // them it should be just fine.
+ _currBuf->create(width, height, Graphics::PixelFormat(3, 0, 0, 0, 0, 0, 0, 0, 0));
+ _prevBuf->create(width, height, Graphics::PixelFormat(3, 0, 0, 0, 0, 0, 0, 0, 0));
// Clear the buffers with black YUV values
byte *ptr1 = (byte *)_currBuf->getBasePtr(0, 0);
@@ -701,7 +706,7 @@ void ROQPlayer::copy(byte size, int destx, int desty, int offx, int offy) {
for (int i = 0; i < size; i++) {
// Copy the current line
- memcpy(dst, src, size * _currBuf->bytesPerPixel);
+ memcpy(dst, src, size * _currBuf->format.bytesPerPixel);
// Move to the beginning of the next line
dst += _currBuf->pitch;
diff --git a/engines/hugo/dialogs.cpp b/engines/hugo/dialogs.cpp
index 50fcfa27db..f0dc84eae8 100644
--- a/engines/hugo/dialogs.cpp
+++ b/engines/hugo/dialogs.cpp
@@ -133,7 +133,7 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) {
Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize);
arrayBmp[i * 2] = Graphics::ImageDecoder::loadFile(stream, g_system->getOverlayFormat());
arrayBmp[i * 2 + 1] = new Graphics::Surface();
- arrayBmp[i * 2 + 1]->create(arrayBmp[i * 2]->w * 2, arrayBmp[i * 2]->h * 2, arrayBmp[i * 2]->bytesPerPixel);
+ arrayBmp[i * 2 + 1]->create(arrayBmp[i * 2]->w * 2, arrayBmp[i * 2]->h * 2, g_system->getOverlayFormat());
byte *src = (byte *)arrayBmp[i * 2]->pixels;
byte *dst = (byte *)arrayBmp[i * 2 + 1]->pixels;
@@ -141,12 +141,12 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) {
src = (byte *)arrayBmp[i * 2]->getBasePtr(0, j);
dst = (byte *)arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2);
for (int k = arrayBmp[i * 2]->w; k > 0; k--) {
- for (int m = arrayBmp[i * 2]->bytesPerPixel; m > 0; m--) {
+ for (int m = arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) {
*dst++ = *src++;
}
- src -= arrayBmp[i * 2]->bytesPerPixel;
+ src -= arrayBmp[i * 2]->format.bytesPerPixel;
- for (int m = arrayBmp[i * 2]->bytesPerPixel; m > 0; m--) {
+ for (int m = arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) {
*dst++ = *src++;
}
}
diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp
index 65dff78bb4..c31d76abd0 100644
--- a/engines/hugo/intro.cpp
+++ b/engines/hugo/intro.cpp
@@ -94,7 +94,7 @@ void intro_v1d::introInit() {
surf.h = 200;
surf.pixels = _vm->_screen->getFrontBuffer();
surf.pitch = 320;
- surf.bytesPerPixel = 1;
+ surf.format = Graphics::PixelFormat::createFormatCLUT8();
_vm->_screen->displayList(kDisplayInit);
}
@@ -248,7 +248,7 @@ void intro_v2d::introInit() {
surf.h = 200;
surf.pixels = _vm->_screen->getFrontBuffer();
surf.pitch = 320;
- surf.bytesPerPixel = 1;
+ surf.format = Graphics::PixelFormat::createFormatCLUT8();
char buffer[128];
@@ -294,7 +294,7 @@ void intro_v3d::introInit() {
surf.h = 200;
surf.pixels = _vm->_screen->getFrontBuffer();
surf.pitch = 320;
- surf.bytesPerPixel = 1;
+ surf.format = Graphics::PixelFormat::createFormatCLUT8();
char buffer[128];
if (_vm->_boot.registered)
diff --git a/engines/lastexpress/data/animation.cpp b/engines/lastexpress/data/animation.cpp
index 6e80d3d9d6..2bf9bd4999 100644
--- a/engines/lastexpress/data/animation.cpp
+++ b/engines/lastexpress/data/animation.cpp
@@ -269,7 +269,7 @@ void Animation::play() {
if (_changed) {
// Create a temporary surface to merge the overlay with the background
Graphics::Surface *s = new Graphics::Surface;
- s->create(640, 480, 2);
+ s->create(640, 480, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
draw(s);
diff --git a/engines/lastexpress/data/sequence.cpp b/engines/lastexpress/data/sequence.cpp
index 0e6df13995..b986a33d5c 100644
--- a/engines/lastexpress/data/sequence.cpp
+++ b/engines/lastexpress/data/sequence.cpp
@@ -83,7 +83,7 @@ void FrameInfo::read(Common::SeekableReadStream *in, bool isSequence) {
AnimFrame::AnimFrame(Common::SeekableReadStream *in, const FrameInfo &f) : _palette(NULL) {
_palSize = 1;
// TODO: use just the needed rectangle
- _image.create(640, 480, 1);
+ _image.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
//debugC(6, kLastExpressDebugGraphics, " Offsets: data=%d, unknown=%d, palette=%d", f.dataOffset, f.unknown, f.paletteOffset);
//debugC(6, kLastExpressDebugGraphics, " Position: (%d, %d) - (%d, %d)", f.xPos1, f.yPos1, f.xPos2, f.yPos2);
diff --git a/engines/lastexpress/graphics.cpp b/engines/lastexpress/graphics.cpp
index 5c72fa76d8..c45baba808 100644
--- a/engines/lastexpress/graphics.cpp
+++ b/engines/lastexpress/graphics.cpp
@@ -34,13 +34,14 @@ namespace LastExpress {
#define COLOR_KEY 0xFFFF
GraphicsManager::GraphicsManager() : _changed(false) {
- _screen.create(640, 480, 2);
+ const Graphics::PixelFormat format(2, 5, 5, 5, 0, 10, 5, 0, 0);
+ _screen.create(640, 480, format);
// Create the game surfaces
- _backgroundA.create(640, 480, 2);
- _backgroundC.create(640, 480, 2);
- _overlay.create(640, 480, 2);
- _inventory.create(640, 480, 2);
+ _backgroundA.create(640, 480, format);
+ _backgroundC.create(640, 480, format);
+ _overlay.create(640, 480, format);
+ _inventory.create(640, 480, format);
clear(kBackgroundAll);
}
diff --git a/engines/m4/dialogs.cpp b/engines/m4/dialogs.cpp
index 0583d5f749..bc6228658d 100644
--- a/engines/m4/dialogs.cpp
+++ b/engines/m4/dialogs.cpp
@@ -445,7 +445,7 @@ void Dialog::draw() {
int dialogY = (_vm->_screen->height() - dlgHeight) / 2;
// Create the surface for the dialog
- create(dlgWidth, dlgHeight, 1);
+ create(dlgWidth, dlgHeight, Graphics::PixelFormat::createFormatCLUT8());
_coords.left = dialogX;
_coords.top = dialogY;
_coords.right = dialogX + dlgWidth + 1;
diff --git a/engines/m4/graphics.cpp b/engines/m4/graphics.cpp
index a685b36a18..689a6ab8b4 100644
--- a/engines/m4/graphics.cpp
+++ b/engines/m4/graphics.cpp
@@ -97,7 +97,7 @@ void M4Surface::loadCodesM4(Common::SeekableReadStream *source) {
uint16 widthVal = source->readUint16LE();
uint16 heightVal = source->readUint16LE();
- create(widthVal, heightVal, 1);
+ create(widthVal, heightVal, Graphics::PixelFormat::createFormatCLUT8());
source->read(pixels, widthVal * heightVal);
}
@@ -111,7 +111,7 @@ void M4Surface::loadCodesMads(Common::SeekableReadStream *source) {
uint16 heightVal = 156;
byte *walkMap = new byte[source->size()];
- create(widthVal, heightVal, 1);
+ create(widthVal, heightVal, Graphics::PixelFormat::createFormatCLUT8());
source->read(walkMap, source->size());
byte *ptr = (byte *)getBasePtr(0, 0);
@@ -761,7 +761,7 @@ void M4Surface::rexLoadBackground(Common::SeekableReadStream *source, RGBList **
sourceUnc = packData.getItemStream(1);
assert((int)sourceUnc->size() >= sceneSize);
- create(sceneWidth, sceneHeight, 1);
+ create(sceneWidth, sceneHeight, Graphics::PixelFormat::createFormatCLUT8());
byte *pData = (byte *)pixels;
sourceUnc->read(pData, sceneSize);
@@ -814,7 +814,7 @@ void M4Surface::m4LoadBackground(Common::SeekableReadStream *source) {
assert(width() == (int)widthVal);
//debugCN(kDebugGraphics, "width(): %d, widthVal: %d, height(): %d, heightVal: %d\n", width(), widthVal, height(), heightVal);
- tileBuffer->create(tileWidth, tileHeight, 1);
+ tileBuffer->create(tileWidth, tileHeight, Graphics::PixelFormat::createFormatCLUT8());
for (curTileY = 0; curTileY < tilesY; curTileY++) {
clipY = MIN(heightVal, (1 + curTileY) * tileHeight) - (curTileY * tileHeight);
@@ -855,7 +855,7 @@ void M4Surface::madsLoadInterface(const Common::String &filename) {
// Chunk 1, data
intStream = intFile.getItemStream(1);
- create(320, 44, 1);
+ create(320, 44, Graphics::PixelFormat::createFormatCLUT8());
intStream->read(pixels, 320 * 44);
delete intStream;
diff --git a/engines/m4/graphics.h b/engines/m4/graphics.h
index dbf6fac8c8..96e81f746e 100644
--- a/engines/m4/graphics.h
+++ b/engines/m4/graphics.h
@@ -105,19 +105,19 @@ private:
void m4LoadBackground(Common::SeekableReadStream *source);
public:
M4Surface(bool isScreen = false) {
- create(g_system->getWidth(), isScreen ? g_system->getHeight() : MADS_SURFACE_HEIGHT, 1);
+ create(g_system->getWidth(), isScreen ? g_system->getHeight() : MADS_SURFACE_HEIGHT, Graphics::PixelFormat::createFormatCLUT8());
_isScreen = isScreen;
_rgbList = NULL;
_ownsData = true;
}
M4Surface(int width_, int height_) {
- create(width_, height_, 1);
+ create(width_, height_, Graphics::PixelFormat::createFormatCLUT8());
_isScreen = false;
_rgbList = NULL;
_ownsData = true;
}
M4Surface(int width_, int height_, byte *srcPixels, int pitch_) {
- bytesPerPixel = 1;
+ format = Graphics::PixelFormat::createFormatCLUT8();
w = width_;
h = height_;
pitch = pitch_;
@@ -157,7 +157,7 @@ public:
inline int width() const { return w; }
inline int height() const { return h; }
inline int getPitch() const { return pitch; }
- void setSize(int sizeX, int sizeY) { create(sizeX, sizeY, 1); }
+ void setSize(int sizeX, int sizeY) { create(sizeX, sizeY, Graphics::PixelFormat::createFormatCLUT8()); }
inline byte *getBasePtr() {
return (byte *)pixels;
}
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp
index e37bd87a7e..5ab24c1984 100644
--- a/engines/made/pmvplayer.cpp
+++ b/engines/made/pmvplayer.cpp
@@ -169,7 +169,7 @@ bool PmvPlayer::play(const char *filename) {
if (!_surface) {
_surface = new Graphics::Surface();
- _surface->create(width, height, 1);
+ _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
}
decompressMovieImage(imageData, *_surface, cmdOffs, pixelOffs, maskOffs, lineSize);
diff --git a/engines/made/resource.cpp b/engines/made/resource.cpp
index 35a659aabb..403520bec3 100644
--- a/engines/made/resource.cpp
+++ b/engines/made/resource.cpp
@@ -96,7 +96,7 @@ void PictureResource::loadRaw(byte *source, int size) {
}
_picture = new Graphics::Surface();
- _picture->create(width, height, 1);
+ _picture->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
decompressImage(source, *_picture, cmdOffs, pixelOffs, maskOffs, lineSize, cmdFlags, pixelFlags, maskFlags);
@@ -172,7 +172,7 @@ void PictureResource::loadChunked(byte *source, int size) {
}
_picture = new Graphics::Surface();
- _picture->create(width, height, 1);
+ _picture->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
decompressImage(source, *_picture, cmdOffs, pixelOffs, maskOffs, lineSize, cmdFlags, pixelFlags, maskFlags);
@@ -228,7 +228,7 @@ void AnimationResource::load(byte *source, int size) {
uint16 lineSize = sourceS->readUint16LE();
Graphics::Surface *frame = new Graphics::Surface();
- frame->create(frameWidth, frameHeight, 1);
+ frame->create(frameWidth, frameHeight, Graphics::PixelFormat::createFormatCLUT8());
decompressImage(source + frameOffs, *frame, cmdOffs, pixelOffs, maskOffs, lineSize, 0, 0, 0, _flags & 1);
diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp
index a863906883..4a73ba8e38 100644
--- a/engines/made/screen.cpp
+++ b/engines/made/screen.cpp
@@ -38,10 +38,10 @@ Screen::Screen(MadeEngine *vm) : _vm(vm) {
_newPalette = new byte[768];
_backgroundScreen = new Graphics::Surface();
- _backgroundScreen->create(320, 200, 1);
+ _backgroundScreen->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
_workScreen = new Graphics::Surface();
- _workScreen->create(320, 200, 1);
+ _workScreen->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
_backgroundScreenDrawCtx.clipRect = Common::Rect(320, 200);
_workScreenDrawCtx.clipRect = Common::Rect(320, 200);
@@ -53,7 +53,7 @@ Screen::Screen(MadeEngine *vm) : _vm(vm) {
// Screen mask is only needed in v2 games
if (_vm->getGameID() != GID_RTZ) {
_screenMask = new Graphics::Surface();
- _screenMask->create(320, 200, 1);
+ _screenMask->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
_maskDrawCtx.clipRect = Common::Rect(320, 200);
_maskDrawCtx.destSurface = _screenMask;
}
diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp
index 05284f8b2b..02548d58fc 100644
--- a/engines/mohawk/bitmap.cpp
+++ b/engines/mohawk/bitmap.cpp
@@ -136,8 +136,12 @@ Common::Array<MohawkSurface *> MohawkBitmap::decodeImages(Common::SeekableReadSt
Graphics::Surface *MohawkBitmap::createSurface(uint16 width, uint16 height) {
Graphics::Surface *surface = new Graphics::Surface();
- byte bytesPerPixel = (getBitsPerPixel() <= 8) ? 1 : g_system->getScreenFormat().bytesPerPixel;
- surface->create(width, height, bytesPerPixel);
+ Graphics::PixelFormat format;
+ if (getBitsPerPixel() <= 8)
+ format = Graphics::PixelFormat::createFormatCLUT8();
+ else
+ format = g_system->getScreenFormat();
+ surface->create(width, height, format);
return surface;
}
@@ -570,7 +574,7 @@ void MohawkBitmap::drawRaw(Graphics::Surface *surface) {
byte b = _data->readByte();
byte g = _data->readByte();
byte r = _data->readByte();
- if (surface->bytesPerPixel == 2)
+ if (surface->format.bytesPerPixel == 2)
*((uint16 *)surface->getBasePtr(x, y)) = pixelFormat.RGBToColor(r, g, b);
else
*((uint32 *)surface->getBasePtr(x, y)) = pixelFormat.RGBToColor(r, g, b);
@@ -857,7 +861,7 @@ MohawkSurface *DOSBitmap::decodeImage(Common::SeekableReadStream *stream) {
}
void DOSBitmap::expandMonochromePlane(Graphics::Surface *surface, Common::SeekableReadStream *rawStream) {
- assert(surface->bytesPerPixel == 1);
+ assert(surface->format.bytesPerPixel == 1);
byte *dst = (byte *)surface->pixels;
@@ -883,7 +887,7 @@ void DOSBitmap::expandMonochromePlane(Graphics::Surface *surface, Common::Seekab
*(dst + j * 4 + dstPixel) = (*(dst + j * 4 + dstPixel) >> 1) | (((temp >> srcBit) & 1) << 3)
void DOSBitmap::expandEGAPlanes(Graphics::Surface *surface, Common::SeekableReadStream *rawStream) {
- assert(surface->bytesPerPixel == 1);
+ assert(surface->format.bytesPerPixel == 1);
// Note that the image is in EGA planar form and not just standard 4bpp
// This seems to contradict the PoP specs which seem to do
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index b4969f990a..66669e35c9 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -148,7 +148,7 @@ void MystCursorManager::setCursor(uint16 id) {
delete clrcStream;
// Myst ME stores some cursors as 24bpp images instead of 8bpp
- if (surface->bytesPerPixel == 1) {
+ if (surface->format.bytesPerPixel == 1) {
CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, 0);
CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256);
} else {
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index fe054989ea..a1bcb55f7b 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -73,14 +73,14 @@ MohawkSurface::~MohawkSurface() {
void MohawkSurface::convertToTrueColor() {
assert(_surface);
- if (_surface->bytesPerPixel > 1)
+ if (_surface->format.bytesPerPixel > 1)
return;
assert(_palette);
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
Graphics::Surface *surface = new Graphics::Surface();
- surface->create(_surface->w, _surface->h, pixelFormat.bytesPerPixel);
+ surface->create(_surface->w, _surface->h, pixelFormat);
for (uint16 i = 0; i < _surface->h; i++) {
for (uint16 j = 0; j < _surface->w; j++) {
@@ -295,7 +295,7 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) {
// Initialize our buffer
_backBuffer = new Graphics::Surface();
- _backBuffer->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel);
+ _backBuffer->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat);
}
MystGraphics::~MystGraphics() {
@@ -489,7 +489,7 @@ void MystGraphics::copyImageSectionToBackBuffer(uint16 image, Common::Rect src,
debug(3, "\theight: %d", height);
for (uint16 i = 0; i < height; i++)
- memcpy(_backBuffer->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel);
+ memcpy(_backBuffer->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->format.bytesPerPixel);
}
void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) {
@@ -649,7 +649,7 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm
// The actual game graphics only take up the first 392 rows. The inventory
// occupies the rest of the screen and we don't use the buffer to hold that.
_mainScreen = new Graphics::Surface();
- _mainScreen->create(608, 392, _pixelFormat.bytesPerPixel);
+ _mainScreen->create(608, 392, _pixelFormat);
_updatesEnabled = true;
_scheduledTransition = -1; // no transition
@@ -680,7 +680,7 @@ void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uin
surface->w = 608 - left;
for (uint16 i = 0; i < surface->h; i++)
- memcpy(_mainScreen->getBasePtr(left, i + top), surface->getBasePtr(0, i), surface->w * surface->bytesPerPixel);
+ memcpy(_mainScreen->getBasePtr(left, i + top), surface->getBasePtr(0, i), surface->w * surface->format.bytesPerPixel);
_dirtyScreen = true;
}
@@ -975,7 +975,7 @@ void RivenGraphics::drawImageRect(uint16 id, Common::Rect srcRect, Common::Rect
assert(srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height());
for (uint16 i = 0; i < srcRect.height(); i++)
- memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(srcRect.left, i + srcRect.top), srcRect.width() * surface->bytesPerPixel);
+ memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(srcRect.left, i + srcRect.top), srcRect.width() * surface->format.bytesPerPixel);
_dirtyScreen = true;
}
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index 36b94558a7..8f57d61cc4 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -226,7 +226,7 @@ bool VideoManager::updateMovies() {
// Convert from 8bpp to the current screen format if necessary
Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat();
- if (frame->bytesPerPixel == 1) {
+ if (frame->format.bytesPerPixel == 1) {
if (pixelFormat.bytesPerPixel == 1) {
if (_videoStreams[i]->hasDirtyPalette())
_videoStreams[i]->setSystemPalette();
@@ -235,7 +235,7 @@ bool VideoManager::updateMovies() {
const byte *palette = _videoStreams[i]->getPalette();
assert(palette);
- convertedFrame->create(frame->w, frame->h, pixelFormat.bytesPerPixel);
+ convertedFrame->create(frame->w, frame->h, pixelFormat);
for (uint16 j = 0; j < frame->h; j++) {
for (uint16 k = 0; k < frame->w; k++) {
diff --git a/engines/parallaction/balloons.cpp b/engines/parallaction/balloons.cpp
index 527f2d2812..2cf6eebf2a 100644
--- a/engines/parallaction/balloons.cpp
+++ b/engines/parallaction/balloons.cpp
@@ -304,7 +304,7 @@ int BalloonManager_ns::createBalloon(int16 w, int16 h, int16 winding, uint16 bor
int16 real_h = (winding == -1) ? h : h + 9;
balloon->surface = new Graphics::Surface;
- balloon->surface->create(w, real_h, 1);
+ balloon->surface->create(w, real_h, Graphics::PixelFormat::createFormatCLUT8());
balloon->surface->fillRect(Common::Rect(w, real_h), BALLOON_TRANSPARENT_COLOR_NS);
Common::Rect r(w, h);
@@ -578,7 +578,7 @@ Graphics::Surface *BalloonManager_br::expandBalloon(Frames *data, int frameNum)
rect.translate(-rect.left, -rect.top);
Graphics::Surface *surf = new Graphics::Surface;
- surf->create(rect.width(), rect.height(), 1);
+ surf->create(rect.width(), rect.height(), Graphics::PixelFormat::createFormatCLUT8());
_vm->_gfx->unpackBlt(rect, data->getData(frameNum), data->getRawSize(frameNum), surf, LAYER_FOREGROUND, 100, BALLOON_TRANSPARENT_COLOR_BR);
@@ -670,7 +670,7 @@ int BalloonManager_br::createBalloon(int16 w, int16 h, uint16 borderThickness) {
Balloon *balloon = &_intBalloons[id];
balloon->surface = new Graphics::Surface;
- balloon->surface->create(w, h, 1);
+ balloon->surface->create(w, h, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect rect(w, h);
balloon->surface->fillRect(rect, 1);
diff --git a/engines/parallaction/disk.cpp b/engines/parallaction/disk.cpp
index a577b16d08..d996b72e90 100644
--- a/engines/parallaction/disk.cpp
+++ b/engines/parallaction/disk.cpp
@@ -39,7 +39,7 @@ void ILBMLoader::setupBuffer(uint32 w, uint32 h) {
_surf = new Graphics::Surface;
assert(_surf);
}
- _surf->create(w, h, 1);
+ _surf->create(w, h, Graphics::PixelFormat::createFormatCLUT8());
_mode = Graphics::ILBMDecoder::ILBM_UNPACK_PLANES;
_intBuffer = (byte*)_surf->pixels;
break;
diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp
index e0342f74f7..cea4091ee9 100644
--- a/engines/parallaction/disk_br.cpp
+++ b/engines/parallaction/disk_br.cpp
@@ -228,7 +228,7 @@ void DosDisk_br::loadBitmap(Common::SeekableReadStream &stream, Graphics::Surfac
stream.skip(768);
}
- surf.create(width, height, 1);
+ surf.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
stream.read(surf.pixels, width * height);
}
diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp
index 7c14a31535..e695fa8798 100644
--- a/engines/parallaction/disk_ns.cpp
+++ b/engines/parallaction/disk_ns.cpp
@@ -474,7 +474,7 @@ void DosDisk_ns::loadBackground(BackgroundInfo& info, const char *filename) {
}
// read bitmap, mask and path data and extract them into the 3 buffers
- info.bg.create(info.width, info.height, 1);
+ info.bg.create(info.width, info.height, Graphics::PixelFormat::createFormatCLUT8());
createMaskAndPathBuffers(info);
unpackBackground(stream, (byte*)info.bg.pixels, info._mask->data, info._path->data);
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index c9504f1898..d33e733677 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -523,7 +523,7 @@ void Gfx::invertBackground(const Common::Rect& r) {
void setupLabelSurface(Graphics::Surface &surf, uint w, uint h) {
- surf.create(w, h, 1);
+ surf.create(w, h, Graphics::PixelFormat::createFormatCLUT8());
surf.fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
}
@@ -859,7 +859,7 @@ void Gfx::setBackground(uint type, BackgroundInfo *info) {
int height = CLIP(info->height, (int)_vm->_screenHeight, info->height);
if (width != _backBuffer.w || height != _backBuffer.h) {
- _backBuffer.create(width, height, 1);
+ _backBuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
}
}
diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp
index cfc7b12453..41e3082464 100644
--- a/engines/parallaction/gui_br.cpp
+++ b/engines/parallaction/gui_br.cpp
@@ -484,7 +484,7 @@ public:
_y = 90;
Graphics::Surface *surf = new Graphics::Surface;
- surf->create(w, 110, 1);
+ surf->create(w, 110, Graphics::PixelFormat::createFormatCLUT8());
surf->fillRect(Common::Rect(0, 0, w, 110), 12);
surf->fillRect(Common::Rect(10, 10, w-10, 100), 15);
diff --git a/engines/parallaction/gui_ns.cpp b/engines/parallaction/gui_ns.cpp
index eb94b076f1..6b863cc808 100644
--- a/engines/parallaction/gui_ns.cpp
+++ b/engines/parallaction/gui_ns.cpp
@@ -475,7 +475,7 @@ class SelectCharacterInputState_NS : public MenuInputState {
public:
SelectCharacterInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("selectcharacter", helper), _vm(vm) {
_keys = (_vm->getPlatform() == Common::kPlatformAmiga && (_vm->getFeatures() & GF_LANG_MULT)) ? _amigaKeys : _pcKeys;
- _block.create(BLOCK_WIDTH, BLOCK_HEIGHT, 1);
+ _block.create(BLOCK_WIDTH, BLOCK_HEIGHT, Graphics::PixelFormat::createFormatCLUT8());
_labels[0] = 0;
_labels[1] = 0;
@@ -626,7 +626,7 @@ public:
_vm->_soundManI->stopMusic();
_vm->showSlide("password");
- _emptySlots.create(BLOCK_WIDTH * 8, BLOCK_HEIGHT, 1);
+ _emptySlots.create(BLOCK_WIDTH * 8, BLOCK_HEIGHT, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect rect(SLOT_X, SLOT_Y, SLOT_X + BLOCK_WIDTH * 8, SLOT_Y + BLOCK_HEIGHT);
_vm->_gfx->grabBackground(rect, _emptySlots);
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index 95ea547b87..3a47b14deb 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -487,7 +487,7 @@ void Input::initCursors() {
_donnaCursor = _vm->_disk->loadPointer("pointer3");
Graphics::Surface *surf = new Graphics::Surface;
- surf->create(_mouseComboProps_BR._width, _mouseComboProps_BR._height, 1);
+ surf->create(_mouseComboProps_BR._width, _mouseComboProps_BR._height, Graphics::PixelFormat::createFormatCLUT8());
_comboArrow = new SurfaceToFrames(surf);
// TODO: choose the pointer depending on the active character
@@ -496,12 +496,12 @@ void Input::initCursors() {
} else {
// TODO: Where are the Amiga cursors?
Graphics::Surface *surf1 = new Graphics::Surface;
- surf1->create(_mouseComboProps_BR._width, _mouseComboProps_BR._height, 1);
+ surf1->create(_mouseComboProps_BR._width, _mouseComboProps_BR._height, Graphics::PixelFormat::createFormatCLUT8());
_comboArrow = new SurfaceToFrames(surf1);
// TODO: scale mouse cursor (see staticres.cpp)
Graphics::Surface *surf2 = new Graphics::Surface;
- surf2->create(32, 16, 1);
+ surf2->create(32, 16, Graphics::PixelFormat::createFormatCLUT8());
memcpy(surf2->pixels, _resMouseArrow_BR_Amiga, 32*16);
_mouseArrow = new SurfaceToFrames(surf2);
}
diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp
index 76c4e2ce36..2412cc6445 100644
--- a/engines/parallaction/inventory.cpp
+++ b/engines/parallaction/inventory.cpp
@@ -141,7 +141,7 @@ void Parallaction::closeInventory() {
InventoryRenderer::InventoryRenderer(Parallaction *vm, InventoryProperties *props, Inventory *inv) : _vm(vm), _props(props), _inv(inv) {
- _surf.create(_props->_width, _props->_height, 1);
+ _surf.create(_props->_width, _props->_height, Graphics::PixelFormat::createFormatCLUT8());
}
InventoryRenderer::~InventoryRenderer() {
diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp
index 0a438e45d3..4930718b67 100644
--- a/engines/saga/gfx.cpp
+++ b/engines/saga/gfx.cpp
@@ -47,7 +47,7 @@ Gfx::Gfx(SagaEngine *vm, OSystem *system, int width, int height) : _vm(vm), _sys
debug(5, "Init screen %dx%d", width, height);
// Convert surface data to R surface data
- _backBuffer.create(width, height, 1);
+ _backBuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
// Start with the cursor shown. It will be hidden before the intro, if
// there is an intro. (With boot params, there may not be.)
diff --git a/engines/saga/render.cpp b/engines/saga/render.cpp
index dc9334b037..837a9e5879 100644
--- a/engines/saga/render.cpp
+++ b/engines/saga/render.cpp
@@ -56,7 +56,7 @@ Render::Render(SagaEngine *vm, OSystem *system) {
_vm->getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this);
#endif
- _backGroundSurface.create(_vm->getDisplayInfo().width, _vm->getDisplayInfo().height, 1);
+ _backGroundSurface.create(_vm->getDisplayInfo().width, _vm->getDisplayInfo().height, Graphics::PixelFormat::createFormatCLUT8());
_flags = 0;
diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp
index 9cb292c4e0..debc75dffd 100644
--- a/engines/sci/video/robot_decoder.cpp
+++ b/engines/sci/video/robot_decoder.cpp
@@ -125,7 +125,7 @@ bool RobotDecoder::loadStream(Common::SeekableReadStream *stream) {
readPaletteChunk(_header.paletteDataSize);
readFrameSizesChunk();
calculateVideoDimensions();
- _surface->create(_width, _height, 1);
+ _surface->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
return true;
}
diff --git a/engines/sci/video/seq_decoder.cpp b/engines/sci/video/seq_decoder.cpp
index 17d1f9afd0..7168496893 100644
--- a/engines/sci/video/seq_decoder.cpp
+++ b/engines/sci/video/seq_decoder.cpp
@@ -59,7 +59,7 @@ bool SeqDecoder::loadStream(Common::SeekableReadStream *stream) {
_fileStream = stream;
_surface = new Graphics::Surface();
- _surface->create(SEQ_SCREEN_WIDTH, SEQ_SCREEN_HEIGHT, 1);
+ _surface->create(SEQ_SCREEN_WIDTH, SEQ_SCREEN_HEIGHT, Graphics::PixelFormat::createFormatCLUT8());
_frameCount = _fileStream->readUint16LE();
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index 861e448221..0246a255f9 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -777,7 +777,7 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) {
(ignoreCharsetMask || !vs->hasTwoBuffers)) {
dst = vs->getPixels(_left, drawTop);
if (charPtr)
- drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->bytesPerPixel);
+ drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->format.bytesPerPixel);
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
else if (_vm->_cjkFont)
_vm->_cjkFont->drawChar(vs, chr, _left, drawTop, _color, _shadowColor);
@@ -785,7 +785,7 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) {
} else {
dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier);
if (charPtr)
- drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.bytesPerPixel, (_vm->_textSurfaceMultiplier == 2 && !is2byte));
+ drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.format.bytesPerPixel, (_vm->_textSurfaceMultiplier == 2 && !is2byte));
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
else if (_vm->_cjkFont)
_vm->_cjkFont->drawChar(_vm->_textSurface, chr, _left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier, _color, _shadowColor);
@@ -834,7 +834,7 @@ void CharsetRendererV3::drawChar(int chr, Graphics::Surface &s, int x, int y) {
height = 8;
}
dst = (byte *)s.pixels + y * s.pitch + x;
- drawBits1(s, dst, charPtr, y, width, height, s.bytesPerPixel);
+ drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel);
}
void CharsetRenderer::translateColor() {
@@ -1096,7 +1096,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
} else
#endif
if (is2byte) {
- drawBits1(dstSurface, dstPtr, charPtr, drawTop, origWidth, origHeight, dstSurface.bytesPerPixel);
+ drawBits1(dstSurface, dstPtr, charPtr, drawTop, origWidth, origHeight, dstSurface.format.bytesPerPixel);
} else {
drawBitsN(dstSurface, dstPtr, charPtr, *_fontPtr, drawTop, origWidth, origHeight, _vm->_textSurfaceMultiplier == 2);
}
@@ -1173,7 +1173,7 @@ void CharsetRendererClassic::drawChar(int chr, Graphics::Surface &s, int x, int
dst = (byte *)s.pixels + y * s.pitch + x;
if (is2byte) {
- drawBits1(s, dst, charPtr, y, width, height, s.bytesPerPixel);
+ drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel);
} else {
drawBitsN(s, dst, charPtr, *_fontPtr, y, width, height);
}
@@ -1519,10 +1519,10 @@ void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) {
if (ignoreCharsetMask || !vs->hasTwoBuffers) {
dst = vs->getPixels(_left, drawTop);
- drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->bytesPerPixel);
+ drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->format.bytesPerPixel);
} else {
dst = (byte *)_vm->_textSurface.pixels + _top * _vm->_textSurface.pitch + _left;
- drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.bytesPerPixel);
+ drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.format.bytesPerPixel);
}
if (_str.left > _left)
@@ -1552,7 +1552,7 @@ void CharsetRendererNES::drawChar(int chr, Graphics::Surface &s, int x, int y) {
height = 8;
dst = (byte *)s.pixels + y * s.pitch + x;
- drawBits1(s, dst, charPtr, y, width, height, s.bytesPerPixel);
+ drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel);
}
void CharsetRendererNES::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth, bool scalex) {
diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp
index bb3c4bcc02..820605924c 100644
--- a/engines/scumm/cursor.cpp
+++ b/engines/scumm/cursor.cpp
@@ -385,7 +385,7 @@ void ScummEngine_v5::redefineBuiltinCursorFromChar(int index, int chr) {
s.pitch = s.w;
// s.h = 17 for FM-TOWNS Loom Japanese. Fixes bug #1166917
assert(s.w <= 16 && s.h <= 17);
- s.bytesPerPixel = 1;
+ s.format = Graphics::PixelFormat::createFormatCLUT8();
_charset->drawChar(chr, s, 0, 0);
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index 80c13d30e3..e7abd5610e 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -391,8 +391,11 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int
vs->hasTwoBuffers = twobufs;
vs->xstart = 0;
vs->backBuf = NULL;
- vs->bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1;
- vs->pitch = width * vs->bytesPerPixel;
+ if (_game.features & GF_16BIT_COLOR)
+ vs->format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+ else
+ vs->format = Graphics::PixelFormat::createFormatCLUT8();
+ vs->pitch = width * vs->format.bytesPerPixel;
if (_game.version >= 7) {
// Increase the pitch by one; needed to accomodate the extra screen
@@ -628,7 +631,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
int m = _textSurfaceMultiplier;
int vsPitch;
int pitch = vs->pitch;
- vsPitch = vs->pitch - width * vs->bytesPerPixel;
+ vsPitch = vs->pitch - width * vs->format.bytesPerPixel;
if (_game.version < 7) {
@@ -673,7 +676,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
} else {
WRITE_UINT16(dstPtr, _16BitPalette[tmp]); dstPtr += 2;
}
- srcPtr += vs->bytesPerPixel;
+ srcPtr += vs->format.bytesPerPixel;
}
srcPtr += vsPitch;
textPtr += _textSurface.pitch - width * m;
@@ -712,7 +715,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
}
#endif
src = _compositeBuf;
- pitch = width * vs->bytesPerPixel;
+ pitch = width * vs->format.bytesPerPixel;
if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
ditherHerc(_compositeBuf, _herculesBuf, width, &x, &y, &width, &height);
@@ -1042,17 +1045,17 @@ void ScummEngine::restoreBackground(Common::Rect rect, byte backColor) {
return;
if (vs->hasTwoBuffers && _currentRoom != 0 && isLightOn()) {
- blit(screenBuf, vs->pitch, vs->getBackPixels(rect.left, rect.top), vs->pitch, width, height, vs->bytesPerPixel);
+ blit(screenBuf, vs->pitch, vs->getBackPixels(rect.left, rect.top), vs->pitch, width, height, vs->format.bytesPerPixel);
if (vs->number == kMainVirtScreen && _charset->_hasMask) {
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
if (_game.platform == Common::kPlatformFMTowns) {
byte *mask = (byte *)_textSurface.getBasePtr(rect.left * _textSurfaceMultiplier, (rect.top + vs->topline) * _textSurfaceMultiplier);
- fill(mask, _textSurface.pitch, 0, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel);
+ fill(mask, _textSurface.pitch, 0, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel);
} else
#endif
{
byte *mask = (byte *)_textSurface.getBasePtr(rect.left, rect.top - _screenTop);
- fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel);
+ fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel);
}
}
} else {
@@ -1060,14 +1063,14 @@ void ScummEngine::restoreBackground(Common::Rect rect, byte backColor) {
if (_game.platform == Common::kPlatformFMTowns) {
backColor |= (backColor << 4);
byte *mask = (byte *)_textSurface.getBasePtr(rect.left * _textSurfaceMultiplier, (rect.top + vs->topline) * _textSurfaceMultiplier);
- fill(mask, _textSurface.pitch, backColor, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel);
+ fill(mask, _textSurface.pitch, backColor, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel);
}
#endif
if (_game.features & GF_16BIT_COLOR)
- fill(screenBuf, vs->pitch, _16BitPalette[backColor], width, height, vs->bytesPerPixel);
+ fill(screenBuf, vs->pitch, _16BitPalette[backColor], width, height, vs->format.bytesPerPixel);
else
- fill(screenBuf, vs->pitch, backColor, width, height, vs->bytesPerPixel);
+ fill(screenBuf, vs->pitch, backColor, width, height, vs->format.bytesPerPixel);
}
}
@@ -1096,7 +1099,7 @@ void ScummEngine::restoreCharsetBg() {
if (vs->number != kMainVirtScreen) {
// Restore from back buffer
const byte *backBuf = vs->getBackPixels(0, 0);
- blit(screenBuf, vs->pitch, backBuf, vs->pitch, vs->w, vs->h, vs->bytesPerPixel);
+ blit(screenBuf, vs->pitch, backBuf, vs->pitch, vs->w, vs->h, vs->format.bytesPerPixel);
}
} else {
// Clear area
@@ -1124,7 +1127,7 @@ void ScummEngine::clearTextSurface() {
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
_game.platform == Common::kPlatformFMTowns ? 0 :
#endif
- CHARSET_MASK_TRANSPARENCY, _textSurface.w, _textSurface.h, _textSurface.bytesPerPixel);
+ CHARSET_MASK_TRANSPARENCY, _textSurface.w, _textSurface.h, _textSurface.format.bytesPerPixel);
}
byte *ScummEngine::getMaskBuffer(int x, int y, int z) {
@@ -1297,56 +1300,56 @@ void ScummEngine::drawBox(int x, int y, int x2, int y2, int color) {
if (vs->number != kMainVirtScreen)
error("can only copy bg to main window");
- blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel);
+ blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->format.bytesPerPixel);
if (_charset->_hasMask) {
byte *mask = (byte *)_textSurface.getBasePtr(x * _textSurfaceMultiplier, (y - _screenTop) * _textSurfaceMultiplier);
- fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel);
+ fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel);
}
}
} else if (_game.heversion >= 72) {
// Flags are used for different methods in HE games
uint32 flags = color;
if ((flags & 0x2000) || (flags & 0x4000000)) {
- blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel);
+ blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->format.bytesPerPixel);
} else if ((flags & 0x4000) || (flags & 0x2000000)) {
- blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->bytesPerPixel);
+ blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->format.bytesPerPixel);
} else if ((flags & 0x8000) || (flags & 0x1000000)) {
flags &= (flags & 0x1000000) ? 0xFFFFFF : 0x7FFF;
- fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel);
- fill(bgbuff, vs->pitch, flags, width, height, vs->bytesPerPixel);
+ fill(backbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel);
+ fill(bgbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel);
} else {
- fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel);
+ fill(backbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel);
}
} else if (_game.heversion >= 60) {
// Flags are used for different methods in HE games
uint16 flags = color;
if (flags & 0x2000) {
- blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel);
+ blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->format.bytesPerPixel);
} else if (flags & 0x4000) {
- blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->bytesPerPixel);
+ blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->format.bytesPerPixel);
} else if (flags & 0x8000) {
flags &= 0x7FFF;
- fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel);
- fill(bgbuff, vs->pitch, flags, width, height, vs->bytesPerPixel);
+ fill(backbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel);
+ fill(bgbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel);
} else {
- fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel);
+ fill(backbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel);
}
} else {
if (_game.features & GF_16BIT_COLOR) {
- fill(backbuff, vs->pitch, _16BitPalette[color], width, height, vs->bytesPerPixel);
+ fill(backbuff, vs->pitch, _16BitPalette[color], width, height, vs->format.bytesPerPixel);
} else {
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
if (_game.platform == Common::kPlatformFMTowns) {
color = ((color & 0x0f) << 4) | (color & 0x0f);
byte *mask = (byte *)_textSurface.getBasePtr(x * _textSurfaceMultiplier, (y - _screenTop + vs->topline) * _textSurfaceMultiplier);
- fill(mask, _textSurface.pitch, color, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel);
+ fill(mask, _textSurface.pitch, color, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel);
if (_game.id == GID_MONKEY2 || _game.id == GID_INDY4 || ((_game.id == GID_INDY3 || _game.id == GID_ZAK) && vs->number != kTextVirtScreen) || (_game.id == GID_LOOM && vs->number == kMainVirtScreen))
return;
}
#endif
- fill(backbuff, vs->pitch, color, width, height, vs->bytesPerPixel);
+ fill(backbuff, vs->pitch, color, width, height, vs->format.bytesPerPixel);
}
}
}
@@ -1385,7 +1388,7 @@ void ScummEngine_v5::drawFlashlight() {
_flashlight.y, _flashlight.y + _flashlight.h, USAGE_BIT_DIRTY);
if (_flashlight.buffer) {
- fill(_flashlight.buffer, vs->pitch, 0, _flashlight.w, _flashlight.h, vs->bytesPerPixel);
+ fill(_flashlight.buffer, vs->pitch, 0, _flashlight.w, _flashlight.h, vs->format.bytesPerPixel);
}
_flashlight.isDrawn = false;
}
@@ -1432,20 +1435,20 @@ void ScummEngine_v5::drawFlashlight() {
_flashlight.buffer = vs->getPixels(_flashlight.x, _flashlight.y);
bgbak = vs->getBackPixels(_flashlight.x, _flashlight.y);
- blit(_flashlight.buffer, vs->pitch, bgbak, vs->pitch, _flashlight.w, _flashlight.h, vs->bytesPerPixel);
+ blit(_flashlight.buffer, vs->pitch, bgbak, vs->pitch, _flashlight.w, _flashlight.h, vs->format.bytesPerPixel);
// Round the corners. To do so, we simply hard-code a set of nicely
// rounded corners.
static const int corner_data[] = { 8, 6, 4, 3, 2, 2, 1, 1 };
int minrow = 0;
- int maxcol = (_flashlight.w - 1) * vs->bytesPerPixel;
+ int maxcol = (_flashlight.w - 1) * vs->format.bytesPerPixel;
int maxrow = (_flashlight.h - 1) * vs->pitch;
for (i = 0; i < 8; i++, minrow += vs->pitch, maxrow -= vs->pitch) {
int d = corner_data[i];
for (j = 0; j < d; j++) {
- if (vs->bytesPerPixel == 2) {
+ if (vs->format.bytesPerPixel == 2) {
WRITE_UINT16(&_flashlight.buffer[minrow + 2 * j], 0);
WRITE_UINT16(&_flashlight.buffer[minrow + maxcol - 2 * j], 0);
WRITE_UINT16(&_flashlight.buffer[maxrow + 2 * j], 0);
@@ -1761,7 +1764,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const
}
#endif
- _vertStripNextInc = height * vs->pitch - 1 * vs->bytesPerPixel;
+ _vertStripNextInc = height * vs->pitch - 1 * vs->format.bytesPerPixel;
_objectMode = (flag & dbObjectMode) == dbObjectMode;
prepareDrawBitmap(ptr, vs, x, y, width, height, stripnr, numstrip);
@@ -1794,9 +1797,9 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const
// In the case of a double buffered virtual screen, we draw to
// the backbuffer, otherwise to the primary surface memory.
if (vs->hasTwoBuffers)
- dstPtr = vs->backBuf + y * vs->pitch + (x * 8 * vs->bytesPerPixel);
+ dstPtr = vs->backBuf + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
else
- dstPtr = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->bytesPerPixel);
+ dstPtr = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
transpStrip = drawStrip(dstPtr, vs, x, y, width, height, stripnr, smap_ptr);
@@ -1805,11 +1808,11 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const
transpStrip = true;
if (vs->hasTwoBuffers) {
- byte *frontBuf = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->bytesPerPixel);
+ byte *frontBuf = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
if (lightsOn)
- copy8Col(frontBuf, vs->pitch, dstPtr, height, vs->bytesPerPixel);
+ copy8Col(frontBuf, vs->pitch, dstPtr, height, vs->format.bytesPerPixel);
else
- clear8Col(frontBuf, vs->pitch, height, vs->bytesPerPixel);
+ clear8Col(frontBuf, vs->pitch, height, vs->format.bytesPerPixel);
}
decodeMask(x, y, width, height, stripnr, numzbuf, zplane_list, transpStrip, flag, tmsk_ptr);
@@ -2045,7 +2048,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) {
drawStripHE(dst, vs->pitch, bmap_ptr, vs->w, vs->h, true);
break;
case 150:
- fill(dst, vs->pitch, *bmap_ptr, vs->w, vs->h, vs->bytesPerPixel);
+ fill(dst, vs->pitch, *bmap_ptr, vs->w, vs->h, vs->format.bytesPerPixel);
break;
default:
// Alternative russian freddi3 uses badly formatted bitmaps
@@ -2156,7 +2159,7 @@ void ScummEngine_v70he::restoreBackgroundHE(Common::Rect rect, int dirtybit) {
assert(rw <= _screenWidth && rw > 0);
assert(rh <= _screenHeight && rh > 0);
- blit(dst, _virtscr[kMainVirtScreen].pitch, src, _virtscr[kMainVirtScreen].pitch, rw, rh, vs->bytesPerPixel);
+ blit(dst, _virtscr[kMainVirtScreen].pitch, src, _virtscr[kMainVirtScreen].pitch, rw, rh, vs->format.bytesPerPixel);
markRectAsDirty(kMainVirtScreen, rect, dirtybit);
}
#endif
@@ -2186,15 +2189,15 @@ void Gdi::resetBackground(int top, int bottom, int strip) {
if (bottom > vs->bdirty[strip])
vs->bdirty[strip] = bottom;
- bgbak_ptr = (byte *)vs->backBuf + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->bytesPerPixel;
- backbuff_ptr = (byte *)vs->pixels + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->bytesPerPixel;
+ bgbak_ptr = (byte *)vs->backBuf + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->format.bytesPerPixel;
+ backbuff_ptr = (byte *)vs->pixels + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->format.bytesPerPixel;
numLinesToProcess = bottom - top;
if (numLinesToProcess) {
if (_vm->isLightOn()) {
- copy8Col(backbuff_ptr, vs->pitch, bgbak_ptr, numLinesToProcess, vs->bytesPerPixel);
+ copy8Col(backbuff_ptr, vs->pitch, bgbak_ptr, numLinesToProcess, vs->format.bytesPerPixel);
} else {
- clear8Col(backbuff_ptr, vs->pitch, numLinesToProcess, vs->bytesPerPixel);
+ clear8Col(backbuff_ptr, vs->pitch, numLinesToProcess, vs->format.bytesPerPixel);
}
}
}
diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h
index c6062ef9be..3f69d75efd 100644
--- a/engines/scumm/gfx.h
+++ b/engines/scumm/gfx.h
@@ -158,11 +158,11 @@ struct VirtScreen : Graphics::Surface {
}
byte *getPixels(int x, int y) const {
- return (byte *)pixels + y * pitch + (xstart + x) * bytesPerPixel;
+ return (byte *)pixels + y * pitch + (xstart + x) * format.bytesPerPixel;
}
byte *getBackPixels(int x, int y) const {
- return (byte *)backBuf + y * pitch + (xstart + x) * bytesPerPixel;
+ return (byte *)backBuf + y * pitch + (xstart + x) * format.bytesPerPixel;
}
};
diff --git a/engines/scumm/gfx_towns.cpp b/engines/scumm/gfx_towns.cpp
index abf2da63a6..78c7ef23f1 100644
--- a/engines/scumm/gfx_towns.cpp
+++ b/engines/scumm/gfx_towns.cpp
@@ -48,7 +48,7 @@ void ScummEngine::towns_drawStripToScreen(VirtScreen *vs, int dstX, int dstY, in
int dp1 = _townsScreen->getLayerPitch(0) - width * _townsScreen->getLayerBpp(0);
int dp2 = _townsScreen->getLayerPitch(1) - width * m * _townsScreen->getLayerBpp(1);
- int sp1 = vs->pitch - (width * vs->bytesPerPixel);
+ int sp1 = vs->pitch - (width * vs->format.bytesPerPixel);
int sp2 = _textSurface.pitch - width * m;
if (vs->number == kMainVirtScreen || _game.id == GID_INDY3 || _game.id == GID_ZAK) {
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 0e7ceff195..f43aed53f7 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1222,7 +1222,7 @@ void ScummEngine::setupScumm() {
setupCharsetRenderer();
// Create and clear the text surface
- _textSurface.create(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, 1);
+ _textSurface.create(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, Graphics::PixelFormat::createFormatCLUT8());
clearTextSurface();
// Create the costume renderer
diff --git a/engines/sword25/fmv/movieplayer.cpp b/engines/sword25/fmv/movieplayer.cpp
index 919e669b68..975f08be22 100644
--- a/engines/sword25/fmv/movieplayer.cpp
+++ b/engines/sword25/fmv/movieplayer.cpp
@@ -125,7 +125,7 @@ void MoviePlayer::update() {
const Graphics::Surface *s = _decoder.decodeNextFrame();
if (s) {
// Transfer the next frame
- assert(s->bytesPerPixel == 4);
+ assert(s->format.bytesPerPixel == 4);
#ifdef THEORA_INDIRECT_RENDERING
byte *frameData = (byte *)s->getBasePtr(0, 0);
diff --git a/engines/sword25/fmv/theora_decoder.cpp b/engines/sword25/fmv/theora_decoder.cpp
index 2b09be74f5..86236fbd21 100644
--- a/engines/sword25/fmv/theora_decoder.cpp
+++ b/engines/sword25/fmv/theora_decoder.cpp
@@ -290,7 +290,7 @@ bool TheoraDecoder::loadStream(Common::SeekableReadStream *stream) {
_surface = new Graphics::Surface();
- _surface->create(_theoraInfo.frame_width, _theoraInfo.frame_height, 4);
+ _surface->create(_theoraInfo.frame_width, _theoraInfo.frame_height, g_system->getScreenFormat());
return true;
}
diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp
index 502d2d3b2a..8bdf2a4a6e 100644
--- a/engines/sword25/gfx/graphicengine.cpp
+++ b/engines/sword25/gfx/graphicengine.cpp
@@ -112,8 +112,10 @@ bool GraphicEngine::init(int width, int height, int bitDepth, int backbufferCoun
_screenRect.right = _width;
_screenRect.bottom = _height;
- _backSurface.create(width, height, 4);
- _frameBuffer.create(width, height, 4);
+ const Graphics::PixelFormat format = g_system->getScreenFormat();
+
+ _backSurface.create(width, height, format);
+ _frameBuffer.create(width, height, format);
// Standardmäßig ist Vsync an.
setVsync(true);
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index b740c0ec68..806d9b27ad 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -187,7 +187,8 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe
// Create an encapsulating surface for the data
Graphics::Surface srcImage;
- srcImage.bytesPerPixel = 4;
+ // TODO: Is the data really in the screen format?
+ srcImage.format = g_system->getScreenFormat();
srcImage.pitch = _width * 4;
srcImage.w = _width;
srcImage.h = _height;
@@ -409,7 +410,7 @@ void RenderedImage::copyDirectly(int posX, int posY) {
*/
Graphics::Surface *RenderedImage::scale(const Graphics::Surface &srcImage, int xSize, int ySize) {
Graphics::Surface *s = new Graphics::Surface();
- s->create(xSize, ySize, srcImage.bytesPerPixel);
+ s->create(xSize, ySize, srcImage.format);
int *horizUsage = scaleLine(xSize, srcImage.w);
int *vertUsage = scaleLine(ySize, srcImage.h);
@@ -420,8 +421,8 @@ Graphics::Surface *RenderedImage::scale(const Graphics::Surface &srcImage, int x
byte *destP = (byte *)s->getBasePtr(0, yp);
for (int xp = 0; xp < xSize; ++xp) {
- const byte *tempSrcP = srcP + (horizUsage[xp] * srcImage.bytesPerPixel);
- for (int byteCtr = 0; byteCtr < srcImage.bytesPerPixel; ++byteCtr) {
+ const byte *tempSrcP = srcP + (horizUsage[xp] * srcImage.format.bytesPerPixel);
+ for (int byteCtr = 0; byteCtr < srcImage.format.bytesPerPixel; ++byteCtr) {
*destP++ = *tempSrcP++;
}
}
diff --git a/engines/sword25/gfx/screenshot.cpp b/engines/sword25/gfx/screenshot.cpp
index ee664d6328..6ea2b574d6 100644
--- a/engines/sword25/gfx/screenshot.cpp
+++ b/engines/sword25/gfx/screenshot.cpp
@@ -128,14 +128,14 @@ Common::SeekableReadStream *Screenshot::createThumbnail(Graphics::Surface *data)
// generates a pixel of the target image. Finally, the result as a PNG file is stored as a file.
// The source image must be 800x600.
- if (data->w != 800 || data->h != 600 || data->bytesPerPixel != 4) {
+ if (data->w != 800 || data->h != 600 || data->format.bytesPerPixel != 4) {
error("The sreenshot dimensions have to be 800x600 in order to be saved as a thumbnail.");
return false;
}
// Buffer for the output thumbnail
Graphics::Surface thumbnail;
- thumbnail.create(200, 125, 4);
+ thumbnail.create(200, 125, g_system->getScreenFormat());
// Über das Zielbild iterieren und einen Pixel zur Zeit berechnen.
uint x, y;
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 1c2c3113c7..ee431b2ab5 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -382,7 +382,7 @@ void Scene::init(int id, const Common::Point &pos) {
custom_animation[i].free();
if (background.pixels == NULL)
- background.create(320, 200, 1);
+ background.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
warp(pos);
diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp
index 96672ca1b3..545b0f75f0 100644
--- a/engines/teenagent/surface.cpp
+++ b/engines/teenagent/surface.cpp
@@ -61,7 +61,7 @@ void Surface::load(Common::SeekableReadStream *stream, Type type) {
}
//debug(0, "creating surface %ux%u -> %u,%u", w_, h_, x, y);
- create(w_, h_, 1);
+ create(w_, h_, Graphics::PixelFormat::createFormatCLUT8());
stream->read(pixels, w_ * h_);
}
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 748f1322ea..20d4f1d31a 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -903,10 +903,10 @@ Common::Error TinselEngine::run() {
#else
initGraphics(640, 432, true);
#endif
- _screenSurface.create(640, 432, 1);
+ _screenSurface.create(640, 432, Graphics::PixelFormat::createFormatCLUT8());
} else {
initGraphics(320, 200, false);
- _screenSurface.create(320, 200, 1);
+ _screenSurface.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
}
g_eventRec.registerRandomSource(_random, "tinsel");
diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp
index 19c85d132c..64b80c29b3 100644
--- a/engines/toon/movie.cpp
+++ b/engines/toon/movie.cpp
@@ -59,7 +59,7 @@ bool ToonstruckSmackerDecoder::loadFile(const Common::String &filename) {
delete _surface;
}
_surface = new Graphics::Surface();
- _surface->create(640, 400, 1);
+ _surface->create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
_header.flags = 4;
}
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 297390c19f..81c4d313e4 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -58,7 +58,7 @@ void ToonEngine::init() {
_hotspots = new Hotspots(this);
_mainSurface = new Graphics::Surface();
- _mainSurface->create(TOON_BACKBUFFER_WIDTH, TOON_BACKBUFFER_HEIGHT, 1);
+ _mainSurface->create(TOON_BACKBUFFER_WIDTH, TOON_BACKBUFFER_HEIGHT, Graphics::PixelFormat::createFormatCLUT8());
_finalPalette = new uint8[768];
_backupPalette = new uint8[768];
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index dce1b86401..9d840bf00d 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -258,7 +258,7 @@ void GfxSurface::create(int width, int height) {
assert((width >= 0) && (height >= 0));
_screenSurface = false;
_customSurface = new Graphics::Surface();
- _customSurface->create(width, height, 1);
+ _customSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_bounds = Rect(0, 0, width, height);
}
@@ -283,7 +283,7 @@ Graphics::Surface GfxSurface::lockSurface() {
result.w = _bounds.width();
result.h = _bounds.height();
result.pitch = src->pitch;
- result.bytesPerPixel = src->bytesPerPixel;
+ result.format = src->format;
result.pixels = src->getBasePtr(_bounds.left, _bounds.top);
return result;
@@ -332,7 +332,7 @@ GfxSurface &GfxSurface::operator=(const GfxSurface &s) {
if (_customSurface) {
// Surface owns the internal data, so replicate it so new surface owns it's own
_customSurface = new Graphics::Surface();
- _customSurface->create(s._customSurface->w, s._customSurface->h, 1);
+ _customSurface->create(s._customSurface->w, s._customSurface->h, Graphics::PixelFormat::createFormatCLUT8());
const byte *srcP = (const byte *)s._customSurface->getBasePtr(0, 0);
byte *destP = (byte *)_customSurface->getBasePtr(0, 0);
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 3eef1b11a9..3eb8b1345f 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -276,7 +276,7 @@ copyFrame(OSystem *sys, const Common::Rect &r) {
sys->copyRectToOverlay(
(const OverlayColor *)_activeSurface->getBasePtr(r.left, r.top),
- _activeSurface->pitch / _activeSurface->bytesPerPixel,
+ _activeSurface->pitch / _activeSurface->format.bytesPerPixel,
r.left, r.top, r.width(), r.height()
);
}
@@ -336,8 +336,8 @@ blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) {
PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
const PixelType *src_ptr = (const PixelType *)source->getBasePtr(0, 0);
- int dst_pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
- int src_pitch = source->pitch / source->bytesPerPixel;
+ int dst_pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
+ int src_pitch = source->pitch / source->format.bytesPerPixel;
int w, h = source->h;
@@ -484,7 +484,7 @@ drawLine(int x1, int y1, int x2, int y2) {
return;
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1);
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int st = Base::_strokeWidth >> 1;
if (dy == 0) { // horizontal lines
@@ -732,7 +732,7 @@ void VectorRendererSpec<PixelType>::
drawTabAlg(int x1, int y1, int w, int h, int r, PixelType color, VectorRenderer::FillMode fill_m, int baseLeft, int baseRight) {
int f, ddF_x, ddF_y;
int x, y, px, py;
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int sw = 0, sp = 0, hp = 0;
PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r);
@@ -830,7 +830,7 @@ drawTabAlg(int x1, int y1, int w, int h, int r, PixelType color, VectorRenderer:
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawBevelTabAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, int baseLeft, int baseRight) {
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int i, j;
PixelType *ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y);
@@ -875,7 +875,7 @@ template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawSquareAlg(int x, int y, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int max_h = h;
if (fill_m != kFillDisabled) {
@@ -907,7 +907,7 @@ drawSquareAlg(int x, int y, int w, int h, PixelType color, VectorRenderer::FillM
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, bool fill) {
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int height = h;
PixelType *ptr_fill = (PixelType *)_activeSurface->getBasePtr(x, y);
@@ -964,7 +964,7 @@ template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1);
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int xdir = (x2 > x1) ? 1 : -1;
*ptr = (PixelType)color;
@@ -1012,7 +1012,7 @@ template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawTriangleVertAlg(int x1, int y1, int w, int h, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) {
int dx = w >> 1, dy = h, gradient_h = 0;
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
PixelType *ptr_right = 0, *ptr_left = 0;
if (inverted) {
@@ -1093,7 +1093,7 @@ drawTriangleVertAlg(int x1, int y1, int w, int h, bool inverted, PixelType color
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawTriangleFast(int x1, int y1, int size, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) {
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int hstep = 0, dy = size;
bool grad = (fill_m == kFillGradient);
@@ -1142,7 +1142,7 @@ void VectorRendererSpec<PixelType>::
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
int f, ddF_x, ddF_y;
int x, y, px, py;
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int sw = 0, sp = 0, hp = h * pitch;
PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r);
@@ -1233,7 +1233,7 @@ void VectorRendererSpec<PixelType>::
drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode fill_m) {
int f, ddF_x, ddF_y;
int x, y, px, py, sw = 0;
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
if (fill_m == kFillDisabled) {
@@ -1283,7 +1283,7 @@ template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawSquareShadow(int x, int y, int w, int h, int blur) {
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x + w - 1, y + blur);
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int i, j;
i = h - blur;
@@ -1320,7 +1320,7 @@ void VectorRendererSpec<PixelType>::
drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int blur) {
int f, ddF_x, ddF_y;
int x, y, px, py;
- int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int alpha = 102;
x1 += blur;
@@ -1367,7 +1367,7 @@ template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawRoundedSquareFakeBevel(int x1, int y1, int r, int w, int h, int amount) {
int x, y;
- const int pitch = _activeSurface->pitch / _activeSurface->bytesPerPixel;
+ const int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int px, py;
int sw = 0, sp = 0;
@@ -1437,7 +1437,7 @@ void VectorRendererAA<PixelType>::
drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
- int pitch = Base::_activeSurface->pitch / Base::_activeSurface->bytesPerPixel;
+ int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel;
int xdir = (x2 > x1) ? 1 : -1;
uint16 error_tmp, error_acc, gradient;
uint8 alpha;
@@ -1488,7 +1488,7 @@ template<typename PixelType>
void VectorRendererAA<PixelType>::
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
int x, y;
- const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->bytesPerPixel;
+ const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel;
int px, py;
int sw = 0, sp = 0, hp = h * pitch;
@@ -1565,7 +1565,7 @@ template<typename PixelType>
void VectorRendererAA<PixelType>::
drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode fill_m) {
int x, y, sw = 0;
- const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->bytesPerPixel;
+ const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel;
int px, py;
uint32 rsq = r*r;
diff --git a/graphics/font.cpp b/graphics/font.cpp
index 9d450e881c..7fa39d07db 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -78,7 +78,7 @@ void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const
assert(dst != 0);
assert(desc.bits != 0 && desc.maxwidth <= 16);
- assert(dst->bytesPerPixel == 1 || dst->bytesPerPixel == 2);
+ assert(dst->format.bytesPerPixel == 1 || dst->format.bytesPerPixel == 2);
// If this character is not included in the font, use the default char.
if (chr < desc.firstchar || chr >= desc.firstchar + desc.size) {
@@ -110,9 +110,9 @@ void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const
tmp += bbh - y;
y -= MAX(0, ty + desc.ascent - bby - dst->h);
- if (dst->bytesPerPixel == 1)
+ if (dst->format.bytesPerPixel == 1)
drawCharIntern<byte>(ptr, dst->pitch, tmp, y, MAX(0, -(tx + bbx)), MIN(bbw, dst->w - tx - bbx), color);
- else if (dst->bytesPerPixel == 2)
+ else if (dst->format.bytesPerPixel == 2)
drawCharIntern<uint16>(ptr, dst->pitch, tmp, y, MAX(0, -(tx + bbx)), MIN(bbw, dst->w - tx - bbx), color);
}
diff --git a/graphics/fonts/scummfont.cpp b/graphics/fonts/scummfont.cpp
index ea1935cea5..3331b72c47 100644
--- a/graphics/fonts/scummfont.cpp
+++ b/graphics/fonts/scummfont.cpp
@@ -303,9 +303,9 @@ void ScummFont::drawChar(Surface *dst, byte chr, int tx, int ty, uint32 color) c
}
c = ((buffer & mask) != 0);
if (c) {
- if (dst->bytesPerPixel == 1)
+ if (dst->format.bytesPerPixel == 1)
ptr[x] = color;
- else if (dst->bytesPerPixel == 2)
+ else if (dst->format.bytesPerPixel == 2)
((uint16 *)ptr)[x] = color;
}
}
diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp
index 18866b4f6f..7db9a233f6 100644
--- a/graphics/fonts/winfont.cpp
+++ b/graphics/fonts/winfont.cpp
@@ -323,7 +323,7 @@ bool WinFont::loadFromFNT(Common::SeekableReadStream &stream) {
void WinFont::drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const {
assert(dst);
- assert(dst->bytesPerPixel == 1 || dst->bytesPerPixel == 2 || dst->bytesPerPixel == 4);
+ assert(dst->format.bytesPerPixel == 1 || dst->format.bytesPerPixel == 2 || dst->format.bytesPerPixel == 4);
assert(_glyphs);
GlyphEntry &glyph = _glyphs[characterToIndex(chr)];
@@ -331,11 +331,11 @@ void WinFont::drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const
for (uint16 i = 0; i < _pixHeight; i++) {
for (uint16 j = 0; j < glyph.charWidth; j++) {
if (glyph.bitmap[j + i * glyph.charWidth]) {
- if (dst->bytesPerPixel == 1)
+ if (dst->format.bytesPerPixel == 1)
*((byte *)dst->getBasePtr(x + j, y + i)) = color;
- else if (dst->bytesPerPixel == 2)
+ else if (dst->format.bytesPerPixel == 2)
*((uint16 *)dst->getBasePtr(x + j, y + i)) = color;
- else if (dst->bytesPerPixel == 4)
+ else if (dst->format.bytesPerPixel == 4)
*((uint32 *)dst->getBasePtr(x + j, y + i)) = color;
}
}
diff --git a/graphics/iff.cpp b/graphics/iff.cpp
index a1f4e8aa6a..fee71de485 100644
--- a/graphics/iff.cpp
+++ b/graphics/iff.cpp
@@ -208,7 +208,7 @@ struct PBMLoader {
case ID_BODY:
if (_surface) {
- _surface->create(_decoder._header.width, _decoder._header.height, 1);
+ _surface->create(_decoder._header.width, _decoder._header.height, PixelFormat::createFormatCLUT8());
_decoder.loadBitmap((byte*)_surface->pixels, chunk._stream);
}
return true; // stop the parser
diff --git a/graphics/imagedec.cpp b/graphics/imagedec.cpp
index 91da83cc63..f45f0ce5ef 100644
--- a/graphics/imagedec.cpp
+++ b/graphics/imagedec.cpp
@@ -118,7 +118,7 @@ Surface *BMPDecoder::decodeImage(Common::SeekableReadStream &stream, const Pixel
uint8 r = 0, g = 0, b = 0;
Surface *newSurf = new Surface;
assert(newSurf);
- newSurf->create(info.width, info.height, sizeof(OverlayColor));
+ newSurf->create(info.width, info.height, format);
assert(newSurf->pixels);
OverlayColor *curPixel = (OverlayColor*)newSurf->pixels + (newSurf->h-1) * newSurf->w;
int pitchAdd = info.width % 4;
diff --git a/graphics/jpeg.cpp b/graphics/jpeg.cpp
index 2d990b9b0e..f1dcd4ac0c 100644
--- a/graphics/jpeg.cpp
+++ b/graphics/jpeg.cpp
@@ -96,7 +96,7 @@ Surface *JPEG::getSurface(const PixelFormat &format) {
Graphics::Surface *vComponent = getComponent(3);
Graphics::Surface *output = new Graphics::Surface();
- output->create(yComponent->w, yComponent->h, format.bytesPerPixel);
+ output->create(yComponent->w, yComponent->h, format);
for (uint16 i = 0; i < output->h; i++) {
for (uint16 j = 0; j < output->w; j++) {
@@ -444,7 +444,7 @@ bool JPEG::readSOS() {
// Initialize the scan surfaces
for (uint16 c = 0; c < _numScanComp; c++) {
- _scanComp[c]->surface.create(xMCU * _maxFactorH * 8, yMCU * _maxFactorV * 8, 1);
+ _scanComp[c]->surface.create(xMCU * _maxFactorH * 8, yMCU * _maxFactorV * 8, PixelFormat::createFormatCLUT8());
}
bool ok = true;
diff --git a/graphics/pict.cpp b/graphics/pict.cpp
index b61b000acd..acade48515 100644
--- a/graphics/pict.cpp
+++ b/graphics/pict.cpp
@@ -212,7 +212,7 @@ void PictDecoder::decodeDirectBitsRect(Common::SeekableReadStream *stream, bool
bytesPerPixel = directBitsData.pixMap.pixelSize / 8;
_outputSurface = new Graphics::Surface();
- _outputSurface->create(width, height, (bytesPerPixel == 1) ? 1 : _pixelFormat.bytesPerPixel);
+ _outputSurface->create(width, height, (bytesPerPixel == 1) ? PixelFormat::createFormatCLUT8() : _pixelFormat);
byte *buffer = new byte[width * height * bytesPerPixel];
// Read in amount of data per row
diff --git a/graphics/png.cpp b/graphics/png.cpp
index 46e3c2523b..3cdb9f7cca 100644
--- a/graphics/png.cpp
+++ b/graphics/png.cpp
@@ -113,16 +113,16 @@ PNG::~PNG() {
Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
Graphics::Surface *output = new Graphics::Surface();
- output->create(_unfilteredSurface->w, _unfilteredSurface->h, format.bytesPerPixel);
+ output->create(_unfilteredSurface->w, _unfilteredSurface->h, format);
byte *src = (byte *)_unfilteredSurface->pixels;
byte a = 0xFF;
if (_header.colorType != kIndexed) {
if (_header.colorType == kTrueColor || _header.colorType == kTrueColorWithAlpha) {
- if (_unfilteredSurface->bytesPerPixel != 3 && _unfilteredSurface->bytesPerPixel != 4)
+ if (_unfilteredSurface->format.bytesPerPixel != 3 && _unfilteredSurface->format.bytesPerPixel != 4)
error("Unsupported truecolor PNG format");
} else if (_header.colorType == kGrayScale || _header.colorType == kGrayScaleWithAlpha) {
- if (_unfilteredSurface->bytesPerPixel != 1 && _unfilteredSurface->bytesPerPixel != 2)
+ if (_unfilteredSurface->format.bytesPerPixel != 1 && _unfilteredSurface->format.bytesPerPixel != 2)
error("Unsupported grayscale PNG format");
}
@@ -130,13 +130,13 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
for (uint16 j = 0; j < output->w; j++) {
if (format.bytesPerPixel == 2) { // 2bpp
uint16 *dest = ((uint16 *)output->getBasePtr(j, i));
- if (_unfilteredSurface->bytesPerPixel == 1) { // Grayscale
+ if (_unfilteredSurface->format.bytesPerPixel == 1) { // Grayscale
if (_transparentColorSpecified)
a = (src[0] == _transparentColor[0]) ? 0 : 0xFF;
*dest = format.ARGBToColor( a, src[0], src[0], src[0]);
- } else if (_unfilteredSurface->bytesPerPixel == 2) { // Grayscale + alpha
+ } else if (_unfilteredSurface->format.bytesPerPixel == 2) { // Grayscale + alpha
*dest = format.ARGBToColor(src[1], src[0], src[0], src[0]);
- } else if (_unfilteredSurface->bytesPerPixel == 3) { // RGB
+ } else if (_unfilteredSurface->format.bytesPerPixel == 3) { // RGB
if (_transparentColorSpecified) {
bool isTransparentColor = (src[0] == _transparentColor[0] &&
src[1] == _transparentColor[1] &&
@@ -144,18 +144,18 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
a = isTransparentColor ? 0 : 0xFF;
}
*dest = format.ARGBToColor( a, src[0], src[1], src[2]);
- } else if (_unfilteredSurface->bytesPerPixel == 4) { // RGBA
+ } else if (_unfilteredSurface->format.bytesPerPixel == 4) { // RGBA
*dest = format.ARGBToColor(src[3], src[0], src[1], src[2]);
}
} else { // 4bpp
uint32 *dest = ((uint32 *)output->getBasePtr(j, i));
- if (_unfilteredSurface->bytesPerPixel == 1) { // Grayscale
+ if (_unfilteredSurface->format.bytesPerPixel == 1) { // Grayscale
if (_transparentColorSpecified)
a = (src[0] == _transparentColor[0]) ? 0 : 0xFF;
*dest = format.ARGBToColor( a, src[0], src[0], src[0]);
- } else if (_unfilteredSurface->bytesPerPixel == 2) { // Grayscale + alpha
+ } else if (_unfilteredSurface->format.bytesPerPixel == 2) { // Grayscale + alpha
*dest = format.ARGBToColor(src[1], src[0], src[0], src[0]);
- } else if (_unfilteredSurface->bytesPerPixel == 3) { // RGB
+ } else if (_unfilteredSurface->format.bytesPerPixel == 3) { // RGB
if (_transparentColorSpecified) {
bool isTransparentColor = (src[0] == _transparentColor[0] &&
src[1] == _transparentColor[1] &&
@@ -163,12 +163,12 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
a = isTransparentColor ? 0 : 0xFF;
}
*dest = format.ARGBToColor( a, src[0], src[1], src[2]);
- } else if (_unfilteredSurface->bytesPerPixel == 4) { // RGBA
+ } else if (_unfilteredSurface->format.bytesPerPixel == 4) { // RGBA
*dest = format.ARGBToColor(src[3], src[0], src[1], src[2]);
}
}
- src += _unfilteredSurface->bytesPerPixel;
+ src += _unfilteredSurface->format.bytesPerPixel;
}
}
} else {
@@ -391,7 +391,8 @@ void PNG::constructImage() {
delete _unfilteredSurface;
}
_unfilteredSurface = new Graphics::Surface();
- _unfilteredSurface->create(_header.width, _header.height, (getNumColorChannels() * _header.bitDepth + 7) / 8);
+ // TODO/FIXME: It seems we can not properly determine the format here. But maybe there is a way...
+ _unfilteredSurface->create(_header.width, _header.height, PixelFormat((getNumColorChannels() * _header.bitDepth + 7) / 8, 0, 0, 0, 0, 0, 0, 0, 0));
scanLine = new byte[_unfilteredSurface->pitch];
dest = (byte *)_unfilteredSurface->getBasePtr(0, 0);
@@ -400,7 +401,7 @@ void PNG::constructImage() {
for (uint16 y = 0; y < _unfilteredSurface->h; y++) {
filterType = _imageData->readByte();
_imageData->read(scanLine, scanLineWidth);
- unfilterScanLine(dest, scanLine, prevLine, _unfilteredSurface->bytesPerPixel, filterType, scanLineWidth);
+ unfilterScanLine(dest, scanLine, prevLine, _unfilteredSurface->format.bytesPerPixel, filterType, scanLineWidth);
prevLine = dest;
dest += _unfilteredSurface->pitch;
}
diff --git a/graphics/scaler/thumbnail_intern.cpp b/graphics/scaler/thumbnail_intern.cpp
index 4b460b29ce..d78648c325 100644
--- a/graphics/scaler/thumbnail_intern.cpp
+++ b/graphics/scaler/thumbnail_intern.cpp
@@ -100,12 +100,12 @@ static bool grabScreen565(Graphics::Surface *surf) {
if (!screen)
return false;
- assert(screen->bytesPerPixel == 1 || screen->bytesPerPixel == 2);
+ assert(screen->format.bytesPerPixel == 1 || screen->format.bytesPerPixel == 2);
assert(screen->pixels != 0);
Graphics::PixelFormat screenFormat = g_system->getScreenFormat();
- surf->create(screen->w, screen->h, 2);
+ surf->create(screen->w, screen->h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
byte *palette = 0;
if (screenFormat.bytesPerPixel == 1) {
@@ -147,7 +147,7 @@ static bool createThumbnail(Graphics::Surface &out, Graphics::Surface &in) {
// center MM NES screen
Graphics::Surface newscreen;
- newscreen.create(width, in.h, in.bytesPerPixel);
+ newscreen.create(width, in.h, in.format);
uint8 *dst = (uint8 *)newscreen.getBasePtr((320 - in.w) / 2, 0);
const uint8 *src = (const uint8 *)in.getBasePtr(0, 0);
@@ -172,13 +172,13 @@ static bool createThumbnail(Graphics::Surface &out, Graphics::Surface &in) {
// cut off menu and so on..
Graphics::Surface newscreen;
- newscreen.create(width, 400, in.bytesPerPixel);
+ newscreen.create(width, 400, in.format);
uint8 *dst = (uint8 *)newscreen.getBasePtr(0, (400 - 240) / 2);
const uint8 *src = (const uint8 *)in.getBasePtr(41, 28);
for (int y = 0; y < 240; ++y) {
- memcpy(dst, src, 640 * in.bytesPerPixel);
+ memcpy(dst, src, 640 * in.format.bytesPerPixel);
dst += newscreen.pitch;
src += in.pitch;
}
@@ -191,9 +191,9 @@ static bool createThumbnail(Graphics::Surface &out, Graphics::Surface &in) {
inHeight = 480;
Graphics::Surface newscreen;
- newscreen.create(width, 480, in.bytesPerPixel);
+ newscreen.create(width, 480, in.format);
- memcpy(newscreen.getBasePtr(0, 0), in.getBasePtr(0, 0), width * 440 * in.bytesPerPixel);
+ memcpy(newscreen.getBasePtr(0, 0), in.getBasePtr(0, 0), width * 440 * in.format.bytesPerPixel);
in.free();
in = newscreen;
@@ -201,7 +201,7 @@ static bool createThumbnail(Graphics::Surface &out, Graphics::Surface &in) {
uint16 newHeight = !(inHeight % 240) ? kThumbnailHeight2 : kThumbnailHeight1;
- out.create(kThumbnailWidth, newHeight, sizeof(uint16));
+ out.create(kThumbnailWidth, newHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
createThumbnail((const uint8 *)in.pixels, width * sizeof(uint16), (uint8 *)out.pixels, out.pitch, width, inHeight);
in.free();
@@ -224,7 +224,7 @@ bool createThumbnail(Graphics::Surface *surf, const uint8 *pixels, int w, int h,
assert(surf);
Graphics::Surface screen;
- screen.create(w, h, 2);
+ screen.create(w, h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
for (uint y = 0; y < screen.h; ++y) {
for (uint x = 0; x < screen.w; ++x) {
diff --git a/graphics/sjis.cpp b/graphics/sjis.cpp
index 13ea339375..caa53a4f63 100644
--- a/graphics/sjis.cpp
+++ b/graphics/sjis.cpp
@@ -58,7 +58,7 @@ FontSJIS *FontSJIS::createFont(const Common::Platform platform) {
}
void FontSJIS::drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1, uint32 c2) const {
- drawChar(dst.getBasePtr(x, y), ch, dst.pitch, dst.bytesPerPixel, c1, c2, dst.w - x, dst.h - y);
+ drawChar(dst.getBasePtr(x, y), ch, dst.pitch, dst.format.bytesPerPixel, c1, c2, dst.w - x, dst.h - y);
}
template<typename Color>
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 271e32fc0c..88bdcfc822 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -41,23 +41,23 @@ static void plotPoint(int x, int y, int color, void *data) {
}
void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) {
- if (bytesPerPixel == 1)
+ if (format.bytesPerPixel == 1)
Graphics::drawLine(x0, y0, x1, y1, color, plotPoint<byte>, this);
- else if (bytesPerPixel == 2)
+ else if (format.bytesPerPixel == 2)
Graphics::drawLine(x0, y0, x1, y1, color, plotPoint<uint16>, this);
else
error("Surface::drawLine: bytesPerPixel must be 1 or 2");
}
-void Surface::create(uint16 width, uint16 height, uint8 bytesPP) {
+void Surface::create(uint16 width, uint16 height, const PixelFormat &f) {
free();
w = width;
h = height;
- bytesPerPixel = bytesPP;
- pitch = w * bytesPP;
+ format = f;
+ pitch = w * format.bytesPerPixel;
- pixels = calloc(width * height, bytesPP);
+ pixels = calloc(width * height, format.bytesPerPixel);
assert(pixels);
}
@@ -65,11 +65,11 @@ void Surface::free() {
::free(pixels);
pixels = 0;
w = h = pitch = 0;
- bytesPerPixel = 0;
+ format = PixelFormat();
}
void Surface::copyFrom(const Surface &surf) {
- create(surf.w, surf.h, surf.bytesPerPixel);
+ create(surf.w, surf.h, surf.format);
memcpy(pixels, surf.pixels, h * pitch);
}
@@ -89,10 +89,10 @@ void Surface::hLine(int x, int y, int x2, uint32 color) {
if (x2 < x)
return;
- if (bytesPerPixel == 1) {
+ if (format.bytesPerPixel == 1) {
byte *ptr = (byte *)getBasePtr(x, y);
memset(ptr, (byte)color, x2-x+1);
- } else if (bytesPerPixel == 2) {
+ } else if (format.bytesPerPixel == 2) {
uint16 *ptr = (uint16 *)getBasePtr(x, y);
Common::set_to(ptr, ptr + (x2-x+1), (uint16)color);
} else {
@@ -113,13 +113,13 @@ void Surface::vLine(int x, int y, int y2, uint32 color) {
if (y2 >= h)
y2 = h - 1;
- if (bytesPerPixel == 1) {
+ if (format.bytesPerPixel == 1) {
byte *ptr = (byte *)getBasePtr(x, y);
while (y++ <= y2) {
*ptr = (byte)color;
ptr += pitch;
}
- } else if (bytesPerPixel == 2) {
+ } else if (format.bytesPerPixel == 2) {
uint16 *ptr = (uint16 *)getBasePtr(x, y);
while (y++ <= y2) {
*ptr = (uint16)color;
@@ -141,13 +141,13 @@ void Surface::fillRect(Common::Rect r, uint32 color) {
int height = r.height();
bool useMemset = true;
- if (bytesPerPixel == 2) {
+ if (format.bytesPerPixel == 2) {
lineLen *= 2;
if ((uint16)color != ((color & 0xff) | (color & 0xff) << 8))
useMemset = false;
- } else if (bytesPerPixel == 4) {
+ } else if (format.bytesPerPixel == 4) {
useMemset = false;
- } else if (bytesPerPixel != 1) {
+ } else if (format.bytesPerPixel != 1) {
error("Surface::fillRect: bytesPerPixel must be 1, 2 or 4");
}
@@ -158,7 +158,7 @@ void Surface::fillRect(Common::Rect r, uint32 color) {
ptr += pitch;
}
} else {
- if (bytesPerPixel == 2) {
+ if (format.bytesPerPixel == 2) {
uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top);
while (height--) {
Common::set_to(ptr, ptr + width, (uint16)color);
@@ -186,7 +186,7 @@ void Surface::move(int dx, int dy, int height) {
if ((dx == 0 && dy == 0) || height <= 0)
return;
- if (bytesPerPixel != 1 && bytesPerPixel != 2)
+ if (format.bytesPerPixel != 1 && format.bytesPerPixel != 2)
error("Surface::move: bytesPerPixel must be 1 or 2");
byte *src, *dst;
@@ -216,37 +216,37 @@ void Surface::move(int dx, int dy, int height) {
// horizontal movement
if (dx > 0) {
// move right - copy from right to left
- dst = (byte *)pixels + (pitch - bytesPerPixel);
- src = dst - (dx * bytesPerPixel);
+ dst = (byte *)pixels + (pitch - format.bytesPerPixel);
+ src = dst - (dx * format.bytesPerPixel);
for (y = 0; y < height; y++) {
for (x = dx; x < w; x++) {
- if (bytesPerPixel == 1) {
+ if (format.bytesPerPixel == 1) {
*dst-- = *src--;
- } else if (bytesPerPixel == 2) {
+ } else if (format.bytesPerPixel == 2) {
*(uint16 *)dst = *(const uint16 *)src;
src -= 2;
dst -= 2;
}
}
- src += pitch + (pitch - dx * bytesPerPixel);
- dst += pitch + (pitch - dx * bytesPerPixel);
+ src += pitch + (pitch - dx * format.bytesPerPixel);
+ dst += pitch + (pitch - dx * format.bytesPerPixel);
}
} else if (dx < 0) {
// move left - copy from left to right
dst = (byte *)pixels;
- src = dst - (dx * bytesPerPixel);
+ src = dst - (dx * format.bytesPerPixel);
for (y = 0; y < height; y++) {
for (x = -dx; x < w; x++) {
- if (bytesPerPixel == 1) {
+ if (format.bytesPerPixel == 1) {
*dst++ = *src++;
- } else if (bytesPerPixel == 2) {
+ } else if (format.bytesPerPixel == 2) {
*(uint16 *)dst = *(const uint16 *)src;
src += 2;
dst += 2;
}
}
- src += pitch - (pitch + dx * bytesPerPixel);
- dst += pitch - (pitch + dx * bytesPerPixel);
+ src += pitch - (pitch + dx * format.bytesPerPixel);
+ dst += pitch - (pitch + dx * format.bytesPerPixel);
}
}
}
diff --git a/graphics/surface.h b/graphics/surface.h
index 92c7b7e899..1b54690aa9 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -31,6 +31,8 @@ namespace Common {
struct Rect;
}
+#include "graphics/pixelformat.h"
+
namespace Graphics {
/**
@@ -68,14 +70,14 @@ struct Surface {
void *pixels;
/**
- * How many bytes a single pixel occupies.
+ * The pixel format of the surface.
*/
- uint8 bytesPerPixel;
+ PixelFormat format;
/**
* Construct a simple Surface object.
*/
- Surface() : w(0), h(0), pitch(0), pixels(0), bytesPerPixel(0) {
+ Surface() : w(0), h(0), pitch(0), pixels(0), format() {
}
/**
@@ -86,7 +88,7 @@ struct Surface {
* @return Pointer to the pixel.
*/
inline const void *getBasePtr(int x, int y) const {
- return (const byte *)(pixels) + y * pitch + x * bytesPerPixel;
+ return (const byte *)(pixels) + y * pitch + x * format.bytesPerPixel;
}
/**
@@ -97,7 +99,7 @@ struct Surface {
* @return Pointer to the pixel.
*/
inline void *getBasePtr(int x, int y) {
- return static_cast<byte *>(pixels) + y * pitch + x * bytesPerPixel;
+ return static_cast<byte *>(pixels) + y * pitch + x * format.bytesPerPixel;
}
/**
@@ -108,9 +110,9 @@ struct Surface {
*
* @param width Width of the surface object.
* @param height Height of the surface object.
- * @param bytePP The number of bytes a single pixel uses.
+ * @param format The pixel format the surface should use.
*/
- void create(uint16 width, uint16 height, uint8 bytesPP);
+ void create(uint16 width, uint16 height, const PixelFormat &format);
/**
* Release the memory used by the pixels memory of this surface. This is the
diff --git a/graphics/thumbnail.cpp b/graphics/thumbnail.cpp
index fa906ca517..32ab04ed24 100644
--- a/graphics/thumbnail.cpp
+++ b/graphics/thumbnail.cpp
@@ -108,10 +108,10 @@ bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface &to) {
return false;
}
- to.create(header.width, header.height, sizeof(OverlayColor));
+ Graphics::PixelFormat format = g_system->getOverlayFormat();
+ to.create(header.width, header.height, format);
OverlayColor *pixels = (OverlayColor *)to.pixels;
- Graphics::PixelFormat format = g_system->getOverlayFormat();
for (int y = 0; y < to.h; ++y) {
for (int x = 0; x < to.w; ++x) {
uint8 r, g, b;
@@ -140,18 +140,18 @@ bool saveThumbnail(Common::WriteStream &out) {
}
bool saveThumbnail(Common::WriteStream &out, const Graphics::Surface &thumb) {
- if (thumb.bytesPerPixel != 2) {
+ if (thumb.format.bytesPerPixel != 2) {
warning("trying to save thumbnail with bpp different than 2");
return false;
}
ThumbnailHeader header;
header.type = MKTAG('T','H','M','B');
- header.size = ThumbnailHeaderSize + thumb.w*thumb.h*thumb.bytesPerPixel;
+ header.size = ThumbnailHeaderSize + thumb.w*thumb.h*thumb.format.bytesPerPixel;
header.version = THMB_VERSION;
header.width = thumb.w;
header.height = thumb.h;
- header.bpp = thumb.bytesPerPixel;
+ header.bpp = thumb.format.bytesPerPixel;
out.writeUint32BE(header.type);
out.writeUint32BE(header.size);
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 3b62d6b667..78ea43ad79 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -371,8 +371,8 @@ const char *ThemeEngine::findModeConfigName(GraphicsMode mode) {
bool ThemeEngine::init() {
// reset everything and reload the graphics
_initOk = false;
- setGraphicsMode(_graphicsMode);
_overlayFormat = _system->getOverlayFormat();
+ setGraphicsMode(_graphicsMode);
if (_screen.pixels && _backBuffer.pixels) {
_initOk = true;
@@ -497,10 +497,10 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) {
uint32 height = _system->getOverlayHeight();
_backBuffer.free();
- _backBuffer.create(width, height, _bytesPerPixel);
+ _backBuffer.create(width, height, _overlayFormat);
_screen.free();
- _screen.create(width, height, _bytesPerPixel);
+ _screen.create(width, height, _overlayFormat);
delete _vectorRenderer;
_vectorRenderer = Graphics::createRenderer(mode);
diff --git a/gui/widget.cpp b/gui/widget.cpp
index f0e91718eb..d3c8d3402d 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -347,7 +347,7 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx) {
void PicButtonWidget::drawWidget() {
g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags());
- if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) {
+ if (sizeof(OverlayColor) == _gfx.format.bytesPerPixel && _gfx.pixels) {
const int x = _x + (_w - _gfx.w) / 2;
const int y = _y + (_h - _gfx.h) / 2;
@@ -575,11 +575,12 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {
if (h == -1)
h = _h;
+ Graphics::PixelFormat overlayFormat = g_system->getOverlayFormat();
+
_gfx.free();
- _gfx.create(w, h, sizeof(OverlayColor));
+ _gfx.create(w, h, overlayFormat);
OverlayColor *dst = (OverlayColor *)_gfx.pixels;
- Graphics::PixelFormat overlayFormat = g_system->getOverlayFormat();
OverlayColor fillCol = overlayFormat.RGBToColor(r, g, b);
while (h--) {
for (int i = 0; i < w; ++i) {
@@ -589,7 +590,7 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {
}
void GraphicsWidget::drawWidget() {
- if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) {
+ if (sizeof(OverlayColor) == _gfx.format.bytesPerPixel && _gfx.pixels) {
const int x = _x + (_w - _gfx.w) / 2;
const int y = _y + (_h - _gfx.h) / 2;
diff --git a/video/codecs/cdtoons.cpp b/video/codecs/cdtoons.cpp
index f26cc35a2b..51e3c23eaa 100644
--- a/video/codecs/cdtoons.cpp
+++ b/video/codecs/cdtoons.cpp
@@ -54,7 +54,7 @@ CDToonsDecoder::CDToonsDecoder(uint16 width, uint16 height) {
debugN(5, "CDToons: width %d, height %d\n", width, height);
_surface = new Graphics::Surface();
- _surface->create(width, height, 1);
+ _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_currentPaletteId = 0;
memset(_palette, 0, 256 * 3);
diff --git a/video/codecs/cinepak.cpp b/video/codecs/cinepak.cpp
index bc73b831fe..2a782dbafe 100644
--- a/video/codecs/cinepak.cpp
+++ b/video/codecs/cinepak.cpp
@@ -95,7 +95,7 @@ const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream
if (!_curFrame.surface) {
_curFrame.surface = new Graphics::Surface();
- _curFrame.surface->create(_curFrame.width, _curFrame.height, _pixelFormat.bytesPerPixel);
+ _curFrame.surface->create(_curFrame.width, _curFrame.height, _pixelFormat);
}
// Reset the y variable.
diff --git a/video/codecs/indeo3.cpp b/video/codecs/indeo3.cpp
index c8f62d2452..b4f6c6ffe3 100644
--- a/video/codecs/indeo3.cpp
+++ b/video/codecs/indeo3.cpp
@@ -51,7 +51,7 @@ Indeo3Decoder::Indeo3Decoder(uint16 width, uint16 height) : _ModPred(0), _correc
_pixelFormat = g_system->getScreenFormat();
_surface = new Graphics::Surface;
- _surface->create(width, height, _pixelFormat.bytesPerPixel);
+ _surface->create(width, height, _pixelFormat);
buildModPred();
allocFrames();
@@ -322,10 +322,10 @@ const Graphics::Surface *Indeo3Decoder::decodeImage(Common::SeekableReadStream *
const uint32 color = _pixelFormat.RGBToColor(r, g, b);
- for (uint32 sW = 0; sW < scaleWidth; sW++, rowDest += _surface->bytesPerPixel) {
- if (_surface->bytesPerPixel == 1)
+ for (uint32 sW = 0; sW < scaleWidth; sW++, rowDest += _surface->format.bytesPerPixel) {
+ if (_surface->format.bytesPerPixel == 1)
*((uint8 *)rowDest) = (uint8)color;
- else if (_surface->bytesPerPixel == 2)
+ else if (_surface->format.bytesPerPixel == 2)
*((uint16 *)rowDest) = (uint16)color;
}
}
diff --git a/video/codecs/mjpeg.cpp b/video/codecs/mjpeg.cpp
index 2cef2b582b..2ef854039b 100644
--- a/video/codecs/mjpeg.cpp
+++ b/video/codecs/mjpeg.cpp
@@ -59,7 +59,7 @@ const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream* st
if (!_surface) {
_surface = new Graphics::Surface();
- _surface->create(_jpeg->getWidth(), _jpeg->getHeight(), _pixelFormat.bytesPerPixel);
+ _surface->create(_jpeg->getWidth(), _jpeg->getHeight(), _pixelFormat);
}
Graphics::Surface *frame = _jpeg->getSurface(_pixelFormat);
diff --git a/video/codecs/msrle.cpp b/video/codecs/msrle.cpp
index 48a17d2ac3..19309bc7aa 100644
--- a/video/codecs/msrle.cpp
+++ b/video/codecs/msrle.cpp
@@ -33,7 +33,7 @@ namespace Video {
MSRLEDecoder::MSRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) {
_surface = new Graphics::Surface();
- _surface->create(width, height, 1);
+ _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_bitsPerPixel = bitsPerPixel;
}
diff --git a/video/codecs/msvideo1.cpp b/video/codecs/msvideo1.cpp
index e173f45239..93e9aaae64 100644
--- a/video/codecs/msvideo1.cpp
+++ b/video/codecs/msvideo1.cpp
@@ -39,7 +39,8 @@ namespace Video {
MSVideo1Decoder::MSVideo1Decoder(uint16 width, uint16 height, byte bitsPerPixel) : Codec() {
_surface = new Graphics::Surface();
- _surface->create(width, height, (bitsPerPixel == 8) ? 1 : 2);
+ // TODO: Specify the correct pixel format for 2Bpp mode.
+ _surface->create(width, height, (bitsPerPixel == 8) ? Graphics::PixelFormat::createFormatCLUT8() : Graphics::PixelFormat(2, 0, 0, 0, 0, 0, 0, 0, 0));
_bitsPerPixel = bitsPerPixel;
}
diff --git a/video/codecs/qtrle.cpp b/video/codecs/qtrle.cpp
index 19835aed78..0ae27f6284 100644
--- a/video/codecs/qtrle.cpp
+++ b/video/codecs/qtrle.cpp
@@ -50,7 +50,7 @@ QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Cod
debug(2, "QTRLE corrected width: %d", width);
_surface = new Graphics::Surface();
- _surface->create(width, height, _bitsPerPixel <= 8 ? 1 : _pixelFormat.bytesPerPixel);
+ _surface->create(width, height, _bitsPerPixel <= 8 ? Graphics::PixelFormat::createFormatCLUT8() : _pixelFormat);
}
#define CHECK_STREAM_PTR(n) \
diff --git a/video/codecs/rpza.cpp b/video/codecs/rpza.cpp
index bfea88b26f..0c06661c50 100644
--- a/video/codecs/rpza.cpp
+++ b/video/codecs/rpza.cpp
@@ -46,7 +46,7 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Codec() {
debug(2, "RPZA corrected width: %d", width);
_surface = new Graphics::Surface();
- _surface->create(width, height, _pixelFormat.bytesPerPixel);
+ _surface->create(width, height, _pixelFormat);
}
RPZADecoder::~RPZADecoder() {
diff --git a/video/codecs/smc.cpp b/video/codecs/smc.cpp
index 745fdc0260..bbd6073497 100644
--- a/video/codecs/smc.cpp
+++ b/video/codecs/smc.cpp
@@ -50,7 +50,7 @@ namespace Video {
SMCDecoder::SMCDecoder(uint16 width, uint16 height) {
_surface = new Graphics::Surface();
- _surface->create(width, height, 1);
+ _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
}
SMCDecoder::~SMCDecoder() {
diff --git a/video/codecs/truemotion1.cpp b/video/codecs/truemotion1.cpp
index 577c72c133..70c456d4a8 100644
--- a/video/codecs/truemotion1.cpp
+++ b/video/codecs/truemotion1.cpp
@@ -94,7 +94,7 @@ TrueMotion1Decoder::TrueMotion1Decoder(uint16 width, uint16 height) {
_width = width;
_height = height;
- _surface->create(width, height, 2);
+ _surface->create(width, height, getPixelFormat());
// there is a vertical predictor for each pixel in a line; each vertical
// predictor is 0 to start with
diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp
index 609c8d118b..4448c9162e 100644
--- a/video/coktel_decoder.cpp
+++ b/video/coktel_decoder.cpp
@@ -99,11 +99,12 @@ void CoktelDecoder::setSurfaceMemory(void *mem, uint16 width, uint16 height, uin
assert(bpp == getPixelFormat().bytesPerPixel);
// Create a surface over this memory
- _surface.w = width;
- _surface.h = height;
- _surface.pitch = width * bpp;
- _surface.pixels = mem;
- _surface.bytesPerPixel = bpp;
+ _surface.w = width;
+ _surface.h = height;
+ _surface.pitch = width * bpp;
+ _surface.pixels = mem;
+ // TODO: Check whether it is fine to assume we want the setup PixelFormat.
+ _surface.format = getPixelFormat();
_ownSurface = false;
}
@@ -134,18 +135,18 @@ void CoktelDecoder::createSurface() {
return;
if ((_width > 0) && (_height > 0))
- _surface.create(_width, _height, getPixelFormat().bytesPerPixel);
+ _surface.create(_width, _height, getPixelFormat());
_ownSurface = true;
}
void CoktelDecoder::freeSurface() {
if (!_ownSurface) {
- _surface.w = 0;
- _surface.h = 0;
- _surface.pitch = 0;
- _surface.pixels = 0;
- _surface.bytesPerPixel = 0;
+ _surface.w = 0;
+ _surface.h = 0;
+ _surface.pitch = 0;
+ _surface.pixels = 0;
+ _surface.format = Graphics::PixelFormat();
} else
_surface.free();
@@ -456,11 +457,11 @@ void CoktelDecoder::renderBlockWhole(Graphics::Surface &dstSurf, const byte *src
rect.clip(dstSurf.w, dstSurf.h);
- byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left * dstSurf.bytesPerPixel;
+ byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left * dstSurf.format.bytesPerPixel;
for (int i = 0; i < rect.height(); i++) {
- memcpy(dst, src, rect.width() * dstSurf.bytesPerPixel);
+ memcpy(dst, src, rect.width() * dstSurf.format.bytesPerPixel);
- src += srcRect.width() * dstSurf.bytesPerPixel;
+ src += srcRect.width() * dstSurf.format.bytesPerPixel;
dst += dstSurf.pitch;
}
}
@@ -1382,12 +1383,12 @@ bool IMDDecoder::renderFrame(Common::Rect &rect) {
if ((type == 2) && (rect.width() == _surface.w) && (_x == 0)) {
// Directly uncompress onto the video surface
- const int offsetX = rect.left * _surface.bytesPerPixel;
+ const int offsetX = rect.left * _surface.format.bytesPerPixel;
const int offsetY = (_y + rect.top) * _surface.pitch;
const int offset = offsetX + offsetY;
if (deLZ77((byte *)_surface.pixels + offset, dataPtr, dataSize,
- _surface.w * _surface.h * _surface.bytesPerPixel - offset))
+ _surface.w * _surface.h * _surface.format.bytesPerPixel - offset))
return true;
}
@@ -1813,11 +1814,11 @@ bool VMDDecoder::assessVideoProperties() {
_videoBuffer[i] = new byte[_videoBufferSize];
memset(_videoBuffer[i], 0, _videoBufferSize);
- _8bppSurface[i].w = _width * _bytesPerPixel;
- _8bppSurface[i].h = _height;
- _8bppSurface[i].pitch = _width * _bytesPerPixel;
- _8bppSurface[i].pixels = _videoBuffer[i];
- _8bppSurface[i].bytesPerPixel = 1;
+ _8bppSurface[i].w = _width * _bytesPerPixel;
+ _8bppSurface[i].h = _height;
+ _8bppSurface[i].pitch = _width * _bytesPerPixel;
+ _8bppSurface[i].pixels = _videoBuffer[i];
+ _8bppSurface[i].format = Graphics::PixelFormat::createFormatCLUT8();
}
}
@@ -2230,12 +2231,12 @@ bool VMDDecoder::renderFrame(Common::Rect &rect) {
if ((type == 2) && (rect.width() == _surface.w) && (_x == 0) && (_blitMode == 0)) {
// Directly uncompress onto the video surface
- const int offsetX = rect.left * _surface.bytesPerPixel;
+ const int offsetX = rect.left * _surface.format.bytesPerPixel;
const int offsetY = (_y + rect.top) * _surface.pitch;
const int offset = offsetX - offsetY;
if (deLZ77((byte *)_surface.pixels + offset, dataPtr, dataSize,
- _surface.w * _surface.h * _surface.bytesPerPixel - offset))
+ _surface.w * _surface.h * _surface.format.bytesPerPixel - offset))
return true;
}
@@ -2345,13 +2346,13 @@ void VMDDecoder::blit16(const Graphics::Surface &srcSurf, Common::Rect &rect) {
const byte *src = (byte *)srcSurf.pixels +
(srcRect.top * srcSurf.pitch) + srcRect.left * _bytesPerPixel;
byte *dst = (byte *)_surface.pixels +
- ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.bytesPerPixel;
+ ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.format.bytesPerPixel;
for (int i = 0; i < rect.height(); i++) {
const byte *srcRow = src;
byte *dstRow = dst;
- for (int j = 0; j < rect.width(); j++, srcRow += 2, dstRow += _surface.bytesPerPixel) {
+ for (int j = 0; j < rect.width(); j++, srcRow += 2, dstRow += _surface.format.bytesPerPixel) {
uint16 data = READ_LE_UINT16(srcRow);
byte r = ((data & 0x7C00) >> 10) << 3;
@@ -2362,7 +2363,7 @@ void VMDDecoder::blit16(const Graphics::Surface &srcSurf, Common::Rect &rect) {
if ((r == 0) && (g == 0) && (b == 0))
c = 0;
- if (_surface.bytesPerPixel == 2)
+ if (_surface.format.bytesPerPixel == 2)
*((uint16 *)dstRow) = (uint16) c;
}
@@ -2383,13 +2384,13 @@ void VMDDecoder::blit24(const Graphics::Surface &srcSurf, Common::Rect &rect) {
const byte *src = (byte *)srcSurf.pixels +
(srcRect.top * srcSurf.pitch) + srcRect.left * _bytesPerPixel;
byte *dst = (byte *)_surface.pixels +
- ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.bytesPerPixel;
+ ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.format.bytesPerPixel;
for (int i = 0; i < rect.height(); i++) {
const byte *srcRow = src;
byte *dstRow = dst;
- for (int j = 0; j < rect.width(); j++, srcRow += 3, dstRow += _surface.bytesPerPixel) {
+ for (int j = 0; j < rect.width(); j++, srcRow += 3, dstRow += _surface.format.bytesPerPixel) {
byte r = srcRow[2];
byte g = srcRow[1];
byte b = srcRow[0];
@@ -2398,7 +2399,7 @@ void VMDDecoder::blit24(const Graphics::Surface &srcSurf, Common::Rect &rect) {
if ((r == 0) && (g == 0) && (b == 0))
c = 0;
- if (_surface.bytesPerPixel == 2)
+ if (_surface.format.bytesPerPixel == 2)
*((uint16 *)dstRow) = (uint16) c;
}
diff --git a/video/dxa_decoder.cpp b/video/dxa_decoder.cpp
index 3fb0a81acb..9e3f59705c 100644
--- a/video/dxa_decoder.cpp
+++ b/video/dxa_decoder.cpp
@@ -102,7 +102,7 @@ bool DXADecoder::loadStream(Common::SeekableReadStream *stream) {
}
_surface = new Graphics::Surface();
- _surface->bytesPerPixel = 1;
+ _surface->format = Graphics::PixelFormat::createFormatCLUT8();
debug(2, "flags 0x0%x framesCount %d width %d height %d rate %d", flags, getFrameCount(), getWidth(), getHeight(), getFrameRate().toInt());
diff --git a/video/flic_decoder.cpp b/video/flic_decoder.cpp
index adceb4565f..47a9244a13 100644
--- a/video/flic_decoder.cpp
+++ b/video/flic_decoder.cpp
@@ -80,7 +80,7 @@ bool FlicDecoder::loadStream(Common::SeekableReadStream *stream) {
_offsetFrame2 = _fileStream->readUint32LE();
_surface = new Graphics::Surface();
- _surface->create(width, height, 1);
+ _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_palette = (byte *)malloc(3 * 256);
memset(_palette, 0, 3 * 256);
_paletteChanged = false;
@@ -227,7 +227,7 @@ const Graphics::Surface *FlicDecoder::decodeNextFrame() {
_surface->free();
delete _surface;
_surface = new Graphics::Surface();
- _surface->create(newWidth, newHeight, 1);
+ _surface->create(newWidth, newHeight, Graphics::PixelFormat::createFormatCLUT8());
}
}
break;
diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp
index 9e125fe99b..d455b13b64 100644
--- a/video/qt_decoder.cpp
+++ b/video/qt_decoder.cpp
@@ -393,7 +393,7 @@ const Graphics::Surface *QuickTimeDecoder::scaleSurface(const Graphics::Surface
for (int32 j = 0; j < _scaledSurface->h; j++)
for (int32 k = 0; k < _scaledSurface->w; k++)
- memcpy(_scaledSurface->getBasePtr(k, j), frame->getBasePtr((k * getScaleFactorX()).toInt() , (j * getScaleFactorY()).toInt()), frame->bytesPerPixel);
+ memcpy(_scaledSurface->getBasePtr(k, j), frame->getBasePtr((k * getScaleFactorX()).toInt() , (j * getScaleFactorY()).toInt()), frame->format.bytesPerPixel);
return _scaledSurface;
}
@@ -538,7 +538,7 @@ void QuickTimeDecoder::init() {
if (getScaleFactorX() != 1 || getScaleFactorY() != 1) {
// We have to initialize the scaled surface
_scaledSurface = new Graphics::Surface();
- _scaledSurface->create(getWidth(), getHeight(), getPixelFormat().bytesPerPixel);
+ _scaledSurface->create(getWidth(), getHeight(), getPixelFormat());
}
}
}
diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp
index d25e055235..7a95eedf6a 100644
--- a/video/smk_decoder.cpp
+++ b/video/smk_decoder.cpp
@@ -483,7 +483,7 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
_surface = new Graphics::Surface();
// Height needs to be doubled if we have flags (Y-interlaced or Y-doubled)
- _surface->create(width, height * (_header.flags ? 2 : 1), 1);
+ _surface->create(width, height * (_header.flags ? 2 : 1), Graphics::PixelFormat::createFormatCLUT8());
memset(_palette, 0, 3 * 256);
return true;