diff options
author | Littleboy | 2011-05-02 17:18:22 -0400 |
---|---|---|
committer | Littleboy | 2011-05-02 17:21:10 -0400 |
commit | 0e45aa8655dc3122e8d88dbcb67ab2013a292989 (patch) | |
tree | f523e5c1870497528d85385ce5ef24259937813c /graphics | |
parent | 580986aa42889c9a775b3ebe5709292d779f41cf (diff) | |
parent | 1aff380a15f12e53bd380fc2a189882e2d6172c0 (diff) | |
download | scummvm-rg350-0e45aa8655dc3122e8d88dbcb67ab2013a292989.tar.gz scummvm-rg350-0e45aa8655dc3122e8d88dbcb67ab2013a292989.tar.bz2 scummvm-rg350-0e45aa8655dc3122e8d88dbcb67ab2013a292989.zip |
Merge remote-tracking branch 'upstream/master' into nsis
Conflicts:
devtools/create_project/scripts/postbuild.cmd
devtools/create_project/visualstudio.cpp
ports.mk
Diffstat (limited to 'graphics')
32 files changed, 183 insertions, 154 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index 0237712f13..e3ca0bf588 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -23,14 +23,9 @@ * */ +#include "common/textconsole.h" #include "common/util.h" -#include "common/system.h" -#include "common/events.h" -#include "graphics/surface.h" -#include "graphics/colormasks.h" - -#include "gui/ThemeEngine.h" #include "graphics/VectorRenderer.h" #define VECTOR_RENDERER_FAST_TRIANGLES diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 0a783a077d..9285fa21c5 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -26,16 +26,19 @@ #ifndef VECTOR_RENDERER_H #define VECTOR_RENDERER_H +#include "common/rect.h" #include "common/scummsys.h" -#include "common/system.h" +#include "common/str.h" #include "graphics/surface.h" -#include "graphics/pixelformat.h" #include "gui/ThemeEngine.h" +class OSystem; + namespace Graphics { class VectorRenderer; +struct DrawStep; typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &); diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 0ee13033af..3eb8b1345f 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -25,7 +25,6 @@ #include "common/util.h" #include "common/system.h" -#include "common/events.h" #include "common/frac.h" #include "graphics/surface.h" @@ -277,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() ); } @@ -337,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; @@ -485,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 @@ -733,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); @@ -831,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); @@ -876,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) { @@ -908,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); @@ -965,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; @@ -1013,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) { @@ -1094,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); @@ -1143,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); @@ -1234,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) { @@ -1284,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; @@ -1321,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; @@ -1368,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; @@ -1438,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; @@ -1489,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; @@ -1566,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/conversion.cpp b/graphics/conversion.cpp index fee4b05f66..c9679432fa 100644 --- a/graphics/conversion.cpp +++ b/graphics/conversion.cpp @@ -23,6 +23,7 @@ */ #include "graphics/conversion.h" +#include "graphics/pixelformat.h" namespace Graphics { diff --git a/graphics/conversion.h b/graphics/conversion.h index b6d230612e..2759f3bb5e 100644 --- a/graphics/conversion.h +++ b/graphics/conversion.h @@ -27,10 +27,11 @@ #define GRAPHICS_CONVERSION_H #include "common/util.h" -#include "graphics/pixelformat.h" namespace Graphics { +struct PixelFormat; + /** Converting a color from YUV to RGB colorspace. */ inline static void YUV2RGB(byte y, byte u, byte v, byte &r, byte &g, byte &b) { r = CLIP<int>(y + ((1357 * (v - 128)) >> 10), 0, 255); diff --git a/graphics/font.cpp b/graphics/font.cpp index 359374436c..7fa39d07db 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -25,7 +25,11 @@ #include "common/stream.h" #include "common/file.h" #include "common/endian.h" +#include "common/array.h" +#include "common/textconsole.h" +#include "common/util.h" #include "graphics/font.h" +#include "graphics/surface.h" namespace Graphics { @@ -74,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) { @@ -106,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/font.h b/graphics/font.h index b1a4735249..9e6e180ec3 100644 --- a/graphics/font.h +++ b/graphics/font.h @@ -26,15 +26,16 @@ #define GRAPHICS_FONT_H #include "common/str.h" -#include "common/array.h" -#include "graphics/surface.h" namespace Common { class SeekableReadStream; +template<class T> class Array; } namespace Graphics { +struct Surface; + /** Text alignment modes */ enum TextAlign { kTextAlignInvalid, diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index 35ea14b199..bbd75bfca2 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -22,6 +22,7 @@ * $Id$ */ +#include "graphics/font.h" #include "graphics/fontman.h" DECLARE_SINGLETON(Graphics::FontManager); diff --git a/graphics/fontman.h b/graphics/fontman.h index 7871f32ba9..34b457ae83 100644 --- a/graphics/fontman.h +++ b/graphics/fontman.h @@ -30,11 +30,12 @@ #include "common/str.h" #include "common/hashmap.h" #include "common/hash-str.h" -#include "graphics/font.h" namespace Graphics { +class Font; + class FontManager : public Common::Singleton<FontManager> { public: enum FontUsage { diff --git a/graphics/fonts/scummfont.cpp b/graphics/fonts/scummfont.cpp index 87078e1475..3331b72c47 100644 --- a/graphics/fonts/scummfont.cpp +++ b/graphics/fonts/scummfont.cpp @@ -23,6 +23,7 @@ */ #include "graphics/font.h" +#include "graphics/surface.h" namespace Graphics { @@ -302,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 12509fd9e1..7db9a233f6 100644 --- a/graphics/fonts/winfont.cpp +++ b/graphics/fonts/winfont.cpp @@ -24,8 +24,11 @@ #include "common/file.h" #include "common/str.h" +#include "common/stream.h" +#include "common/textconsole.h" #include "common/winexe_ne.h" #include "common/winexe_pe.h" +#include "graphics/surface.h" #include "graphics/fonts/winfont.h" namespace Graphics { @@ -320,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)]; @@ -328,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/fonts/winfont.h b/graphics/fonts/winfont.h index fbe4a778e2..c31d45e2ce 100644 --- a/graphics/fonts/winfont.h +++ b/graphics/fonts/winfont.h @@ -25,11 +25,11 @@ #ifndef GRAPHICS_WINFONT_H #define GRAPHICS_WINFONT_H +#include "common/str.h" #include "graphics/font.h" namespace Common { - class SeekableReadStream; - class String; +class SeekableReadStream; } namespace Graphics { diff --git a/graphics/iff.cpp b/graphics/iff.cpp index 2174291112..fee71de485 100644 --- a/graphics/iff.cpp +++ b/graphics/iff.cpp @@ -25,6 +25,10 @@ #include "graphics/iff.h" #include "graphics/surface.h" +#include "common/endian.h" +#include "common/func.h" +#include "common/iff_container.h" +#include "common/textconsole.h" #include "common/util.h" namespace Graphics { @@ -204,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/iff.h b/graphics/iff.h index 0aab0e09cb..fc837a3ea2 100644 --- a/graphics/iff.h +++ b/graphics/iff.h @@ -31,7 +31,7 @@ #ifndef GRAPHICS_IFF_H #define GRAPHICS_IFF_H -#include "common/iff_container.h" +#include "common/stream.h" namespace Graphics { diff --git a/graphics/imagedec.cpp b/graphics/imagedec.cpp index a4d2fbc1cf..f45f0ce5ef 100644 --- a/graphics/imagedec.cpp +++ b/graphics/imagedec.cpp @@ -23,6 +23,7 @@ */ #include "graphics/imagedec.h" +#include "graphics/pixelformat.h" #include "graphics/surface.h" #include "common/file.h" @@ -117,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/imagedec.h b/graphics/imagedec.h index 13aa63a153..7ea987b1e4 100644 --- a/graphics/imagedec.h +++ b/graphics/imagedec.h @@ -28,14 +28,13 @@ #include "common/scummsys.h" #include "common/str.h" -#include "graphics/pixelformat.h" - namespace Common{ class SeekableReadStream; } namespace Graphics { +struct PixelFormat; struct Surface; class ImageDecoder { diff --git a/graphics/jpeg.cpp b/graphics/jpeg.cpp index 169c3b5f1b..70ffb06f6b 100644 --- a/graphics/jpeg.cpp +++ b/graphics/jpeg.cpp @@ -27,9 +27,10 @@ #include "graphics/jpeg.h" #include "graphics/pixelformat.h" +#include "common/debug.h" #include "common/endian.h" -#include "common/util.h" #include "common/stream.h" +#include "common/textconsole.h" namespace Graphics { @@ -95,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++) { @@ -443,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; @@ -710,9 +711,9 @@ uint8 JPEG::readBit() { if (byte2 == 0xDC) { // DNL marker: Define Number of Lines // TODO: terminate scan - printf("DNL marker detected: terminate scan\n"); + warning("DNL marker detected: terminate scan"); } else { - printf("Error: marker 0x%02X read in entropy data\n", byte2); + warning("Error: marker 0x%02X read in entropy data", byte2); } } } diff --git a/graphics/palette.h b/graphics/palette.h index 8d7fdbd99a..14e433f153 100644 --- a/graphics/palette.h +++ b/graphics/palette.h @@ -26,6 +26,7 @@ #ifndef GRAPHICS_PALETTE_H #define GRAPHICS_PALETTE_H +#include "common/scummsys.h" #include "common/noncopyable.h" /** diff --git a/graphics/pict.cpp b/graphics/pict.cpp index ca4aac751d..acade48515 100644 --- a/graphics/pict.cpp +++ b/graphics/pict.cpp @@ -23,9 +23,12 @@ * */ +#include "common/debug.h" +#include "common/endian.h" +#include "common/stream.h" #include "common/substream.h" +#include "common/textconsole.h" -#include "graphics/conversion.h" #include "graphics/jpeg.h" #include "graphics/pict.h" #include "graphics/surface.h" @@ -209,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/pict.h b/graphics/pict.h index a683a23bf6..22f36aafe7 100644 --- a/graphics/pict.h +++ b/graphics/pict.h @@ -32,7 +32,7 @@ #include "graphics/pixelformat.h" namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Graphics { diff --git a/graphics/png.cpp b/graphics/png.cpp index b256c87cf5..3cdb9f7cca 100644 --- a/graphics/png.cpp +++ b/graphics/png.cpp @@ -23,13 +23,14 @@ * */ -#include "graphics/conversion.h" #include "graphics/png.h" #include "graphics/pixelformat.h" +#include "graphics/surface.h" #include "common/endian.h" #include "common/memstream.h" #include "common/stream.h" +#include "common/types.h" #include "common/util.h" #include "common/zlib.h" @@ -112,60 +113,62 @@ 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"); } for (uint16 i = 0; i < output->h; i++) { for (uint16 j = 0; j < output->w; j++) { - if (format.bytesPerPixel == 2) { - if (_unfilteredSurface->bytesPerPixel == 1) { // Grayscale + if (format.bytesPerPixel == 2) { // 2bpp + uint16 *dest = ((uint16 *)output->getBasePtr(j, i)); + if (_unfilteredSurface->format.bytesPerPixel == 1) { // Grayscale if (_transparentColorSpecified) a = (src[0] == _transparentColor[0]) ? 0 : 0xFF; - *((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor( a, src[0], src[0], src[0]); - } else if (_unfilteredSurface->bytesPerPixel == 2) { // Grayscale + alpha - *((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[1], src[0], src[0], src[0]); - } else if (_unfilteredSurface->bytesPerPixel == 3) { // RGB + *dest = format.ARGBToColor( a, src[0], src[0], src[0]); + } else if (_unfilteredSurface->format.bytesPerPixel == 2) { // Grayscale + alpha + *dest = format.ARGBToColor(src[1], src[0], src[0], src[0]); + } else if (_unfilteredSurface->format.bytesPerPixel == 3) { // RGB if (_transparentColorSpecified) { bool isTransparentColor = (src[0] == _transparentColor[0] && src[1] == _transparentColor[1] && src[2] == _transparentColor[2]); a = isTransparentColor ? 0 : 0xFF; } - *((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor( a, src[0], src[1], src[2]); - } else if (_unfilteredSurface->bytesPerPixel == 4) { // RGBA - *((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[3], src[0], src[1], src[2]); + *dest = format.ARGBToColor( a, src[0], src[1], src[2]); + } else if (_unfilteredSurface->format.bytesPerPixel == 4) { // RGBA + *dest = format.ARGBToColor(src[3], src[0], src[1], src[2]); } - } else { - if (_unfilteredSurface->bytesPerPixel == 1) { // Grayscale + } else { // 4bpp + uint32 *dest = ((uint32 *)output->getBasePtr(j, i)); + if (_unfilteredSurface->format.bytesPerPixel == 1) { // Grayscale if (_transparentColorSpecified) a = (src[0] == _transparentColor[0]) ? 0 : 0xFF; - *((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor( a, src[0], src[0], src[0]); - } else if (_unfilteredSurface->bytesPerPixel == 2) { // Grayscale + alpha - *((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[1], src[0], src[0], src[0]); - } else if (_unfilteredSurface->bytesPerPixel == 3) { // RGB + *dest = format.ARGBToColor( a, src[0], src[0], src[0]); + } else if (_unfilteredSurface->format.bytesPerPixel == 2) { // Grayscale + alpha + *dest = format.ARGBToColor(src[1], src[0], src[0], src[0]); + } else if (_unfilteredSurface->format.bytesPerPixel == 3) { // RGB if (_transparentColorSpecified) { bool isTransparentColor = (src[0] == _transparentColor[0] && src[1] == _transparentColor[1] && src[2] == _transparentColor[2]); a = isTransparentColor ? 0 : 0xFF; } - *((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor( a, src[0], src[1], src[2]); - } else if (_unfilteredSurface->bytesPerPixel == 4) { // RGBA - *((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[3], src[0], src[1], src[2]); + *dest = format.ARGBToColor( a, src[0], src[1], src[2]); + } 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 { @@ -388,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); @@ -397,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/png.h b/graphics/png.h index 00c084da8e..21e0f35be1 100644 --- a/graphics/png.h +++ b/graphics/png.h @@ -31,8 +31,6 @@ #ifndef GRAPHICS_PNG_H #define GRAPHICS_PNG_H -#include "graphics/surface.h" - // PNG decoder, based on the W3C specs: // http://www.w3.org/TR/PNG/ // Parts of the code have been adapted from LodePNG, by Lode Vandevenne: @@ -54,12 +52,17 @@ // is a bit unclear. For now, these won't be supported, until a suitable sample // is found. +#include "common/scummsys.h" +#include "common/textconsole.h" + namespace Common { class SeekableReadStream; } namespace Graphics { +struct Surface; + enum PNGColorType { kGrayScale = 0, // bit depths: 1, 2, 4, 8, 16 kTrueColor = 2, // bit depths: 8, 16 @@ -117,18 +120,18 @@ public: } /** - * Returns the palette of the specified PNG8 image. - * - * Note that the palette's format is RGBA. + * Returns the palette of the specified PNG8 image, given a pointer to + * an RGBA palette array (4 x 256). */ - void getPalette(byte *&palette, uint16 &entries) { + void getPalette(byte *palette, uint16 &entries) { if (_header.colorType != kIndexed) error("Palette requested for a non-indexed PNG"); - // TODO: It might be that this should really return a copy of the - // palette, but since the implementation was like this I changed - // the palette pointer to be a reference instead of a value copy. - // Someone should check this code and verify this is as intended. - palette = _palette; + for (int i = 0; i < 256; i++) { + palette[0 + i * 4] = _palette[0 + i * 4]; // R + palette[1 + i * 4] = _palette[1 + i * 4]; // G + palette[2 + i * 4] = _palette[2 + i * 4]; // B + palette[3 + i * 4] = _palette[3 + i * 4]; // A + } entries = _paletteEntries; } diff --git a/graphics/scaler/scale2x.cpp b/graphics/scaler/scale2x.cpp index deae44c1c7..ec2aa2086e 100644 --- a/graphics/scaler/scale2x.cpp +++ b/graphics/scaler/scale2x.cpp @@ -34,7 +34,6 @@ #include "common/scummsys.h" -#include "graphics/scaler/intern.h" #include "graphics/scaler/scale2x.h" /***************************************************************************/ diff --git a/graphics/scaler/scale3x.cpp b/graphics/scaler/scale3x.cpp index 4e78796ee7..788c8694c5 100644 --- a/graphics/scaler/scale3x.cpp +++ b/graphics/scaler/scale3x.cpp @@ -34,7 +34,6 @@ #include "common/scummsys.h" -#include "graphics/scaler/intern.h" #include "graphics/scaler/scale3x.h" /***************************************************************************/ diff --git a/graphics/scaler/scalebit.cpp b/graphics/scaler/scalebit.cpp index 706fea8f05..c6d2a0d752 100644 --- a/graphics/scaler/scalebit.cpp +++ b/graphics/scaler/scalebit.cpp @@ -35,7 +35,6 @@ #include "common/scummsys.h" -#include "graphics/scaler/intern.h" #include "graphics/scaler/scale2x.h" #include "graphics/scaler/scale3x.h" diff --git a/graphics/scaler/thumbnail_intern.cpp b/graphics/scaler/thumbnail_intern.cpp index 5cee1c7a72..d78648c325 100644 --- a/graphics/scaler/thumbnail_intern.cpp +++ b/graphics/scaler/thumbnail_intern.cpp @@ -30,6 +30,7 @@ #include "graphics/colormasks.h" #include "graphics/scaler.h" #include "graphics/scaler/intern.h" +#include "graphics/palette.h" template<int bitFormat> uint16 quadBlockInterpolate(const uint8 *src, uint32 srcPitch) { @@ -99,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) { @@ -146,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); @@ -171,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; } @@ -190,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; @@ -200,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(); @@ -223,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 c581f9b265..caa53a4f63 100644 --- a/graphics/sjis.cpp +++ b/graphics/sjis.cpp @@ -31,6 +31,7 @@ #include "common/archive.h" #include "common/endian.h" #include "common/stream.h" +#include "common/textconsole.h" #include "graphics/surface.h" @@ -57,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 f06c24c2cd..88bdcfc822 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -24,7 +24,8 @@ #include "common/algorithm.h" #include "common/util.h" -#include "common/endian.h" +#include "common/rect.h" +#include "common/textconsole.h" #include "graphics/primitives.h" #include "graphics/surface.h" @@ -40,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); } @@ -64,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); } @@ -88,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 { @@ -112,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; @@ -140,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"); } @@ -157,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); @@ -185,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; @@ -215,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 f9cb6cc474..1b54690aa9 100644 --- a/graphics/surface.h +++ b/graphics/surface.h @@ -26,7 +26,12 @@ #define GRAPHICS_SURFACE_H #include "common/scummsys.h" -#include "common/rect.h" + +namespace Common { +struct Rect; +} + +#include "graphics/pixelformat.h" namespace Graphics { @@ -65,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() { } /** @@ -83,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; } /** @@ -94,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; } /** @@ -105,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 8688096c3d..32ab04ed24 100644 --- a/graphics/thumbnail.cpp +++ b/graphics/thumbnail.cpp @@ -28,6 +28,7 @@ #include "common/endian.h" #include "common/system.h" #include "common/stream.h" +#include "common/textconsole.h" namespace Graphics { @@ -107,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; @@ -139,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/graphics/wincursor.cpp b/graphics/wincursor.cpp index 10939a677a..bae64f9303 100644 --- a/graphics/wincursor.cpp +++ b/graphics/wincursor.cpp @@ -23,12 +23,9 @@ * */ -#include "common/debug.h" -#include "common/file.h" -#include "common/memstream.h" #include "common/ptr.h" -#include "common/str.h" #include "common/stream.h" +#include "common/textconsole.h" #include "common/winexe_ne.h" #include "common/winexe_pe.h" diff --git a/graphics/wincursor.h b/graphics/wincursor.h index ca0abf6fe1..717a1be588 100644 --- a/graphics/wincursor.h +++ b/graphics/wincursor.h @@ -30,9 +30,9 @@ #include "common/winexe.h" namespace Common { - class NEResources; - class PEResources; - class SeekableReadStream; +class NEResources; +class PEResources; +class SeekableReadStream; } namespace Graphics { |