2011-07-09 23:48:18 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-09 23:48:18 +04:00
|
|
|
* RLE Compressed Bitmap Stream
|
|
|
|
*
|
|
|
|
* Copyright 2011 Jay Sorg <jay.sorg@gmail.com>
|
2016-04-05 18:07:45 +03:00
|
|
|
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2016 Thincast Technologies GmbH
|
2011-07-09 23:48:18 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* do not compile the file directly */
|
|
|
|
|
2011-07-10 06:55:11 +04:00
|
|
|
/**
|
|
|
|
* Write a foreground/background image to a destination buffer.
|
|
|
|
*/
|
2018-10-23 11:33:45 +03:00
|
|
|
static INLINE BYTE* WRITEFGBGIMAGE(BYTE* pbDest, const BYTE* pbDestEnd, UINT32 rowDelta,
|
2017-01-16 13:39:55 +03:00
|
|
|
BYTE bitmask, PIXEL fgPel, INT32 cBits)
|
2011-07-09 23:48:18 +04:00
|
|
|
{
|
|
|
|
PIXEL xorPixel;
|
2018-11-07 14:00:49 +03:00
|
|
|
BYTE mask = 0x01;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (cBits > 8)
|
|
|
|
return NULL;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, cBits))
|
|
|
|
return NULL;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(cBits, {
|
2018-11-07 14:00:49 +03:00
|
|
|
UINT32 data;
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTREADPIXEL(xorPixel, pbDest - rowDelta);
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (bitmask & mask)
|
|
|
|
data = xorPixel ^ fgPel;
|
2011-07-09 23:48:18 +04:00
|
|
|
else
|
2018-11-07 14:00:49 +03:00
|
|
|
data = xorPixel;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, data);
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-07 14:00:49 +03:00
|
|
|
mask = mask << 1;
|
2018-11-09 13:51:20 +03:00
|
|
|
});
|
2011-07-09 23:48:18 +04:00
|
|
|
return pbDest;
|
|
|
|
}
|
|
|
|
|
2011-07-10 06:55:11 +04:00
|
|
|
/**
|
|
|
|
* Write a foreground/background image to a destination buffer
|
|
|
|
* for the first line of compressed data.
|
|
|
|
*/
|
2018-10-23 11:33:45 +03:00
|
|
|
static INLINE BYTE* WRITEFIRSTLINEFGBGIMAGE(BYTE* pbDest, const BYTE* pbDestEnd, BYTE bitmask,
|
2019-11-06 17:24:51 +03:00
|
|
|
PIXEL fgPel, UINT32 cBits)
|
2011-07-09 23:48:18 +04:00
|
|
|
{
|
2018-11-07 14:00:49 +03:00
|
|
|
BYTE mask = 0x01;
|
|
|
|
|
|
|
|
if (cBits > 8)
|
|
|
|
return NULL;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, cBits))
|
|
|
|
return NULL;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(cBits, {
|
2018-11-07 14:00:49 +03:00
|
|
|
UINT32 data;
|
|
|
|
|
|
|
|
if (bitmask & mask)
|
|
|
|
data = fgPel;
|
2011-07-09 23:48:18 +04:00
|
|
|
else
|
2019-11-06 17:24:51 +03:00
|
|
|
data = BLACK_PIXEL;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, data);
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-07 14:00:49 +03:00
|
|
|
mask = mask << 1;
|
2018-11-09 13:51:20 +03:00
|
|
|
});
|
2011-07-09 23:48:18 +04:00
|
|
|
return pbDest;
|
|
|
|
}
|
|
|
|
|
2011-07-10 06:55:11 +04:00
|
|
|
/**
|
|
|
|
* Decompress an RLE compressed bitmap.
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static INLINE BOOL RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer, BYTE* pbDestBuffer,
|
2017-01-16 13:39:55 +03:00
|
|
|
UINT32 rowDelta, UINT32 width, UINT32 height)
|
2011-07-09 23:48:18 +04:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
const BYTE* pbSrc = pbSrcBuffer;
|
2019-02-22 15:18:19 +03:00
|
|
|
const BYTE* pbEnd;
|
|
|
|
const BYTE* pbDestEnd;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* pbDest = pbDestBuffer;
|
2011-07-09 23:48:18 +04:00
|
|
|
PIXEL temp;
|
|
|
|
PIXEL fgPel = WHITE_PIXEL;
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL fInsertFgPel = FALSE;
|
|
|
|
BOOL fFirstLine = TRUE;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE bitmask;
|
2011-07-09 23:48:18 +04:00
|
|
|
PIXEL pixelA, pixelB;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 runLength;
|
|
|
|
UINT32 code;
|
2021-09-14 08:38:25 +03:00
|
|
|
UINT32 advance = 0;
|
2011-07-09 23:48:18 +04:00
|
|
|
RLEEXTRA
|
|
|
|
|
2018-10-23 11:33:45 +03:00
|
|
|
if ((rowDelta == 0) || (rowDelta < width))
|
|
|
|
return FALSE;
|
|
|
|
|
2018-10-16 18:23:24 +03:00
|
|
|
if (!pbSrcBuffer || !pbDestBuffer)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-02-22 15:18:19 +03:00
|
|
|
pbEnd = pbSrcBuffer + cbSrcBuffer;
|
|
|
|
pbDestEnd = pbDestBuffer + rowDelta * height;
|
|
|
|
|
2011-07-09 23:48:18 +04:00
|
|
|
while (pbSrc < pbEnd)
|
|
|
|
{
|
|
|
|
/* Watch out for the end of the first scanline. */
|
|
|
|
if (fFirstLine)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
if ((UINT32)(pbDest - pbDestBuffer) >= rowDelta)
|
2011-07-09 23:48:18 +04:00
|
|
|
{
|
2012-10-09 10:31:28 +04:00
|
|
|
fFirstLine = FALSE;
|
|
|
|
fInsertFgPel = FALSE;
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Extract the compression order code ID from the compression
|
|
|
|
order header.
|
|
|
|
*/
|
|
|
|
code = ExtractCodeId(*pbSrc);
|
|
|
|
|
|
|
|
/* Handle Background Run Orders. */
|
|
|
|
if (code == REGULAR_BG_RUN || code == MEGA_MEGA_BG_RUN)
|
|
|
|
{
|
2021-07-02 08:42:43 +03:00
|
|
|
runLength = ExtractRunLength(code, pbSrc, pbEnd, &advance);
|
2011-07-09 23:48:18 +04:00
|
|
|
pbSrc = pbSrc + advance;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2011-07-09 23:48:18 +04:00
|
|
|
if (fFirstLine)
|
|
|
|
{
|
|
|
|
if (fInsertFgPel)
|
|
|
|
{
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, 1))
|
2018-10-23 11:33:45 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, fgPel);
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
|
|
|
runLength = runLength - 1;
|
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, runLength))
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(runLength, {
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, BLACK_PIXEL);
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-09 13:32:28 +03:00
|
|
|
});
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (fInsertFgPel)
|
|
|
|
{
|
|
|
|
DESTREADPIXEL(temp, pbDest - rowDelta);
|
2018-10-23 11:33:45 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, 1))
|
2018-10-23 11:33:45 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, temp ^ fgPel);
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-07 14:00:49 +03:00
|
|
|
runLength--;
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, runLength))
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(runLength, {
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTREADPIXEL(temp, pbDest - rowDelta);
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, temp);
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-09 13:32:28 +03:00
|
|
|
});
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2011-07-09 23:48:18 +04:00
|
|
|
/* A follow-on background run order will need a foreground pel inserted. */
|
2012-10-09 10:31:28 +04:00
|
|
|
fInsertFgPel = TRUE;
|
2011-07-09 23:48:18 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* For any of the other run-types a follow-on background run
|
2019-11-06 17:24:51 +03:00
|
|
|
order does not need a foreground pel inserted. */
|
2012-10-09 10:31:28 +04:00
|
|
|
fInsertFgPel = FALSE;
|
2011-07-09 23:48:18 +04:00
|
|
|
|
|
|
|
switch (code)
|
|
|
|
{
|
2016-07-18 12:16:36 +03:00
|
|
|
/* Handle Foreground Run Orders. */
|
|
|
|
case REGULAR_FG_RUN:
|
|
|
|
case MEGA_MEGA_FG_RUN:
|
|
|
|
case LITE_SET_FG_FG_RUN:
|
|
|
|
case MEGA_MEGA_SET_FG_RUN:
|
2021-07-02 08:42:43 +03:00
|
|
|
runLength = ExtractRunLength(code, pbSrc, pbEnd, &advance);
|
2016-07-18 12:16:36 +03:00
|
|
|
pbSrc = pbSrc + advance;
|
|
|
|
|
|
|
|
if (code == LITE_SET_FG_FG_RUN || code == MEGA_MEGA_SET_FG_RUN)
|
|
|
|
{
|
2020-06-02 09:45:09 +03:00
|
|
|
if (pbSrc >= pbEnd)
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
SRCREADPIXEL(fgPel, pbSrc);
|
|
|
|
SRCNEXTPIXEL(pbSrc);
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, runLength))
|
|
|
|
return FALSE;
|
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
if (fFirstLine)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(runLength, {
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, fgPel);
|
2016-07-18 12:16:36 +03:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-09 13:32:28 +03:00
|
|
|
});
|
2016-07-18 12:16:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(runLength, {
|
2016-07-18 12:16:36 +03:00
|
|
|
DESTREADPIXEL(temp, pbDest - rowDelta);
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, temp ^ fgPel);
|
2016-07-18 12:16:36 +03:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-09 13:32:28 +03:00
|
|
|
});
|
2016-07-18 12:16:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Handle Dithered Run Orders. */
|
|
|
|
case LITE_DITHERED_RUN:
|
|
|
|
case MEGA_MEGA_DITHERED_RUN:
|
2021-07-02 08:42:43 +03:00
|
|
|
runLength = ExtractRunLength(code, pbSrc, pbEnd, &advance);
|
2016-07-18 12:16:36 +03:00
|
|
|
pbSrc = pbSrc + advance;
|
2020-06-02 09:45:09 +03:00
|
|
|
if (pbSrc >= pbEnd)
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
SRCREADPIXEL(pixelA, pbSrc);
|
2011-07-09 23:48:18 +04:00
|
|
|
SRCNEXTPIXEL(pbSrc);
|
2020-06-02 09:45:09 +03:00
|
|
|
if (pbSrc >= pbEnd)
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
SRCREADPIXEL(pixelB, pbSrc);
|
|
|
|
SRCNEXTPIXEL(pbSrc);
|
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, runLength * 2))
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(runLength, {
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, pixelA);
|
2016-07-18 12:16:36 +03:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, pixelB);
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-09 13:32:28 +03:00
|
|
|
});
|
2016-07-18 12:16:36 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Handle Color Run Orders. */
|
|
|
|
case REGULAR_COLOR_RUN:
|
|
|
|
case MEGA_MEGA_COLOR_RUN:
|
2021-07-02 08:42:43 +03:00
|
|
|
runLength = ExtractRunLength(code, pbSrc, pbEnd, &advance);
|
2016-07-18 12:16:36 +03:00
|
|
|
pbSrc = pbSrc + advance;
|
2020-06-02 09:45:09 +03:00
|
|
|
if (pbSrc >= pbEnd)
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
SRCREADPIXEL(pixelA, pbSrc);
|
|
|
|
SRCNEXTPIXEL(pbSrc);
|
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, runLength))
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(runLength, {
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, pixelA);
|
2011-07-09 23:48:18 +04:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-09 13:32:28 +03:00
|
|
|
});
|
2016-07-18 12:16:36 +03:00
|
|
|
break;
|
2011-07-09 23:48:18 +04:00
|
|
|
|
|
|
|
/* Handle Foreground/Background Image Orders. */
|
2016-07-18 12:16:36 +03:00
|
|
|
case REGULAR_FGBG_IMAGE:
|
|
|
|
case MEGA_MEGA_FGBG_IMAGE:
|
|
|
|
case LITE_SET_FG_FGBG_IMAGE:
|
|
|
|
case MEGA_MEGA_SET_FGBG_IMAGE:
|
2021-07-02 08:42:43 +03:00
|
|
|
runLength = ExtractRunLength(code, pbSrc, pbEnd, &advance);
|
2016-07-18 12:16:36 +03:00
|
|
|
pbSrc = pbSrc + advance;
|
|
|
|
|
2020-06-02 09:45:09 +03:00
|
|
|
if (pbSrc >= pbEnd)
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
if (code == LITE_SET_FG_FGBG_IMAGE || code == MEGA_MEGA_SET_FGBG_IMAGE)
|
2011-07-09 23:48:18 +04:00
|
|
|
{
|
2016-07-18 12:16:36 +03:00
|
|
|
SRCREADPIXEL(fgPel, pbSrc);
|
|
|
|
SRCNEXTPIXEL(pbSrc);
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
|
|
|
|
if (fFirstLine)
|
|
|
|
{
|
|
|
|
while (runLength > 8)
|
|
|
|
{
|
|
|
|
bitmask = *pbSrc;
|
|
|
|
pbSrc = pbSrc + 1;
|
2018-10-23 11:33:45 +03:00
|
|
|
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, pbDestEnd, bitmask, fgPel, 8);
|
|
|
|
|
|
|
|
if (!pbDest)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
runLength = runLength - 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (runLength > 8)
|
|
|
|
{
|
|
|
|
bitmask = *pbSrc;
|
|
|
|
pbSrc = pbSrc + 1;
|
2018-10-23 11:33:45 +03:00
|
|
|
pbDest = WRITEFGBGIMAGE(pbDest, pbDestEnd, rowDelta, bitmask, fgPel, 8);
|
|
|
|
|
|
|
|
if (!pbDest)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
runLength = runLength - 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (runLength > 0)
|
2011-07-09 23:48:18 +04:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
bitmask = *pbSrc;
|
|
|
|
pbSrc = pbSrc + 1;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
|
|
|
if (fFirstLine)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
pbDest =
|
|
|
|
WRITEFIRSTLINEFGBGIMAGE(pbDest, pbDestEnd, bitmask, fgPel, runLength);
|
2016-07-18 12:16:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
pbDest =
|
|
|
|
WRITEFGBGIMAGE(pbDest, pbDestEnd, rowDelta, bitmask, fgPel, runLength);
|
2016-07-18 12:16:36 +03:00
|
|
|
}
|
2018-10-23 11:33:45 +03:00
|
|
|
|
|
|
|
if (!pbDest)
|
|
|
|
return FALSE;
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Handle Color Image Orders. */
|
|
|
|
case REGULAR_COLOR_IMAGE:
|
|
|
|
case MEGA_MEGA_COLOR_IMAGE:
|
2021-07-02 08:42:43 +03:00
|
|
|
runLength = ExtractRunLength(code, pbSrc, pbEnd, &advance);
|
2016-07-18 12:16:36 +03:00
|
|
|
pbSrc = pbSrc + advance;
|
2020-03-30 19:05:17 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, runLength))
|
|
|
|
return FALSE;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
UNROLL(runLength, {
|
2020-06-02 09:45:09 +03:00
|
|
|
if (pbSrc >= pbEnd)
|
|
|
|
return FALSE;
|
2016-07-18 12:16:36 +03:00
|
|
|
SRCREADPIXEL(temp, pbSrc);
|
|
|
|
SRCNEXTPIXEL(pbSrc);
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, temp);
|
2016-07-18 12:16:36 +03:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
2018-11-09 13:32:28 +03:00
|
|
|
});
|
2016-07-18 12:16:36 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Handle Special Order 1. */
|
|
|
|
case SPECIAL_FGBG_1:
|
2011-07-09 23:48:18 +04:00
|
|
|
pbSrc = pbSrc + 1;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2011-07-09 23:48:18 +04:00
|
|
|
if (fFirstLine)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
pbDest =
|
|
|
|
WRITEFIRSTLINEFGBGIMAGE(pbDest, pbDestEnd, g_MaskSpecialFgBg1, fgPel, 8);
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
pbDest =
|
|
|
|
WRITEFGBGIMAGE(pbDest, pbDestEnd, rowDelta, g_MaskSpecialFgBg1, fgPel, 8);
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
2018-10-23 11:33:45 +03:00
|
|
|
if (!pbDest)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
break;
|
2011-07-09 23:48:18 +04:00
|
|
|
|
|
|
|
/* Handle Special Order 2. */
|
2016-07-18 12:16:36 +03:00
|
|
|
case SPECIAL_FGBG_2:
|
|
|
|
pbSrc = pbSrc + 1;
|
|
|
|
|
|
|
|
if (fFirstLine)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
pbDest =
|
|
|
|
WRITEFIRSTLINEFGBGIMAGE(pbDest, pbDestEnd, g_MaskSpecialFgBg2, fgPel, 8);
|
2016-07-18 12:16:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
pbDest =
|
|
|
|
WRITEFGBGIMAGE(pbDest, pbDestEnd, rowDelta, g_MaskSpecialFgBg2, fgPel, 8);
|
2016-07-18 12:16:36 +03:00
|
|
|
}
|
|
|
|
|
2018-10-23 11:33:45 +03:00
|
|
|
if (!pbDest)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
break;
|
2011-07-09 23:48:18 +04:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
/* Handle White Order. */
|
2016-07-18 12:16:36 +03:00
|
|
|
case SPECIAL_WHITE:
|
|
|
|
pbSrc = pbSrc + 1;
|
2018-10-23 11:33:45 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, 1))
|
2018-10-23 11:33:45 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, WHITE_PIXEL);
|
2016-07-18 12:16:36 +03:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
|
|
|
break;
|
2011-07-09 23:48:18 +04:00
|
|
|
|
|
|
|
/* Handle Black Order. */
|
2016-07-18 12:16:36 +03:00
|
|
|
case SPECIAL_BLACK:
|
|
|
|
pbSrc = pbSrc + 1;
|
2018-10-23 11:33:45 +03:00
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
if (!ENSURE_CAPACITY(pbDest, pbDestEnd, 1))
|
2018-10-23 11:33:45 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2018-11-07 14:00:49 +03:00
|
|
|
DESTWRITEPIXEL(pbDest, BLACK_PIXEL);
|
2016-07-18 12:16:36 +03:00
|
|
|
DESTNEXTPIXEL(pbDest);
|
|
|
|
break;
|
2018-10-16 18:23:24 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|
|
|
|
}
|
2018-10-16 18:23:24 +03:00
|
|
|
|
|
|
|
return TRUE;
|
2011-07-09 23:48:18 +04:00
|
|
|
}
|