aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sword25/gfx/image/vectorimage.cpp68
-rw-r--r--engines/sword25/gfx/image/vectorimage.h2
-rw-r--r--engines/sword25/gfx/image/vectorimagerenderer.cpp21
3 files changed, 40 insertions, 51 deletions
diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp
index 42cac1aaa1..70e162eae2 100644
--- a/engines/sword25/gfx/image/vectorimage.cpp
+++ b/engines/sword25/gfx/image/vectorimage.cpp
@@ -186,18 +186,6 @@ Common::Rect flashRectToBSRect(VectorImage::SWFBitStream &bs) {
return Common::Rect(xMin, yMin, xMax + 1, yMax + 1);
}
-
-// -----------------------------------------------------------------------------
-// Konvertiert SWF-Farben in AntiGrain Farben
-// -----------------------------------------------------------------------------
-
-uint32 flashColorToAGGRGBA8(uint flashColor) {
- uint32 resultColor = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(flashColor >> 24, (flashColor >> 16) & 0xff, (flashColor >> 8) & 0xff, flashColor & 0xff);
-
- return resultColor;
-}
-
-
// -----------------------------------------------------------------------------
// Berechnet die Bounding-Box eines BS_VectorImageElement
// -----------------------------------------------------------------------------
@@ -343,8 +331,6 @@ ArtBpath *VectorImage::storeBez(ArtBpath *bez, int lineStyle, int fillStyle0, in
return bez;
}
-#define SWF_SCALE_FACTOR (1/20.0)
-
bool VectorImage::parseDefineShape(uint shapeType, SWFBitStream &bs) {
/*uint32 shapeID = */bs.getUInt16();
@@ -393,8 +379,8 @@ bool VectorImage::parseDefineShape(uint shapeType, SWFBitStream &bs) {
} else {
if (stateMoveTo) {
uint32 moveToBits = bs.getBits(5);
- curX = bs.getSignedBits(moveToBits) * SWF_SCALE_FACTOR;
- curY = bs.getSignedBits(moveToBits) * SWF_SCALE_FACTOR;
+ curX = bs.getSignedBits(moveToBits);
+ curY = bs.getSignedBits(moveToBits);
}
if (stateFillStyle0) {
@@ -448,10 +434,10 @@ bool VectorImage::parseDefineShape(uint shapeType, SWFBitStream &bs) {
// Curved edge
if (edgeFlag == 0) {
- double controlDeltaX = bs.getSignedBits(numBits) * SWF_SCALE_FACTOR;
- double controlDeltaY = bs.getSignedBits(numBits) * SWF_SCALE_FACTOR;
- double anchorDeltaX = bs.getSignedBits(numBits) * SWF_SCALE_FACTOR;
- double anchorDeltaY = bs.getSignedBits(numBits) * SWF_SCALE_FACTOR;
+ double controlDeltaX = bs.getSignedBits(numBits);
+ double controlDeltaY = bs.getSignedBits(numBits);
+ double anchorDeltaX = bs.getSignedBits(numBits);
+ double anchorDeltaY = bs.getSignedBits(numBits);
double newX = curX + controlDeltaX;
double newY = curY + controlDeltaY;
@@ -489,8 +475,8 @@ bool VectorImage::parseDefineShape(uint shapeType, SWFBitStream &bs) {
deltaX = bs.getSignedBits(numBits);
}
- curX += deltaX * SWF_SCALE_FACTOR;
- curY += deltaY * SWF_SCALE_FACTOR;
+ curX += deltaX;
+ curY += deltaY;
bezNodes++;
bez = ensureBezStorage(bez, bezNodes, &bezAllocated);
@@ -535,14 +521,20 @@ bool VectorImage::parseStyles(uint shapeType, SWFBitStream &bs, uint &numFillBit
for (uint i = 0; i < fillStyleCount; ++i) {
byte type = bs.getByte();
uint32 color;
- if (shapeType == 3) {
- color = (bs.getByte() << 16) | (bs.getByte() << 8) | bs.getByte() | (bs.getByte() << 24);
- } else
- color = bs.getBits(24) | (0xff << 24);
+ byte r = bs.getByte();
+ byte g = bs.getByte();
+ byte b = bs.getByte();
+ byte a = 0xff;
+
+ if (shapeType == 3)
+ a = bs.getByte();
+
+ color = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(a, r, g, b);
+
if (type != 0)
return false;
- _elements.back()._fillStyles.push_back(flashColorToAGGRGBA8(color));
+ _elements.back()._fillStyles.push_back(color);
}
// Linestyles parsen
@@ -558,12 +550,18 @@ bool VectorImage::parseStyles(uint shapeType, SWFBitStream &bs, uint &numFillBit
for (uint i = 0; i < lineStyleCount; ++i) {
double width = bs.getUInt16();
uint32 color;
+ byte r = bs.getByte();
+ byte g = bs.getByte();
+ byte b = bs.getByte();
+ byte a = 0xff;
+
if (shapeType == 3)
- color = (bs.getByte() << 16) | (bs.getByte() << 8) | bs.getByte() | (bs.getByte() << 24);
- else
- color = bs.getBits(24) | (0xff << 24);
+ a = bs.getByte();
+
+ color = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(a, r, g, b);
- _elements.back()._lineStyles.push_back(VectorImageElement::LineStyleType(width, flashColorToAGGRGBA8(color)));
+ debug(0, "color: %08x", color);
+ _elements.back()._lineStyles.push_back(VectorImageElement::LineStyleType(width, color));
}
// Bitbreite für die folgenden Styleindizes auslesen
@@ -611,13 +609,7 @@ bool VectorImage::blit(int posX, int posY,
// Feststellen, ob das alte Bild im Cache nicht wiederbenutzt werden kann und neu Berechnet werden muss
if (!(oldThis == this && oldWidth == width && oldHeight == height)) {
- float ScaleFactorX = (width == - 1) ? 1 : static_cast<float>(width) / static_cast<float>(getWidth());
- float ScaleFactorY = (height == - 1) ? 1 : static_cast<float>(height) / static_cast<float>(getHeight());
-
- uint RenderedWidth;
- uint RenderedHeight;
-
- render(ScaleFactorX, ScaleFactorY, RenderedWidth, RenderedHeight);
+ render(width, height);
oldThis = this;
oldHeight = height;
diff --git a/engines/sword25/gfx/image/vectorimage.h b/engines/sword25/gfx/image/vectorimage.h
index d4cbfece7c..ea9948fec7 100644
--- a/engines/sword25/gfx/image/vectorimage.h
+++ b/engines/sword25/gfx/image/vectorimage.h
@@ -182,7 +182,7 @@ public:
}
virtual bool fill(const Common::Rect *pFillRect = 0, uint color = BS_RGB(0, 0, 0));
- void render(float scaleFactorX, float scaleFactorY, uint &width, uint &height);
+ void render(int width, int height);
virtual uint getPixel(int x, int y);
virtual bool isBlitSource() const {
diff --git a/engines/sword25/gfx/image/vectorimagerenderer.cpp b/engines/sword25/gfx/image/vectorimagerenderer.cpp
index a4c33bc777..8ba65dd1e1 100644
--- a/engines/sword25/gfx/image/vectorimagerenderer.cpp
+++ b/engines/sword25/gfx/image/vectorimagerenderer.cpp
@@ -40,6 +40,7 @@
#include <libart_lgpl/art_rgb.h>
#include "sword25/gfx/image/vectorimage.h"
+#include "graphics/colormasks.h"
namespace Sword25 {
@@ -50,9 +51,8 @@ art_rgb_fill_run1(art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int n) {
if (r == g && g == b && r == 255) {
memset(buf, g, n + n + n + n);
} else {
- art_u32 *alt = (art_u32 *)buf;
- //art_u32 color = (r << 24) | (g << 16) | (b << 8) | 0xff;
- art_u32 color = (r << 0) | (g << 8) | (b << 16) | (0xff << 24);
+ uint32 *alt = (uint32 *)buf;
+ uint32 color = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(0xff, r, g, b);
for (i = 0; i < n; i++)
*alt++ = color;
}
@@ -215,18 +215,15 @@ art_rgb_svp_alpha_opaque_callback1(void *callback_data, int y,
void
art_rgb_svp_alpha1(const ArtSVP *svp,
int x0, int y0, int x1, int y1,
- art_u32 rgba,
+ uint32 color,
art_u8 *buf, int rowstride,
ArtAlphaGamma *alphagamma) {
ArtRgbSVPAlphaData data;
- int r, g, b, alpha;
+ byte r, g, b, alpha;
int i;
int a, da;
- r = rgba >> 24;
- g = (rgba >> 16) & 0xff;
- b = (rgba >> 8) & 0xff;
- alpha = rgba & 0xff;
+ Graphics::colorToARGB<Graphics::ColorMasks<8888> >(color, alpha, r, g, b);
data.r = r;
data.g = g;
@@ -251,9 +248,9 @@ art_rgb_svp_alpha1(const ArtSVP *svp,
art_svp_render_aa(svp, x0, y0, x1, y1, art_rgb_svp_alpha_callback1, &data);
}
-void VectorImage::render(float scaleFactorX, float scaleFactorY, uint &width, uint &height) {
- width = static_cast<uint>(getWidth() * scaleFactorX);
- height = static_cast<uint>(getHeight() * scaleFactorY);
+void VectorImage::render(int width, int height) {
+ float scaleFactorX = (width == - 1) ? 1 : static_cast<float>(width) / static_cast<float>(getWidth());
+ float scaleFactorY = (height == - 1) ? 1 : static_cast<float>(height) / static_cast<float>(getHeight());
if (_pixelData)
free(_pixelData);