Browse Source

pcx_render: Fix line skipping for odd widths (#4828)

When line skipping PCX sprites with odd widths, skip the padding pixel
as well.
pull/4832/head^2
Gleb Mazovetskiy 4 years ago committed by GitHub
parent
commit
bd66e7d6d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      Source/engine/render/pcx_render.cpp

14
Source/engine/render/pcx_render.cpp

@ -28,17 +28,15 @@ const uint8_t *SkipRestOfPcxLine(const uint8_t *src, unsigned remainingWidth)
template <bool UseColorMap, bool HasTransparency>
void BlitPcxClipY(const Surface &out, Point position, const uint8_t *src, unsigned srcWidth, unsigned srcHeight, const uint8_t *colorMap, uint8_t transparentColor)
{
if (position.y >= out.h())
return;
const unsigned srcSkip = srcWidth % 2;
while (position.y < 0 && srcHeight != 0) {
src = SkipRestOfPcxLine(src, srcWidth);
src = SkipRestOfPcxLine(src, srcWidth) + srcSkip;
++position.y;
--srcHeight;
}
srcHeight = static_cast<unsigned>(std::min<int>(out.h() - position.y, srcHeight));
const auto dstSkip = static_cast<unsigned>(out.pitch() - srcWidth);
const unsigned srcSkip = srcWidth % 2;
uint8_t *dst = &out[position];
for (unsigned y = 0; y < srcHeight; y++) {
for (unsigned x = 0; x < srcWidth;) {
@ -67,10 +65,9 @@ void BlitPcxClipY(const Surface &out, Point position, const uint8_t *src, unsign
template <bool UseColorMap, bool HasTransparency>
void BlitPcxClipXY(const Surface &out, Point position, const uint8_t *src, unsigned srcWidth, unsigned srcHeight, ClipX clipX, const uint8_t *colorMap, uint8_t transparentColor)
{
if (position.y >= out.h() || position.x >= out.w())
return;
const unsigned srcSkip = srcWidth % 2;
while (position.y < 0 && srcHeight != 0) {
src = SkipRestOfPcxLine(src, srcWidth);
src = SkipRestOfPcxLine(src, srcWidth) + srcSkip;
++position.y;
--srcHeight;
}
@ -79,7 +76,6 @@ void BlitPcxClipXY(const Surface &out, Point position, const uint8_t *src, unsig
position.x += static_cast<int>(clipX.left);
const auto dstSkip = static_cast<unsigned>(out.pitch() - clipX.width);
const unsigned srcSkip = srcWidth % 2;
uint8_t *dst = &out[position];
for (unsigned y = 0; y < srcHeight; y++) {
// Skip initial src if clipping on the left.
@ -155,6 +151,8 @@ void BlitPcxClipXY(const Surface &out, Point position, const uint8_t *src, unsig
template <bool UseColorMap>
void BlitPcxSprite(const Surface &out, Point position, PcxSprite sprite, const uint8_t *colorMap)
{
if (position.y >= out.h() || position.y + sprite.height() <= 0)
return;
const ClipX clipX = CalculateClipX(position.x, sprite.width(), out);
if (clipX.width <= 0)
return;

Loading…
Cancel
Save