2011-04-05 14:23:20 +02:00
|
|
|
/*
|
|
|
|
* DIB driver primitives.
|
|
|
|
*
|
|
|
|
* Copyright 2011 Huw Davies
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
2011-04-05 14:23:20 +02:00
|
|
|
#include "gdi_private.h"
|
|
|
|
#include "dibdrv.h"
|
|
|
|
|
2011-05-27 14:41:32 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dib);
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
/* Bayer matrices for dithering */
|
|
|
|
|
|
|
|
static const BYTE bayer_4x4[4][4] =
|
|
|
|
{
|
|
|
|
{ 0, 8, 2, 10 },
|
|
|
|
{ 12, 4, 14, 6 },
|
|
|
|
{ 3, 11, 1, 9 },
|
|
|
|
{ 15, 7, 13, 5 }
|
|
|
|
};
|
|
|
|
|
2012-05-23 11:14:16 +02:00
|
|
|
static const BYTE bayer_8x8[8][8] =
|
|
|
|
{
|
|
|
|
{ 0, 32, 8, 40, 2, 34, 10, 42 },
|
|
|
|
{ 48, 16, 56, 24, 50, 18, 58, 26 },
|
|
|
|
{ 12, 44, 4, 36, 14, 46, 6, 38 },
|
|
|
|
{ 60, 28, 52, 20, 62, 30, 54, 22 },
|
|
|
|
{ 3, 35, 11, 43, 1, 33, 9, 41 },
|
|
|
|
{ 51, 19, 59, 27, 49, 17, 57, 25 },
|
|
|
|
{ 15, 47, 7, 39, 13, 45, 5, 37 },
|
|
|
|
{ 63, 31, 55, 23, 61, 29, 53, 21 }
|
|
|
|
};
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static const BYTE bayer_16x16[16][16] =
|
|
|
|
{
|
|
|
|
{ 0, 128, 32, 160, 8, 136, 40, 168, 2, 130, 34, 162, 10, 138, 42, 170 },
|
|
|
|
{ 192, 64, 224, 96, 200, 72, 232, 104, 194, 66, 226, 98, 202, 74, 234, 106 },
|
|
|
|
{ 48, 176, 16, 144, 56, 184, 24, 152, 50, 178, 18, 146, 58, 186, 26, 154 },
|
|
|
|
{ 240, 112, 208, 80, 248, 120, 216, 88, 242, 114, 210, 82, 250, 122, 218, 90 },
|
|
|
|
{ 12, 140, 44, 172, 4, 132, 36, 164, 14, 142, 46, 174, 6, 134, 38, 166 },
|
|
|
|
{ 204, 76, 236, 108, 196, 68, 228, 100, 206, 78, 238, 110, 198, 70, 230, 102 },
|
|
|
|
{ 60, 188, 28, 156, 52, 180, 20, 148, 62, 190, 30, 158, 54, 182, 22, 150 },
|
|
|
|
{ 252, 124, 220, 92, 244, 116, 212, 84, 254, 126, 222, 94, 246, 118, 214, 86 },
|
|
|
|
{ 3, 131, 35, 163, 11, 139, 43, 171, 1, 129, 33, 161, 9, 137, 41, 169 },
|
|
|
|
{ 195, 67, 227, 99, 203, 75, 235, 107, 193, 65, 225, 97, 201, 73, 233, 105 },
|
|
|
|
{ 51, 179, 19, 147, 59, 187, 27, 155, 49, 177, 17, 145, 57, 185, 25, 153 },
|
|
|
|
{ 243, 115, 211, 83, 251, 123, 219, 91, 241, 113, 209, 81, 249, 121, 217, 89 },
|
|
|
|
{ 15, 143, 47, 175, 7, 135, 39, 167, 13, 141, 45, 173, 5, 133, 37, 165 },
|
|
|
|
{ 207, 79, 239, 111, 199, 71, 231, 103, 205, 77, 237, 109, 197, 69, 229, 101 },
|
|
|
|
{ 63, 191, 31, 159, 55, 183, 23, 151, 61, 189, 29, 157, 53, 181, 21, 149 },
|
|
|
|
{ 255, 127, 223, 95, 247, 119, 215, 87, 253, 125, 221, 93, 245, 117, 213, 85 },
|
|
|
|
};
|
|
|
|
|
2011-04-07 14:46:11 +02:00
|
|
|
static inline DWORD *get_pixel_ptr_32(const dib_info *dib, int x, int y)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
return (DWORD *)((BYTE*)dib->bits.ptr + (dib->rect.top + y) * dib->stride + (dib->rect.left + x) * 4);
|
2011-04-07 14:46:11 +02:00
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:39 +02:00
|
|
|
static inline DWORD *get_pixel_ptr_24_dword(const dib_info *dib, int x, int y)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
return (DWORD *)((BYTE*)dib->bits.ptr + (dib->rect.top + y) * dib->stride) + (dib->rect.left + x) * 3 / 4;
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline BYTE *get_pixel_ptr_24(const dib_info *dib, int x, int y)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
return (BYTE*)dib->bits.ptr + (dib->rect.top + y) * dib->stride + (dib->rect.left + x) * 3;
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
static inline WORD *get_pixel_ptr_16(const dib_info *dib, int x, int y)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
return (WORD *)((BYTE*)dib->bits.ptr + (dib->rect.top + y) * dib->stride + (dib->rect.left + x) * 2);
|
2011-05-27 14:10:29 +02:00
|
|
|
}
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
static inline BYTE *get_pixel_ptr_8(const dib_info *dib, int x, int y)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
return (BYTE*)dib->bits.ptr + (dib->rect.top + y) * dib->stride + dib->rect.left + x;
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:03 +02:00
|
|
|
static inline BYTE *get_pixel_ptr_4(const dib_info *dib, int x, int y)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
return (BYTE*)dib->bits.ptr + (dib->rect.top + y) * dib->stride + (dib->rect.left + x) / 2;
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:49 +02:00
|
|
|
static inline BYTE *get_pixel_ptr_1(const dib_info *dib, int x, int y)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
return (BYTE*)dib->bits.ptr + (dib->rect.top + y) * dib->stride + (dib->rect.left + x) / 8;
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
|
|
|
|
2011-11-21 11:12:52 +01:00
|
|
|
static const BYTE pixel_masks_4[2] = {0xf0, 0x0f};
|
2011-06-15 14:43:49 +02:00
|
|
|
static const BYTE pixel_masks_1[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
2016-07-15 09:59:29 +02:00
|
|
|
static const BYTE edge_masks_1[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
|
2011-06-15 14:43:49 +02:00
|
|
|
|
2017-03-08 21:29:51 +01:00
|
|
|
#define FILTER_DIBINDEX(rgbquad,other_val) \
|
|
|
|
(HIWORD( *(DWORD *)(&rgbquad) ) == 0x10ff ? LOWORD( *(DWORD *)(&rgbquad) ) : (other_val))
|
|
|
|
|
2016-08-25 10:43:08 +02:00
|
|
|
#define ROPS_WITHOUT_COPY( _d, _s ) \
|
|
|
|
case R2_BLACK: LOOP( (_d) = 0 ) break; \
|
|
|
|
case R2_NOTMERGEPEN: LOOP( (_d) = ~((_d) | (_s)) ) break; \
|
|
|
|
case R2_MASKNOTPEN: LOOP( (_d) &= ~(_s) ) break; \
|
|
|
|
case R2_NOTCOPYPEN: LOOP( (_d) = ~(_s) ) break; \
|
|
|
|
case R2_MASKPENNOT: LOOP( (_d) = (~(_d) & (_s)) ) break; \
|
|
|
|
case R2_NOT: LOOP( (_d) = ~(_d) ) break; \
|
|
|
|
case R2_XORPEN: LOOP( (_d) ^= (_s) ) break; \
|
|
|
|
case R2_NOTMASKPEN: LOOP( (_d) = ~((_d) & (_s)) ) break; \
|
|
|
|
case R2_MASKPEN: LOOP( (_d) &= (_s) ) break; \
|
|
|
|
case R2_NOTXORPEN: LOOP( (_d) = ~((_d) ^ (_s)) ) break; \
|
|
|
|
case R2_NOP: break; \
|
|
|
|
case R2_MERGENOTPEN: LOOP( (_d) = ((_d) | ~(_s)) ) break; \
|
|
|
|
case R2_MERGEPENNOT: LOOP( (_d) = (~(_d) | (_s)) ) break; \
|
|
|
|
case R2_MERGEPEN: LOOP( (_d) |= (_s) ) break; \
|
|
|
|
case R2_WHITE: LOOP( (_d) = ~0 ) break;
|
|
|
|
|
2016-08-25 10:43:09 +02:00
|
|
|
#define ROPS_ALL( _d, _s ) \
|
|
|
|
case R2_COPYPEN: LOOP( (_d) = (_s) ) break; \
|
|
|
|
ROPS_WITHOUT_COPY( (_d), (_s) )
|
|
|
|
|
2011-04-07 14:46:11 +02:00
|
|
|
static inline void do_rop_32(DWORD *ptr, DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
*ptr = (*ptr & and) ^ xor;
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
static inline void do_rop_16(WORD *ptr, WORD and, WORD xor)
|
|
|
|
{
|
|
|
|
*ptr = (*ptr & and) ^ xor;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
static inline void do_rop_8(BYTE *ptr, BYTE and, BYTE xor)
|
|
|
|
{
|
|
|
|
*ptr = (*ptr & and) ^ xor;
|
|
|
|
}
|
|
|
|
|
2011-08-02 15:11:08 +02:00
|
|
|
static inline void do_rop_mask_8(BYTE *ptr, BYTE and, BYTE xor, BYTE mask)
|
|
|
|
{
|
|
|
|
*ptr = (*ptr & (and | ~mask)) ^ (xor & mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void do_rop_codes_32(DWORD *dst, DWORD src, struct rop_codes *codes)
|
|
|
|
{
|
|
|
|
do_rop_32( dst, (src & codes->a1) ^ codes->a2, (src & codes->x1) ^ codes->x2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void do_rop_codes_16(WORD *dst, WORD src, struct rop_codes *codes)
|
|
|
|
{
|
|
|
|
do_rop_16( dst, (src & codes->a1) ^ codes->a2, (src & codes->x1) ^ codes->x2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void do_rop_codes_8(BYTE *dst, BYTE src, struct rop_codes *codes)
|
|
|
|
{
|
|
|
|
do_rop_8( dst, (src & codes->a1) ^ codes->a2, (src & codes->x1) ^ codes->x2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void do_rop_codes_mask_8(BYTE *dst, BYTE src, struct rop_codes *codes, BYTE mask)
|
|
|
|
{
|
|
|
|
do_rop_mask_8( dst, (src & codes->a1) ^ codes->a2, (src & codes->x1) ^ codes->x2, mask );
|
|
|
|
}
|
|
|
|
|
2011-09-22 10:18:14 +02:00
|
|
|
static inline void do_rop_codes_line_16(WORD *dst, const WORD *src, struct rop_codes *codes, int len)
|
|
|
|
{
|
|
|
|
for (; len > 0; len--, src++, dst++) do_rop_codes_16( dst, *src, codes );
|
|
|
|
}
|
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
static inline void do_rop_codes_line_rev_16(WORD *dst, const WORD *src, struct rop_codes *codes, int len)
|
|
|
|
{
|
|
|
|
for (src += len - 1, dst += len - 1; len > 0; len--, src--, dst--)
|
|
|
|
do_rop_codes_16( dst, *src, codes );
|
|
|
|
}
|
|
|
|
|
2011-09-22 10:18:14 +02:00
|
|
|
static inline void do_rop_codes_line_8(BYTE *dst, const BYTE *src, struct rop_codes *codes, int len)
|
|
|
|
{
|
|
|
|
for (; len > 0; len--, src++, dst++) do_rop_codes_8( dst, *src, codes );
|
|
|
|
}
|
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
static inline void do_rop_codes_line_rev_8(BYTE *dst, const BYTE *src, struct rop_codes *codes, int len)
|
|
|
|
{
|
|
|
|
for (src += len - 1, dst += len - 1; len > 0; len--, src--, dst--)
|
|
|
|
do_rop_codes_8( dst, *src, codes );
|
|
|
|
}
|
|
|
|
|
2011-09-22 10:18:14 +02:00
|
|
|
static inline void do_rop_codes_line_4(BYTE *dst, int dst_x, const BYTE *src, int src_x,
|
|
|
|
struct rop_codes *codes, int len)
|
|
|
|
{
|
|
|
|
BYTE src_val;
|
|
|
|
|
|
|
|
for (src += src_x / 2, dst += dst_x / 2; len > 0; len--, dst_x++, src_x++)
|
|
|
|
{
|
|
|
|
if (dst_x & 1)
|
|
|
|
{
|
|
|
|
if (src_x & 1) src_val = *src++;
|
|
|
|
else src_val = *src >> 4;
|
|
|
|
do_rop_codes_mask_8( dst++, src_val, codes, 0x0f );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (src_x & 1) src_val = *src++ << 4;
|
|
|
|
else src_val = *src;
|
|
|
|
do_rop_codes_mask_8( dst, src_val, codes, 0xf0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
static inline void do_rop_codes_line_rev_4(BYTE *dst, int dst_x, const BYTE *src, int src_x,
|
|
|
|
struct rop_codes *codes, int len)
|
|
|
|
{
|
|
|
|
BYTE src_val;
|
|
|
|
|
|
|
|
src_x += len - 1;
|
|
|
|
dst_x += len - 1;
|
|
|
|
for (src += src_x / 2, dst += dst_x / 2; len > 0; len--, dst_x--, src_x--)
|
|
|
|
{
|
|
|
|
if (dst_x & 1)
|
|
|
|
{
|
|
|
|
if (src_x & 1) src_val = *src;
|
|
|
|
else src_val = *src-- >> 4;
|
|
|
|
do_rop_codes_mask_8( dst, src_val, codes, 0x0f );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (src_x & 1) src_val = *src << 4;
|
|
|
|
else src_val = *src--;
|
|
|
|
do_rop_codes_mask_8( dst--, src_val, codes, 0xf0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-29 12:17:55 +01:00
|
|
|
static inline void memset_32( DWORD *start, DWORD val, DWORD size )
|
|
|
|
{
|
2012-11-29 12:31:13 +01:00
|
|
|
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
|
|
|
DWORD dummy;
|
|
|
|
__asm__ __volatile__( "cld; rep; stosl"
|
|
|
|
: "=c" (dummy), "=D" (dummy)
|
|
|
|
: "a" (val), "0" (size), "1" (start) );
|
|
|
|
#else
|
2012-11-29 12:17:55 +01:00
|
|
|
while (size--) *start++ = val;
|
2012-11-29 12:31:13 +01:00
|
|
|
#endif
|
2012-11-29 12:17:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void memset_16( WORD *start, WORD val, DWORD size )
|
|
|
|
{
|
2012-11-29 12:31:13 +01:00
|
|
|
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
|
|
|
DWORD dummy;
|
|
|
|
__asm__ __volatile__( "cld; rep; stosw"
|
|
|
|
: "=c" (dummy), "=D" (dummy)
|
|
|
|
: "a" (val), "0" (size), "1" (start) );
|
|
|
|
#else
|
2012-11-29 12:17:55 +01:00
|
|
|
while (size--) *start++ = val;
|
2012-11-29 12:31:13 +01:00
|
|
|
#endif
|
2012-11-29 12:17:55 +01:00
|
|
|
}
|
|
|
|
|
2011-05-11 16:16:45 +02:00
|
|
|
static void solid_rects_32(const dib_info *dib, int num, const RECT *rc, DWORD and, DWORD xor)
|
2011-04-07 14:46:11 +02:00
|
|
|
{
|
|
|
|
DWORD *ptr, *start;
|
|
|
|
int x, y, i;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
2012-11-29 12:17:55 +01:00
|
|
|
assert( !is_rect_empty( rc ));
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
start = get_pixel_ptr_32(dib, rc->left, rc->top);
|
2012-11-29 12:17:55 +01:00
|
|
|
if (and)
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 4)
|
|
|
|
for(x = rc->left, ptr = start; x < rc->right; x++)
|
|
|
|
do_rop_32(ptr++, and, xor);
|
|
|
|
else
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 4)
|
|
|
|
memset_32( start, xor, rc->right - rc->left );
|
2011-04-07 14:46:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:39 +02:00
|
|
|
static void solid_rects_24(const dib_info *dib, int num, const RECT *rc, DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
DWORD *ptr, *start;
|
|
|
|
BYTE *byte_ptr, *byte_start;
|
|
|
|
int x, y, i;
|
|
|
|
DWORD and_masks[3], xor_masks[3];
|
|
|
|
|
|
|
|
and_masks[0] = ( and & 0x00ffffff) | ((and << 24) & 0xff000000);
|
|
|
|
and_masks[1] = ((and >> 8) & 0x0000ffff) | ((and << 16) & 0xffff0000);
|
|
|
|
and_masks[2] = ((and >> 16) & 0x000000ff) | ((and << 8) & 0xffffff00);
|
|
|
|
xor_masks[0] = ( xor & 0x00ffffff) | ((xor << 24) & 0xff000000);
|
|
|
|
xor_masks[1] = ((xor >> 8) & 0x0000ffff) | ((xor << 16) & 0xffff0000);
|
|
|
|
xor_masks[2] = ((xor >> 16) & 0x000000ff) | ((xor << 8) & 0xffffff00);
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int left = dib->rect.left + rc->left;
|
|
|
|
int right = dib->rect.left + rc->right;
|
2011-06-01 10:41:39 +02:00
|
|
|
|
2012-11-29 12:17:55 +01:00
|
|
|
assert( !is_rect_empty( rc ));
|
2012-04-27 14:44:53 +02:00
|
|
|
|
|
|
|
if ((left & ~3) == (right & ~3)) /* Special case for lines that start and end in the same DWORD triplet */
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
|
|
|
byte_start = get_pixel_ptr_24(dib, rc->left, rc->top);
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, byte_start += dib->stride)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
for(x = left, byte_ptr = byte_start; x < right; x++)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
|
|
|
do_rop_8(byte_ptr++, and_masks[0] & 0xff, xor_masks[0] & 0xff);
|
|
|
|
do_rop_8(byte_ptr++, and_masks[1] & 0xff, xor_masks[1] & 0xff);
|
|
|
|
do_rop_8(byte_ptr++, and_masks[2] & 0xff, xor_masks[2] & 0xff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-29 12:17:55 +01:00
|
|
|
else if (and)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
|
|
|
start = get_pixel_ptr_24_dword(dib, rc->left, rc->top);
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 4)
|
|
|
|
{
|
|
|
|
ptr = start;
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
switch(left & 3)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
do_rop_32(ptr++, and_masks[0] | 0x00ffffff, xor_masks[0] & 0xff000000);
|
|
|
|
do_rop_32(ptr++, and_masks[1], xor_masks[1]);
|
|
|
|
do_rop_32(ptr++, and_masks[2], xor_masks[2]);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
do_rop_32(ptr++, and_masks[1] | 0x0000ffff, xor_masks[1] & 0xffff0000);
|
|
|
|
do_rop_32(ptr++, and_masks[2], xor_masks[2]);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
do_rop_32(ptr++, and_masks[2] | 0x000000ff, xor_masks[2] & 0xffffff00);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
for(x = (left + 3) & ~3; x < (right & ~3); x += 4)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
|
|
|
do_rop_32(ptr++, and_masks[0], xor_masks[0]);
|
|
|
|
do_rop_32(ptr++, and_masks[1], xor_masks[1]);
|
|
|
|
do_rop_32(ptr++, and_masks[2], xor_masks[2]);
|
|
|
|
}
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
switch(right & 3)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
do_rop_32(ptr, and_masks[0] | 0xff000000, xor_masks[0] & 0x00ffffff);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
do_rop_32(ptr++, and_masks[0], xor_masks[0]);
|
|
|
|
do_rop_32(ptr, and_masks[1] | 0xffff0000, xor_masks[1] & 0x0000ffff);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
do_rop_32(ptr++, and_masks[0], xor_masks[0]);
|
|
|
|
do_rop_32(ptr++, and_masks[1], xor_masks[1]);
|
|
|
|
do_rop_32(ptr, and_masks[2] | 0xffffff00, xor_masks[2] & 0x000000ff);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-29 12:17:55 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
start = get_pixel_ptr_24_dword(dib, rc->left, rc->top);
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 4)
|
|
|
|
{
|
|
|
|
ptr = start;
|
|
|
|
|
|
|
|
switch(left & 3)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
do_rop_32(ptr++, 0x00ffffff, xor_masks[0] & 0xff000000);
|
|
|
|
*ptr++ = xor_masks[1];
|
|
|
|
*ptr++ = xor_masks[2];
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
do_rop_32(ptr++, 0x0000ffff, xor_masks[1] & 0xffff0000);
|
|
|
|
*ptr++ = xor_masks[2];
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
do_rop_32(ptr++, 0x000000ff, xor_masks[2] & 0xffffff00);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(x = (left + 3) & ~3; x < (right & ~3); x += 4)
|
|
|
|
{
|
|
|
|
*ptr++ = xor_masks[0];
|
|
|
|
*ptr++ = xor_masks[1];
|
|
|
|
*ptr++ = xor_masks[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(right & 3)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
do_rop_32(ptr, 0xff000000, xor_masks[0] & 0x00ffffff);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
*ptr++ = xor_masks[0];
|
|
|
|
do_rop_32(ptr, 0xffff0000, xor_masks[1] & 0x0000ffff);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
*ptr++ = xor_masks[0];
|
|
|
|
*ptr++ = xor_masks[1];
|
|
|
|
do_rop_32(ptr, 0xffffff00, xor_masks[2] & 0x000000ff);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
static void solid_rects_16(const dib_info *dib, int num, const RECT *rc, DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
WORD *ptr, *start;
|
|
|
|
int x, y, i;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
2012-11-29 12:17:55 +01:00
|
|
|
assert( !is_rect_empty( rc ));
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
start = get_pixel_ptr_16(dib, rc->left, rc->top);
|
2012-11-29 12:17:55 +01:00
|
|
|
if (and)
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 2)
|
|
|
|
for(x = rc->left, ptr = start; x < rc->right; x++)
|
|
|
|
do_rop_16(ptr++, and, xor);
|
|
|
|
else
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 2)
|
|
|
|
memset_16( start, xor, rc->right - rc->left );
|
2011-05-27 14:10:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
static void solid_rects_8(const dib_info *dib, int num, const RECT *rc, DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
BYTE *ptr, *start;
|
|
|
|
int x, y, i;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
2012-11-29 12:17:55 +01:00
|
|
|
assert( !is_rect_empty( rc ));
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
start = get_pixel_ptr_8(dib, rc->left, rc->top);
|
2012-11-29 12:17:55 +01:00
|
|
|
if (and)
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
for(x = rc->left, ptr = start; x < rc->right; x++)
|
|
|
|
do_rop_8(ptr++, and, xor);
|
|
|
|
else
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
memset( start, xor, rc->right - rc->left );
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:03 +02:00
|
|
|
static void solid_rects_4(const dib_info *dib, int num, const RECT *rc, DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
BYTE *ptr, *start;
|
|
|
|
int x, y, i;
|
|
|
|
BYTE byte_and = (and & 0xf) | ((and << 4) & 0xf0);
|
|
|
|
BYTE byte_xor = (xor & 0xf) | ((xor << 4) & 0xf0);
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int left = dib->rect.left + rc->left;
|
|
|
|
int right = dib->rect.left + rc->right;
|
|
|
|
|
2012-11-29 12:17:55 +01:00
|
|
|
assert( !is_rect_empty( rc ));
|
|
|
|
|
2011-05-31 11:02:03 +02:00
|
|
|
start = get_pixel_ptr_4(dib, rc->left, rc->top);
|
2012-11-29 12:17:55 +01:00
|
|
|
if (and)
|
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
{
|
|
|
|
ptr = start;
|
|
|
|
if(left & 1) /* upper nibble untouched */
|
|
|
|
do_rop_8(ptr++, byte_and | 0xf0, byte_xor & 0x0f);
|
|
|
|
|
|
|
|
for(x = (left + 1) & ~1; x < (right & ~1); x += 2)
|
|
|
|
do_rop_8(ptr++, byte_and, byte_xor);
|
|
|
|
|
|
|
|
if(right & 1) /* lower nibble untouched */
|
|
|
|
do_rop_8(ptr, byte_and | 0x0f, byte_xor & 0xf0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2012-11-29 12:17:55 +01:00
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
{
|
|
|
|
unsigned int byte_len = (right - ((left + 1) & ~1)) / 2;
|
|
|
|
|
|
|
|
ptr = start;
|
|
|
|
if(left & 1) /* upper nibble untouched */
|
|
|
|
do_rop_8(ptr++, 0xf0, byte_xor & 0x0f);
|
2011-05-31 11:02:03 +02:00
|
|
|
|
2012-11-29 12:17:55 +01:00
|
|
|
memset( ptr, byte_xor, byte_len );
|
2011-05-31 11:02:03 +02:00
|
|
|
|
2012-11-29 12:17:55 +01:00
|
|
|
if(right & 1) /* lower nibble untouched */
|
|
|
|
do_rop_8(ptr + byte_len, 0x0f, byte_xor & 0xf0);
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:49 +02:00
|
|
|
static void solid_rects_1(const dib_info *dib, int num, const RECT *rc, DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
BYTE *ptr, *start;
|
|
|
|
int x, y, i;
|
|
|
|
BYTE byte_and = (and & 1) ? 0xff : 0;
|
|
|
|
BYTE byte_xor = (xor & 1) ? 0xff : 0;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int left = dib->rect.left + rc->left;
|
|
|
|
int right = dib->rect.left + rc->right;
|
|
|
|
|
2012-11-29 12:17:55 +01:00
|
|
|
assert( !is_rect_empty( rc ));
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
start = get_pixel_ptr_1(dib, rc->left, rc->top);
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
if ((left & ~7) == (right & ~7)) /* Special case for lines that start and end in the same byte */
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
2016-07-15 09:59:29 +02:00
|
|
|
BYTE mask = edge_masks_1[left & 7] & ~edge_masks_1[right & 7];
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
{
|
2012-11-29 12:17:55 +01:00
|
|
|
do_rop_8(start, byte_and | ~mask, byte_xor & mask);
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
|
|
|
}
|
2012-11-29 12:17:55 +01:00
|
|
|
else if (and)
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
{
|
|
|
|
ptr = start;
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
if(left & 7)
|
2016-07-15 09:59:29 +02:00
|
|
|
do_rop_8(ptr++, byte_and | ~edge_masks_1[left & 7], byte_xor & edge_masks_1[left & 7]);
|
2011-06-15 14:43:49 +02:00
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
for(x = (left + 7) & ~7; x < (right & ~7); x += 8)
|
2011-06-15 14:43:49 +02:00
|
|
|
do_rop_8(ptr++, byte_and, byte_xor);
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
if(right & 7)
|
2012-11-29 12:17:55 +01:00
|
|
|
/* this is inverted wrt start mask */
|
2016-07-15 09:59:29 +02:00
|
|
|
do_rop_8(ptr, byte_and | edge_masks_1[right & 7], byte_xor & ~edge_masks_1[right & 7]);
|
2012-11-29 12:17:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
{
|
|
|
|
unsigned int byte_len = (right - ((left + 7) & ~7)) / 8;
|
|
|
|
|
|
|
|
ptr = start;
|
|
|
|
|
|
|
|
if(left & 7)
|
2016-07-15 09:59:29 +02:00
|
|
|
do_rop_8(ptr++, ~edge_masks_1[left & 7], byte_xor & edge_masks_1[left & 7]);
|
2012-11-29 12:17:55 +01:00
|
|
|
|
|
|
|
memset( ptr, byte_xor, byte_len );
|
|
|
|
|
|
|
|
if(right & 7)
|
2016-07-15 09:59:29 +02:00
|
|
|
do_rop_8(ptr + byte_len, edge_masks_1[right & 7], byte_xor & ~edge_masks_1[right & 7]);
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-11 16:16:45 +02:00
|
|
|
static void solid_rects_null(const dib_info *dib, int num, const RECT *rc, DWORD and, DWORD xor)
|
2011-04-07 14:46:11 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-21 11:12:52 +01:00
|
|
|
static void solid_line_32(const dib_info *dib, const POINT *start, const struct line_params *params,
|
|
|
|
DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
DWORD *ptr = get_pixel_ptr_32( dib, start->x, start->y );
|
|
|
|
int len = params->length, err = params->err_start;
|
|
|
|
int major_inc, minor_inc;
|
|
|
|
|
|
|
|
if (params->x_major)
|
|
|
|
{
|
|
|
|
major_inc = params->x_inc;
|
|
|
|
minor_inc = (dib->stride * params->y_inc) / 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
major_inc = (dib->stride * params->y_inc) / 4;
|
|
|
|
minor_inc = params->x_inc;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
do_rop_32( ptr, and, xor );
|
|
|
|
if (err + params->bias > 0)
|
|
|
|
{
|
|
|
|
ptr += minor_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
ptr += major_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void solid_line_24(const dib_info *dib, const POINT *start, const struct line_params *params,
|
|
|
|
DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
BYTE *ptr = get_pixel_ptr_24( dib, start->x, start->y );
|
|
|
|
int len = params->length, err = params->err_start;
|
|
|
|
int major_inc, minor_inc;
|
|
|
|
|
|
|
|
if (params->x_major)
|
|
|
|
{
|
|
|
|
major_inc = params->x_inc * 3;
|
|
|
|
minor_inc = dib->stride * params->y_inc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
major_inc = dib->stride * params->y_inc;
|
|
|
|
minor_inc = params->x_inc * 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
do_rop_8( ptr, and, xor );
|
|
|
|
do_rop_8( ptr + 1, and >> 8, xor >> 8 );
|
|
|
|
do_rop_8( ptr + 2, and >> 16, xor >> 16 );
|
|
|
|
if (err + params->bias > 0)
|
|
|
|
{
|
|
|
|
ptr += minor_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
ptr += major_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void solid_line_16(const dib_info *dib, const POINT *start, const struct line_params *params,
|
|
|
|
DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
WORD *ptr = get_pixel_ptr_16( dib, start->x, start->y );
|
|
|
|
int len = params->length, err = params->err_start;
|
|
|
|
int major_inc, minor_inc;
|
|
|
|
|
|
|
|
if (params->x_major)
|
|
|
|
{
|
|
|
|
major_inc = params->x_inc;
|
|
|
|
minor_inc = (dib->stride * params->y_inc) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
major_inc = (dib->stride * params->y_inc) / 2;
|
|
|
|
minor_inc = params->x_inc;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
do_rop_16( ptr, and, xor );
|
|
|
|
if (err + params->bias > 0)
|
|
|
|
{
|
|
|
|
ptr += minor_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
ptr += major_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void solid_line_8(const dib_info *dib, const POINT *start, const struct line_params *params,
|
|
|
|
DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
BYTE *ptr = get_pixel_ptr_8( dib, start->x, start->y );
|
|
|
|
int len = params->length, err = params->err_start;
|
|
|
|
int major_inc, minor_inc;
|
|
|
|
|
|
|
|
if (params->x_major)
|
|
|
|
{
|
|
|
|
major_inc = params->x_inc;
|
|
|
|
minor_inc = dib->stride * params->y_inc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
major_inc = dib->stride * params->y_inc;
|
|
|
|
minor_inc = params->x_inc;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
do_rop_8( ptr, and, xor );
|
|
|
|
if (err + params->bias > 0)
|
|
|
|
{
|
|
|
|
ptr += minor_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
ptr += major_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void solid_line_4(const dib_info *dib, const POINT *start, const struct line_params *params,
|
|
|
|
DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
BYTE *ptr = get_pixel_ptr_4( dib, start->x, start->y );
|
|
|
|
int len = params->length, err = params->err_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
int x = dib->rect.left + start->x;
|
2011-11-21 11:12:52 +01:00
|
|
|
|
|
|
|
and = (and & 0x0f) | ((and << 4) & 0xf0);
|
|
|
|
xor = (xor & 0x0f) | ((xor << 4) & 0xf0);
|
|
|
|
|
|
|
|
if (params->x_major)
|
|
|
|
{
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
do_rop_mask_8( ptr, and, xor, pixel_masks_4[ x % 2 ] );
|
|
|
|
if (err + params->bias > 0)
|
|
|
|
{
|
|
|
|
ptr += dib->stride * params->y_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
if ((x / 2) != ((x + params->x_inc) / 2))
|
|
|
|
ptr += params->x_inc;
|
|
|
|
x += params->x_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
do_rop_mask_8( ptr, and, xor, pixel_masks_4[ x % 2 ] );
|
|
|
|
if (err + params->bias > 0)
|
|
|
|
{
|
|
|
|
if ((x / 2) != ((x + params->x_inc) / 2))
|
|
|
|
ptr += params->x_inc;
|
|
|
|
x += params->x_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
ptr += dib->stride * params->y_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void solid_line_1(const dib_info *dib, const POINT *start, const struct line_params *params,
|
|
|
|
DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
BYTE *ptr = get_pixel_ptr_1( dib, start->x, start->y );
|
|
|
|
int len = params->length, err = params->err_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
int x = dib->rect.left + start->x;
|
2011-11-21 11:12:52 +01:00
|
|
|
|
|
|
|
and = (and & 0x1) ? 0xff : 0;
|
|
|
|
xor = (xor & 0x1) ? 0xff : 0;
|
|
|
|
|
|
|
|
if (params->x_major)
|
|
|
|
{
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
do_rop_mask_8( ptr, and, xor, pixel_masks_1[ x % 8 ] );
|
|
|
|
if (err + params->bias > 0)
|
|
|
|
{
|
|
|
|
ptr += dib->stride * params->y_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
if ((x / 8) != ((x + params->x_inc) / 8))
|
|
|
|
ptr += params->x_inc;
|
|
|
|
x += params->x_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
do_rop_mask_8( ptr, and, xor, pixel_masks_1[ x % 8 ] );
|
|
|
|
if (err + params->bias > 0)
|
|
|
|
{
|
|
|
|
if ((x / 8) != ((x + params->x_inc) / 8))
|
|
|
|
ptr += params->x_inc;
|
|
|
|
x += params->x_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
ptr += dib->stride * params->y_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void solid_line_null(const dib_info *dib, const POINT *start, const struct line_params *params,
|
|
|
|
DWORD and, DWORD xor)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-12 13:46:50 +02:00
|
|
|
static inline INT calc_offset(INT edge, INT size, INT origin)
|
|
|
|
{
|
|
|
|
INT offset;
|
|
|
|
|
|
|
|
if(edge - origin >= 0)
|
|
|
|
offset = (edge - origin) % size;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offset = (origin - edge) % size;
|
|
|
|
if(offset) offset = size - offset;
|
|
|
|
}
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline POINT calc_brush_offset(const RECT *rc, const dib_info *brush, const POINT *origin)
|
|
|
|
{
|
|
|
|
POINT offset;
|
|
|
|
|
|
|
|
offset.x = calc_offset(rc->left, brush->width, origin->x);
|
|
|
|
offset.y = calc_offset(rc->top, brush->height, origin->y);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pattern_rects_32(const dib_info *dib, int num, const RECT *rc, const POINT *origin,
|
2012-05-22 21:52:44 +02:00
|
|
|
const dib_info *brush, const rop_mask_bits *bits)
|
2011-05-12 13:46:50 +02:00
|
|
|
{
|
|
|
|
DWORD *ptr, *start, *start_and, *and_ptr, *start_xor, *xor_ptr;
|
2012-11-29 17:59:37 +01:00
|
|
|
int x, y, i, len, brush_x;
|
2011-05-12 13:46:50 +02:00
|
|
|
POINT offset;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
|
|
|
offset = calc_brush_offset(rc, brush, origin);
|
|
|
|
start = get_pixel_ptr_32(dib, rc->left, rc->top);
|
2012-05-22 21:52:44 +02:00
|
|
|
start_xor = (DWORD*)bits->xor + offset.y * brush->stride / 4;
|
2011-05-12 13:46:50 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if (bits->and)
|
2011-05-12 13:46:50 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
start_and = (DWORD*)bits->and + offset.y * brush->stride / 4;
|
2011-05-12 13:46:50 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 4)
|
2011-05-12 13:46:50 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
and_ptr = start_and + offset.x;
|
|
|
|
xor_ptr = start_xor + offset.x;
|
|
|
|
|
|
|
|
for(x = rc->left, ptr = start; x < rc->right; x++)
|
2011-05-12 13:46:50 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
do_rop_32(ptr++, *and_ptr++, *xor_ptr++);
|
|
|
|
if(and_ptr == start_and + brush->width)
|
|
|
|
{
|
|
|
|
and_ptr = start_and;
|
|
|
|
xor_ptr = start_xor;
|
|
|
|
}
|
2011-05-12 13:46:50 +02:00
|
|
|
}
|
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_and = bits->and;
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start_and += brush->stride / 4;
|
|
|
|
start_xor += brush->stride / 4;
|
|
|
|
}
|
2011-05-12 13:46:50 +02:00
|
|
|
}
|
2012-11-29 17:59:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 4)
|
2011-05-12 13:46:50 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
for (x = rc->left, brush_x = offset.x; x < rc->right; x += len)
|
|
|
|
{
|
|
|
|
len = min( rc->right - x, brush->width - brush_x );
|
|
|
|
memcpy( start + x - rc->left, start_xor + brush_x, len * 4 );
|
|
|
|
brush_x = 0;
|
|
|
|
}
|
|
|
|
|
2011-05-12 13:46:50 +02:00
|
|
|
start_xor += brush->stride / 4;
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
2011-05-12 13:46:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:39 +02:00
|
|
|
static void pattern_rects_24(const dib_info *dib, int num, const RECT *rc, const POINT *origin,
|
2012-05-22 21:52:44 +02:00
|
|
|
const dib_info *brush, const rop_mask_bits *bits)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
|
|
|
BYTE *ptr, *start, *start_and, *and_ptr, *start_xor, *xor_ptr;
|
2012-11-29 17:59:37 +01:00
|
|
|
int x, y, i, len, brush_x;
|
2011-06-01 10:41:39 +02:00
|
|
|
POINT offset;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
|
|
|
offset = calc_brush_offset(rc, brush, origin);
|
|
|
|
|
|
|
|
start = get_pixel_ptr_24(dib, rc->left, rc->top);
|
2012-05-22 21:52:44 +02:00
|
|
|
start_xor = (BYTE*)bits->xor + offset.y * brush->stride;
|
2011-06-01 10:41:39 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if (bits->and)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
start_and = (BYTE*)bits->and + offset.y * brush->stride;
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
and_ptr = start_and + offset.x * 3;
|
|
|
|
xor_ptr = start_xor + offset.x * 3;
|
|
|
|
|
|
|
|
for(x = rc->left, ptr = start; x < rc->right; x++)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
do_rop_8(ptr++, *and_ptr++, *xor_ptr++);
|
|
|
|
do_rop_8(ptr++, *and_ptr++, *xor_ptr++);
|
|
|
|
do_rop_8(ptr++, *and_ptr++, *xor_ptr++);
|
|
|
|
if(and_ptr == start_and + brush->width * 3)
|
|
|
|
{
|
|
|
|
and_ptr = start_and;
|
|
|
|
xor_ptr = start_xor;
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_and = bits->and;
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start_and += brush->stride;
|
|
|
|
start_xor += brush->stride;
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
2012-11-29 17:59:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
for (x = rc->left, brush_x = offset.x; x < rc->right; x += len)
|
|
|
|
{
|
|
|
|
len = min( rc->right - x, brush->width - brush_x );
|
|
|
|
memcpy( start + (x - rc->left) * 3, start_xor + brush_x * 3, len * 3 );
|
|
|
|
brush_x = 0;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:39 +02:00
|
|
|
start_xor += brush->stride;
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
static void pattern_rects_16(const dib_info *dib, int num, const RECT *rc, const POINT *origin,
|
2012-05-22 21:52:44 +02:00
|
|
|
const dib_info *brush, const rop_mask_bits *bits)
|
2011-05-27 14:10:29 +02:00
|
|
|
{
|
|
|
|
WORD *ptr, *start, *start_and, *and_ptr, *start_xor, *xor_ptr;
|
2012-11-29 17:59:37 +01:00
|
|
|
int x, y, i, len, brush_x;
|
2011-05-27 14:10:29 +02:00
|
|
|
POINT offset;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
|
|
|
offset = calc_brush_offset(rc, brush, origin);
|
|
|
|
|
|
|
|
start = get_pixel_ptr_16(dib, rc->left, rc->top);
|
2012-05-22 21:52:44 +02:00
|
|
|
start_xor = (WORD*)bits->xor + offset.y * brush->stride / 2;
|
2011-05-27 14:10:29 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if (bits->and)
|
2011-05-27 14:10:29 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
start_and = (WORD*)bits->and + offset.y * brush->stride / 2;
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 2)
|
2011-05-27 14:10:29 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
and_ptr = start_and + offset.x;
|
|
|
|
xor_ptr = start_xor + offset.x;
|
|
|
|
|
|
|
|
for(x = rc->left, ptr = start; x < rc->right; x++)
|
2011-05-27 14:10:29 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
do_rop_16(ptr++, *and_ptr++, *xor_ptr++);
|
|
|
|
if(and_ptr == start_and + brush->width)
|
|
|
|
{
|
|
|
|
and_ptr = start_and;
|
|
|
|
xor_ptr = start_xor;
|
|
|
|
}
|
2011-05-27 14:10:29 +02:00
|
|
|
}
|
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_and = bits->and;
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start_and += brush->stride / 2;
|
|
|
|
start_xor += brush->stride / 2;
|
|
|
|
}
|
2011-05-27 14:10:29 +02:00
|
|
|
}
|
2012-11-29 17:59:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride / 2)
|
2011-05-27 14:10:29 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
for (x = rc->left, brush_x = offset.x; x < rc->right; x += len)
|
|
|
|
{
|
|
|
|
len = min( rc->right - x, brush->width - brush_x );
|
|
|
|
memcpy( start + x - rc->left, start_xor + brush_x, len * 2 );
|
|
|
|
brush_x = 0;
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
start_xor += brush->stride / 2;
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
2011-05-27 14:10:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
static void pattern_rects_8(const dib_info *dib, int num, const RECT *rc, const POINT *origin,
|
2012-05-22 21:52:44 +02:00
|
|
|
const dib_info *brush, const rop_mask_bits *bits)
|
2011-05-27 15:26:02 +02:00
|
|
|
{
|
|
|
|
BYTE *ptr, *start, *start_and, *and_ptr, *start_xor, *xor_ptr;
|
2012-11-29 17:59:37 +01:00
|
|
|
int x, y, i, len, brush_x;
|
2011-05-27 15:26:02 +02:00
|
|
|
POINT offset;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
|
|
|
offset = calc_brush_offset(rc, brush, origin);
|
|
|
|
|
|
|
|
start = get_pixel_ptr_8(dib, rc->left, rc->top);
|
2012-05-22 21:52:44 +02:00
|
|
|
start_xor = (BYTE*)bits->xor + offset.y * brush->stride;
|
2011-05-27 15:26:02 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if (bits->and)
|
2011-05-27 15:26:02 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
start_and = (BYTE*)bits->and + offset.y * brush->stride;
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
2011-05-27 15:26:02 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
and_ptr = start_and + offset.x;
|
|
|
|
xor_ptr = start_xor + offset.x;
|
|
|
|
|
|
|
|
for(x = rc->left, ptr = start; x < rc->right; x++)
|
2011-05-27 15:26:02 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
do_rop_8(ptr++, *and_ptr++, *xor_ptr++);
|
|
|
|
if(and_ptr == start_and + brush->width)
|
|
|
|
{
|
|
|
|
and_ptr = start_and;
|
|
|
|
xor_ptr = start_xor;
|
|
|
|
}
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_and = bits->and;
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start_and += brush->stride;
|
|
|
|
start_xor += brush->stride;
|
|
|
|
}
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
2012-11-29 17:59:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
2011-05-27 15:26:02 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
for (x = rc->left, brush_x = offset.x; x < rc->right; x += len)
|
|
|
|
{
|
|
|
|
len = min( rc->right - x, brush->width - brush_x );
|
|
|
|
memcpy( start + x - rc->left, start_xor + brush_x, len );
|
|
|
|
brush_x = 0;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
start_xor += brush->stride;
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:03 +02:00
|
|
|
static void pattern_rects_4(const dib_info *dib, int num, const RECT *rc, const POINT *origin,
|
2012-05-22 21:52:44 +02:00
|
|
|
const dib_info *brush, const rop_mask_bits *bits)
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
|
|
|
BYTE *ptr, *start, *start_and, *and_ptr, *start_xor, *xor_ptr;
|
2012-04-27 14:44:53 +02:00
|
|
|
int x, y, i, left, right;
|
2011-05-31 11:02:03 +02:00
|
|
|
POINT offset;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
|
|
|
offset = calc_brush_offset(rc, brush, origin);
|
2012-04-27 14:44:53 +02:00
|
|
|
left = dib->rect.left + rc->left;
|
|
|
|
right = dib->rect.left + rc->right;
|
2011-05-31 11:02:03 +02:00
|
|
|
|
|
|
|
start = get_pixel_ptr_4(dib, rc->left, rc->top);
|
2012-05-22 21:52:44 +02:00
|
|
|
start_xor = (BYTE*)bits->xor + offset.y * brush->stride;
|
2011-05-31 11:02:03 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if (bits->and)
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
start_and = (BYTE*)bits->and + offset.y * brush->stride;
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
{
|
|
|
|
INT brush_x = offset.x;
|
|
|
|
BYTE byte_and, byte_xor;
|
2011-05-31 11:02:03 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
and_ptr = start_and + brush_x / 2;
|
|
|
|
xor_ptr = start_xor + brush_x / 2;
|
2011-05-31 11:02:03 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
for(x = left, ptr = start; x < right; x++)
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
/* FIXME: Two pixels at a time */
|
|
|
|
if(x & 1) /* lower dst nibble */
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
if(brush_x & 1) /* lower pat nibble */
|
|
|
|
{
|
|
|
|
byte_and = *and_ptr++ | 0xf0;
|
|
|
|
byte_xor = *xor_ptr++ & 0x0f;
|
|
|
|
}
|
|
|
|
else /* upper pat nibble */
|
|
|
|
{
|
|
|
|
byte_and = (*and_ptr >> 4) | 0xf0;
|
|
|
|
byte_xor = (*xor_ptr >> 4) & 0x0f;
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
2012-11-29 17:59:37 +01:00
|
|
|
else /* upper dst nibble */
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
if(brush_x & 1) /* lower pat nibble */
|
|
|
|
{
|
|
|
|
byte_and = (*and_ptr++ << 4) | 0x0f;
|
|
|
|
byte_xor = (*xor_ptr++ << 4) & 0xf0;
|
|
|
|
}
|
|
|
|
else /* upper pat nibble */
|
|
|
|
{
|
|
|
|
byte_and = *and_ptr | 0x0f;
|
|
|
|
byte_xor = *xor_ptr & 0xf0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
do_rop_8(ptr, byte_and, byte_xor);
|
|
|
|
|
|
|
|
if(x & 1) ptr++;
|
|
|
|
|
|
|
|
if(++brush_x == brush->width)
|
|
|
|
{
|
|
|
|
brush_x = 0;
|
|
|
|
and_ptr = start_and;
|
|
|
|
xor_ptr = start_xor;
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
}
|
2012-11-29 17:59:37 +01:00
|
|
|
|
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
start_and = bits->and;
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start_and += brush->stride;
|
|
|
|
start_xor += brush->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
{
|
|
|
|
INT brush_x = offset.x;
|
|
|
|
BYTE byte_xor;
|
|
|
|
|
|
|
|
xor_ptr = start_xor + brush_x / 2;
|
|
|
|
|
|
|
|
for(x = left, ptr = start; x < right; x++)
|
|
|
|
{
|
|
|
|
/* FIXME: Two pixels at a time */
|
|
|
|
if(x & 1) /* lower dst nibble */
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
if(brush_x & 1) /* lower pat nibble */
|
|
|
|
byte_xor = *xor_ptr++ & 0x0f;
|
|
|
|
else /* upper pat nibble */
|
|
|
|
byte_xor = (*xor_ptr >> 4) & 0x0f;
|
|
|
|
do_rop_8(ptr, 0xf0, byte_xor);
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
2012-11-29 17:59:37 +01:00
|
|
|
else /* upper dst nibble */
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
if(brush_x & 1) /* lower pat nibble */
|
|
|
|
byte_xor = (*xor_ptr++ << 4) & 0xf0;
|
|
|
|
else /* upper pat nibble */
|
|
|
|
byte_xor = *xor_ptr & 0xf0;
|
|
|
|
do_rop_8(ptr, 0x0f, byte_xor);
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if(x & 1) ptr++;
|
2011-05-31 11:02:03 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if(++brush_x == brush->width)
|
|
|
|
{
|
|
|
|
brush_x = 0;
|
|
|
|
xor_ptr = start_xor;
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
start_xor += brush->stride;
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:49 +02:00
|
|
|
static void pattern_rects_1(const dib_info *dib, int num, const RECT *rc, const POINT *origin,
|
2012-05-22 21:52:44 +02:00
|
|
|
const dib_info *brush, const rop_mask_bits *bits)
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
|
|
|
BYTE *ptr, *start, *start_and, *and_ptr, *start_xor, *xor_ptr;
|
2012-04-27 14:44:53 +02:00
|
|
|
int x, y, i, left, right;
|
2011-06-15 14:43:49 +02:00
|
|
|
POINT offset;
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++, rc++)
|
|
|
|
{
|
|
|
|
offset = calc_brush_offset(rc, brush, origin);
|
2012-04-27 14:44:53 +02:00
|
|
|
left = dib->rect.left + rc->left;
|
|
|
|
right = dib->rect.left + rc->right;
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
start = get_pixel_ptr_1(dib, rc->left, rc->top);
|
2012-05-22 21:52:44 +02:00
|
|
|
start_xor = (BYTE*)bits->xor + offset.y * brush->stride;
|
2011-06-15 14:43:49 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if (bits->and)
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
start_and = (BYTE*)bits->and + offset.y * brush->stride;
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
|
|
|
{
|
|
|
|
INT brush_x = offset.x;
|
|
|
|
BYTE byte_and, byte_xor;
|
2011-06-15 14:43:49 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
and_ptr = start_and + brush_x / 8;
|
|
|
|
xor_ptr = start_xor + brush_x / 8;
|
2011-06-15 14:43:49 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
for(x = left, ptr = start; x < right; x++)
|
|
|
|
{
|
|
|
|
byte_and = (*and_ptr & pixel_masks_1[brush_x % 8]) ? 0xff : 0;
|
|
|
|
byte_and |= ~pixel_masks_1[x % 8];
|
|
|
|
byte_xor = (*xor_ptr & pixel_masks_1[brush_x % 8]) ? 0xff : 0;
|
|
|
|
byte_xor &= pixel_masks_1[x % 8];
|
2011-06-15 14:43:49 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
do_rop_8(ptr, byte_and, byte_xor);
|
2011-06-15 14:43:49 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if((x & 7) == 7) ptr++;
|
2011-06-15 14:43:49 +02:00
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
if((brush_x & 7) == 7)
|
|
|
|
{
|
|
|
|
and_ptr++;
|
|
|
|
xor_ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(++brush_x == brush->width)
|
|
|
|
{
|
|
|
|
brush_x = 0;
|
|
|
|
and_ptr = start_and;
|
|
|
|
xor_ptr = start_xor;
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
|
|
|
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
start_and = bits->and;
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start_and += brush->stride;
|
|
|
|
start_xor += brush->stride;
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
|
|
|
}
|
2012-11-29 17:59:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = rc->top; y < rc->bottom; y++, start += dib->stride)
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
2012-11-29 17:59:37 +01:00
|
|
|
INT brush_x = offset.x;
|
|
|
|
|
|
|
|
xor_ptr = start_xor + brush_x / 8;
|
|
|
|
|
|
|
|
for(x = left, ptr = start; x < right; x++)
|
|
|
|
{
|
|
|
|
BYTE byte_xor = (*xor_ptr & pixel_masks_1[brush_x % 8]) ? 0xff : 0;
|
|
|
|
byte_xor &= pixel_masks_1[x % 8];
|
|
|
|
|
|
|
|
do_rop_8(ptr, ~pixel_masks_1[x % 8], byte_xor);
|
|
|
|
|
|
|
|
if((x & 7) == 7) ptr++;
|
|
|
|
if((brush_x & 7) == 7) xor_ptr++;
|
|
|
|
|
|
|
|
if(++brush_x == brush->width)
|
|
|
|
{
|
|
|
|
brush_x = 0;
|
|
|
|
xor_ptr = start_xor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:49 +02:00
|
|
|
start_xor += brush->stride;
|
2012-11-29 17:59:37 +01:00
|
|
|
offset.y++;
|
|
|
|
if(offset.y == brush->height)
|
|
|
|
{
|
|
|
|
start_xor = bits->xor;
|
|
|
|
offset.y = 0;
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-12 13:46:50 +02:00
|
|
|
static void pattern_rects_null(const dib_info *dib, int num, const RECT *rc, const POINT *origin,
|
2012-05-22 21:52:44 +02:00
|
|
|
const dib_info *brush, const rop_mask_bits *bits)
|
2011-05-12 13:46:50 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-25 10:43:07 +02:00
|
|
|
static inline void copy_rect_bits_32( DWORD *dst_start, const DWORD *src_start, const SIZE *size,
|
|
|
|
int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const DWORD *src;
|
|
|
|
DWORD *dst;
|
|
|
|
int x, y;
|
|
|
|
|
2016-08-25 10:43:08 +02:00
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride) \
|
|
|
|
for (x = 0, src = src_start, dst = dst_start; x < size->cx; x++, src++, dst++) \
|
|
|
|
op;
|
2016-08-25 10:43:07 +02:00
|
|
|
|
2016-08-25 10:43:08 +02:00
|
|
|
switch (rop2)
|
|
|
|
{
|
|
|
|
ROPS_WITHOUT_COPY( dst[0], src[0] )
|
|
|
|
}
|
|
|
|
#undef LOOP
|
2016-08-25 10:43:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_rect_bits_rev_32( DWORD *dst_start, const DWORD *src_start, const SIZE *size,
|
|
|
|
int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const DWORD *src;
|
|
|
|
DWORD *dst;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
src_start += size->cx - 1;
|
|
|
|
dst_start += size->cx - 1;
|
|
|
|
|
2016-08-25 10:43:08 +02:00
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride) \
|
|
|
|
for (x = 0, src = src_start, dst = dst_start; x < size->cx; x++, src--, dst--) \
|
|
|
|
op;
|
|
|
|
|
|
|
|
switch (rop2)
|
|
|
|
{
|
|
|
|
ROPS_WITHOUT_COPY( dst[0], src[0] )
|
|
|
|
}
|
|
|
|
#undef LOOP
|
2016-08-25 10:43:07 +02:00
|
|
|
}
|
|
|
|
|
2011-08-02 15:11:08 +02:00
|
|
|
static void copy_rect_32(const dib_info *dst, const RECT *rc,
|
2011-09-22 09:57:58 +02:00
|
|
|
const dib_info *src, const POINT *origin, int rop2, int overlap)
|
2011-08-02 15:11:08 +02:00
|
|
|
{
|
2011-09-22 09:57:58 +02:00
|
|
|
DWORD *dst_start, *src_start;
|
|
|
|
int y, dst_stride, src_stride;
|
2016-08-25 10:43:07 +02:00
|
|
|
SIZE size;
|
2011-08-02 15:11:08 +02:00
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
if (overlap & OVERLAP_BELOW)
|
|
|
|
{
|
|
|
|
dst_start = get_pixel_ptr_32(dst, rc->left, rc->bottom - 1);
|
|
|
|
src_start = get_pixel_ptr_32(src, origin->x, origin->y + rc->bottom - rc->top - 1);
|
|
|
|
dst_stride = -dst->stride / 4;
|
|
|
|
src_stride = -src->stride / 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dst_start = get_pixel_ptr_32(dst, rc->left, rc->top);
|
|
|
|
src_start = get_pixel_ptr_32(src, origin->x, origin->y);
|
|
|
|
dst_stride = dst->stride / 4;
|
|
|
|
src_stride = src->stride / 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rop2 == R2_COPYPEN)
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
memmove( dst_start, src_start, (rc->right - rc->left) * 4 );
|
2011-08-02 15:11:08 +02:00
|
|
|
return;
|
2011-09-22 09:57:58 +02:00
|
|
|
}
|
2011-08-02 15:11:08 +02:00
|
|
|
|
2016-08-25 10:43:07 +02:00
|
|
|
size.cx = rc->right - rc->left;
|
|
|
|
size.cy = rc->bottom - rc->top;
|
|
|
|
|
|
|
|
if (overlap & OVERLAP_RIGHT)
|
|
|
|
copy_rect_bits_rev_32( dst_start, src_start, &size, dst_stride, src_stride, rop2 );
|
|
|
|
else
|
|
|
|
copy_rect_bits_32( dst_start, src_start, &size, dst_stride, src_stride, rop2 );
|
2011-08-02 15:11:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_rect_24(const dib_info *dst, const RECT *rc,
|
2011-09-22 09:57:58 +02:00
|
|
|
const dib_info *src, const POINT *origin, int rop2, int overlap)
|
2011-08-02 15:11:08 +02:00
|
|
|
{
|
2011-09-22 09:57:58 +02:00
|
|
|
BYTE *dst_start, *src_start;
|
|
|
|
int y, dst_stride, src_stride;
|
2011-08-02 15:11:08 +02:00
|
|
|
struct rop_codes codes;
|
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
if (overlap & OVERLAP_BELOW)
|
|
|
|
{
|
|
|
|
dst_start = get_pixel_ptr_24(dst, rc->left, rc->bottom - 1);
|
|
|
|
src_start = get_pixel_ptr_24(src, origin->x, origin->y + rc->bottom - rc->top - 1);
|
|
|
|
dst_stride = -dst->stride;
|
|
|
|
src_stride = -src->stride;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dst_start = get_pixel_ptr_24(dst, rc->left, rc->top);
|
|
|
|
src_start = get_pixel_ptr_24(src, origin->x, origin->y);
|
|
|
|
dst_stride = dst->stride;
|
|
|
|
src_stride = src->stride;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rop2 == R2_COPYPEN)
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
memmove( dst_start, src_start, (rc->right - rc->left) * 3 );
|
2011-08-02 15:11:08 +02:00
|
|
|
return;
|
2011-09-22 09:57:58 +02:00
|
|
|
}
|
2011-08-02 15:11:08 +02:00
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
{
|
|
|
|
if (overlap & OVERLAP_RIGHT)
|
|
|
|
do_rop_codes_line_rev_8( dst_start, src_start, &codes, (rc->right - rc->left) * 3 );
|
|
|
|
else
|
2011-09-22 10:18:14 +02:00
|
|
|
do_rop_codes_line_8( dst_start, src_start, &codes, (rc->right - rc->left) * 3 );
|
2011-08-02 15:11:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_rect_16(const dib_info *dst, const RECT *rc,
|
2011-09-22 09:57:58 +02:00
|
|
|
const dib_info *src, const POINT *origin, int rop2, int overlap)
|
2011-08-02 15:11:08 +02:00
|
|
|
{
|
2011-09-22 09:57:58 +02:00
|
|
|
WORD *dst_start, *src_start;
|
|
|
|
int y, dst_stride, src_stride;
|
2011-08-02 15:11:08 +02:00
|
|
|
struct rop_codes codes;
|
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
if (overlap & OVERLAP_BELOW)
|
|
|
|
{
|
|
|
|
dst_start = get_pixel_ptr_16(dst, rc->left, rc->bottom - 1);
|
|
|
|
src_start = get_pixel_ptr_16(src, origin->x, origin->y + rc->bottom - rc->top - 1);
|
|
|
|
dst_stride = -dst->stride / 2;
|
|
|
|
src_stride = -src->stride / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dst_start = get_pixel_ptr_16(dst, rc->left, rc->top);
|
|
|
|
src_start = get_pixel_ptr_16(src, origin->x, origin->y);
|
|
|
|
dst_stride = dst->stride / 2;
|
|
|
|
src_stride = src->stride / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rop2 == R2_COPYPEN)
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
memmove( dst_start, src_start, (rc->right - rc->left) * 2 );
|
2011-08-02 15:11:08 +02:00
|
|
|
return;
|
2011-09-22 09:57:58 +02:00
|
|
|
}
|
2011-08-02 15:11:08 +02:00
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
{
|
|
|
|
if (overlap & OVERLAP_RIGHT)
|
|
|
|
do_rop_codes_line_rev_16( dst_start, src_start, &codes, rc->right - rc->left );
|
|
|
|
else
|
2011-09-22 10:18:14 +02:00
|
|
|
do_rop_codes_line_16( dst_start, src_start, &codes, rc->right - rc->left );
|
2011-08-02 15:11:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_rect_8(const dib_info *dst, const RECT *rc,
|
2011-09-22 09:57:58 +02:00
|
|
|
const dib_info *src, const POINT *origin, int rop2, int overlap)
|
2011-08-02 15:11:08 +02:00
|
|
|
{
|
2011-09-22 09:57:58 +02:00
|
|
|
BYTE *dst_start, *src_start;
|
|
|
|
int y, dst_stride, src_stride;
|
2011-08-02 15:11:08 +02:00
|
|
|
struct rop_codes codes;
|
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
if (overlap & OVERLAP_BELOW)
|
|
|
|
{
|
|
|
|
dst_start = get_pixel_ptr_8(dst, rc->left, rc->bottom - 1);
|
|
|
|
src_start = get_pixel_ptr_8(src, origin->x, origin->y + rc->bottom - rc->top - 1);
|
|
|
|
dst_stride = -dst->stride;
|
|
|
|
src_stride = -src->stride;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dst_start = get_pixel_ptr_8(dst, rc->left, rc->top);
|
|
|
|
src_start = get_pixel_ptr_8(src, origin->x, origin->y);
|
|
|
|
dst_stride = dst->stride;
|
|
|
|
src_stride = src->stride;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rop2 == R2_COPYPEN)
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
memmove( dst_start, src_start, (rc->right - rc->left) );
|
2011-08-02 15:11:08 +02:00
|
|
|
return;
|
2011-09-22 09:57:58 +02:00
|
|
|
}
|
2011-08-02 15:11:08 +02:00
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
{
|
|
|
|
if (overlap & OVERLAP_RIGHT)
|
|
|
|
do_rop_codes_line_rev_8( dst_start, src_start, &codes, rc->right - rc->left );
|
|
|
|
else
|
2011-09-22 10:18:14 +02:00
|
|
|
do_rop_codes_line_8( dst_start, src_start, &codes, rc->right - rc->left );
|
2011-08-02 15:11:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_rect_4(const dib_info *dst, const RECT *rc,
|
2011-09-22 09:57:58 +02:00
|
|
|
const dib_info *src, const POINT *origin, int rop2, int overlap)
|
2011-08-02 15:11:08 +02:00
|
|
|
{
|
2011-09-22 09:57:58 +02:00
|
|
|
BYTE *dst_start, *src_start;
|
|
|
|
int y, dst_stride, src_stride;
|
2011-08-02 15:11:08 +02:00
|
|
|
struct rop_codes codes;
|
2012-04-27 14:44:53 +02:00
|
|
|
int left = dst->rect.left + rc->left;
|
|
|
|
int right = dst->rect.left + rc->right;
|
|
|
|
int org_x = src->rect.left + origin->x;
|
2011-08-02 15:11:08 +02:00
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
if (overlap & OVERLAP_BELOW)
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
dst_start = get_pixel_ptr_4(dst, rc->left, rc->bottom - 1);
|
|
|
|
src_start = get_pixel_ptr_4(src, origin->x, origin->y + rc->bottom - rc->top - 1);
|
2011-09-22 09:57:58 +02:00
|
|
|
dst_stride = -dst->stride;
|
|
|
|
src_stride = -src->stride;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
dst_start = get_pixel_ptr_4(dst, rc->left, rc->top);
|
|
|
|
src_start = get_pixel_ptr_4(src, origin->x, origin->y);
|
2011-09-22 09:57:58 +02:00
|
|
|
dst_stride = dst->stride;
|
|
|
|
src_stride = src->stride;
|
|
|
|
}
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
if (rop2 == R2_COPYPEN && (left & 1) == 0 && (org_x & 1) == 0 && (right & 1) == 0)
|
2011-09-22 09:57:58 +02:00
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
2012-04-27 14:44:53 +02:00
|
|
|
memmove( dst_start, src_start, (right - left) / 2 );
|
2011-08-02 15:11:08 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-09-22 09:57:58 +02:00
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
{
|
|
|
|
if (overlap & OVERLAP_RIGHT)
|
2012-04-27 14:44:53 +02:00
|
|
|
do_rop_codes_line_rev_4( dst_start, left & 1, src_start, org_x & 1, &codes, right - left );
|
2011-09-22 09:57:58 +02:00
|
|
|
else
|
2012-04-27 14:44:53 +02:00
|
|
|
do_rop_codes_line_4( dst_start, left & 1, src_start, org_x & 1, &codes, right - left );
|
2011-09-22 09:57:58 +02:00
|
|
|
}
|
2011-08-02 15:11:08 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 10:43:10 +02:00
|
|
|
static inline void copy_rect_bits_partial_1( BYTE *dst_start, int dst_x, const BYTE *src_start, int src_x,
|
|
|
|
const SIZE *size, int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const BYTE *src;
|
|
|
|
BYTE *dst, src_val, mask;
|
|
|
|
int dst_end = dst_x + size->cx, y;
|
|
|
|
int off = (src_x & 7) - (dst_x & 7);
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
src_start += src_x / 8;
|
|
|
|
dst_start += dst_x / 8;
|
|
|
|
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride)
|
|
|
|
{
|
|
|
|
dst = dst_start;
|
|
|
|
src = src_start;
|
|
|
|
if (off == 0)
|
|
|
|
src_val = src[0];
|
|
|
|
else if (off > 0)
|
|
|
|
{
|
|
|
|
src_val = src[0] << off;
|
|
|
|
if ((dst_end & 7) + off > 8)
|
|
|
|
src_val |= (src[1] >> (8 - off));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
src_val = src[0] >> -off;
|
|
|
|
|
|
|
|
mask = edge_masks_1[dst_x & 7];
|
|
|
|
if (dst_end & 7)
|
|
|
|
mask &= ~edge_masks_1[dst_end & 7];
|
|
|
|
do_rop_codes_mask_8( dst, src_val, &codes, mask );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_rect_bits_align_1( BYTE *dst_start, int dst_x, const BYTE *src_start, int src_x,
|
|
|
|
const SIZE *size, int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const BYTE *src;
|
|
|
|
BYTE *dst, mask;
|
|
|
|
int y, i, full_bytes, dst_end = dst_x + size->cx;
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
src_start += src_x / 8;
|
|
|
|
dst_start += dst_x / 8;
|
|
|
|
full_bytes = (dst_end - ((dst_x + 7) & ~7)) / 8;
|
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
switch( rop2 )
|
2016-08-25 10:43:10 +02:00
|
|
|
{
|
2016-08-25 10:43:11 +02:00
|
|
|
case R2_COPYPEN:
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride)
|
2016-08-25 10:43:10 +02:00
|
|
|
{
|
2016-08-25 10:43:11 +02:00
|
|
|
dst = dst_start;
|
|
|
|
src = src_start;
|
|
|
|
if (dst_x & 7)
|
|
|
|
{
|
|
|
|
mask = edge_masks_1[dst_x & 7];
|
|
|
|
do_rop_codes_mask_8( dst, src[0], &codes, mask );
|
|
|
|
src++;
|
|
|
|
dst++;
|
|
|
|
}
|
2016-08-25 10:43:10 +02:00
|
|
|
memmove( dst, src, full_bytes );
|
|
|
|
src += full_bytes;
|
|
|
|
dst += full_bytes;
|
2016-08-25 10:43:11 +02:00
|
|
|
if (dst_end & 7)
|
|
|
|
{
|
|
|
|
mask = ~edge_masks_1[dst_end & 7];
|
|
|
|
do_rop_codes_mask_8( dst, src[0], &codes, mask );
|
|
|
|
}
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
2016-08-25 10:43:11 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride) \
|
|
|
|
{ \
|
|
|
|
dst = dst_start; \
|
|
|
|
src = src_start; \
|
|
|
|
if (dst_x & 7) \
|
|
|
|
{ \
|
|
|
|
mask = edge_masks_1[dst_x & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src[0], &codes, mask ); \
|
|
|
|
src++; \
|
|
|
|
dst++; \
|
|
|
|
} \
|
|
|
|
for (i = 0; i < full_bytes; i++, src++, dst++) \
|
|
|
|
op; \
|
|
|
|
if (dst_end & 7) \
|
|
|
|
{ \
|
|
|
|
mask = ~edge_masks_1[dst_end & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src[0], &codes, mask ); \
|
|
|
|
} \
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
ROPS_WITHOUT_COPY( dst[0], src[0] );
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
2016-08-25 10:43:11 +02:00
|
|
|
#undef LOOP
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_rect_bits_shl_1( BYTE *dst_start, int dst_x, const BYTE *src_start, int src_x,
|
|
|
|
const SIZE *size, int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const BYTE *src;
|
|
|
|
BYTE *dst, mask, src_val;
|
|
|
|
int y, i, full_bytes, dst_end = dst_x + size->cx;
|
|
|
|
int off = (src_x & 7) - (dst_x & 7);
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
src_start += src_x / 8;
|
|
|
|
dst_start += dst_x / 8;
|
|
|
|
full_bytes = (dst_end - ((dst_x + 7) & ~7)) / 8;
|
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride) \
|
|
|
|
{ \
|
|
|
|
dst = dst_start; \
|
|
|
|
src = src_start; \
|
|
|
|
if (dst_x & 7) \
|
|
|
|
{ \
|
|
|
|
src_val = (src[0] << off) | (src[1] >> (8 - off)); \
|
|
|
|
mask = edge_masks_1[dst_x & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src_val, &codes, mask ); \
|
|
|
|
src++; \
|
|
|
|
dst++; \
|
|
|
|
} \
|
|
|
|
for (i = 0; i < full_bytes; i++, src++, dst++) \
|
|
|
|
op; \
|
|
|
|
if (dst_end & 7) \
|
|
|
|
{ \
|
|
|
|
src_val = src[0] << off; \
|
|
|
|
if ((dst_end & 7) + off > 8) \
|
|
|
|
src_val |= (src[1] >> (8 - off)); \
|
|
|
|
mask = ~edge_masks_1[dst_end & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src_val, &codes, mask ); \
|
|
|
|
} \
|
|
|
|
}
|
2016-08-25 10:43:10 +02:00
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
switch( rop2 )
|
|
|
|
{
|
|
|
|
ROPS_ALL( dst[0], ((src[0] << off) | (src[1] >> (8 - off))) );
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
2016-08-25 10:43:11 +02:00
|
|
|
#undef LOOP
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_rect_bits_shr_1( BYTE *dst_start, int dst_x, const BYTE *src_start, int src_x,
|
|
|
|
const SIZE *size, int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const BYTE *src;
|
|
|
|
BYTE *dst, mask, src_val, last_src;
|
|
|
|
int y, i, full_bytes, dst_end = dst_x + size->cx;
|
|
|
|
int off = (src_x & 7) - (dst_x & 7);
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
src_start += src_x / 8;
|
|
|
|
dst_start += dst_x / 8;
|
|
|
|
full_bytes = (dst_end - ((dst_x + 7) & ~7)) / 8;
|
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride) \
|
|
|
|
{ \
|
|
|
|
dst = dst_start; \
|
|
|
|
src = src_start; \
|
|
|
|
last_src = 0; \
|
|
|
|
if (dst_x & 7) \
|
|
|
|
{ \
|
|
|
|
last_src = src[0]; \
|
|
|
|
mask = edge_masks_1[dst_x & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src[0] >> -off, &codes, mask ); \
|
|
|
|
src++; \
|
|
|
|
dst++; \
|
|
|
|
} \
|
|
|
|
for (i = 0; i < full_bytes; i++, src++, dst++) \
|
|
|
|
{ \
|
|
|
|
src_val = (last_src << (8 + off)) | (src[0] >> -off); \
|
|
|
|
last_src = src[0]; \
|
|
|
|
op; \
|
|
|
|
} \
|
|
|
|
if (dst_end & 7) \
|
|
|
|
{ \
|
|
|
|
src_val = last_src << (8 + off); \
|
|
|
|
if ((dst_end & 7) + off > 0) \
|
|
|
|
src_val |= (src[0] >> -off); \
|
|
|
|
mask = ~edge_masks_1[dst_end & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src_val, &codes, mask ); \
|
|
|
|
} \
|
|
|
|
}
|
2016-08-25 10:43:10 +02:00
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
switch( rop2 )
|
|
|
|
{
|
|
|
|
ROPS_ALL( dst[0], src_val )
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
2016-08-25 10:43:11 +02:00
|
|
|
#undef LOOP
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_rect_bits_rev_align_1( BYTE *dst_start, int dst_x, const BYTE *src_start, int src_x,
|
|
|
|
const SIZE *size, int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const BYTE *src;
|
|
|
|
BYTE *dst, mask;
|
|
|
|
int y, i, full_bytes, dst_end = dst_x + size->cx, src_end = src_x + size->cx;
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
src_start += (src_end - 1) / 8;
|
|
|
|
dst_start += (dst_end - 1) / 8;
|
|
|
|
full_bytes = (dst_end - ((dst_x + 7) & ~7)) / 8;
|
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
switch( rop2 )
|
2016-08-25 10:43:10 +02:00
|
|
|
{
|
2016-08-25 10:43:11 +02:00
|
|
|
case R2_COPYPEN:
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride)
|
2016-08-25 10:43:10 +02:00
|
|
|
{
|
2016-08-25 10:43:11 +02:00
|
|
|
dst = dst_start;
|
|
|
|
src = src_start;
|
|
|
|
if (dst_end & 7)
|
|
|
|
{
|
|
|
|
mask = ~edge_masks_1[dst_end & 7];
|
|
|
|
do_rop_codes_mask_8( dst, src[0], &codes, mask );
|
|
|
|
src--;
|
|
|
|
dst--;
|
|
|
|
}
|
2016-08-25 10:43:10 +02:00
|
|
|
memmove( dst, src, full_bytes );
|
|
|
|
src -= full_bytes;
|
|
|
|
dst -= full_bytes;
|
2016-08-25 10:43:11 +02:00
|
|
|
if (dst_x & 7)
|
|
|
|
{
|
|
|
|
mask = edge_masks_1[dst_x & 7];
|
|
|
|
do_rop_codes_mask_8( dst, src[0], &codes, mask );
|
|
|
|
}
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
2016-08-25 10:43:11 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride) \
|
|
|
|
{ \
|
|
|
|
dst = dst_start; \
|
|
|
|
src = src_start; \
|
|
|
|
if (dst_end & 7) \
|
|
|
|
{ \
|
|
|
|
mask = ~edge_masks_1[dst_end & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src[0], &codes, mask ); \
|
|
|
|
src--; \
|
|
|
|
dst--; \
|
|
|
|
} \
|
|
|
|
for (i = 0; i < full_bytes; i++, src--, dst--) \
|
|
|
|
op; \
|
|
|
|
if (dst_x & 7) \
|
|
|
|
{ \
|
|
|
|
mask = edge_masks_1[dst_x & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src[0], &codes, mask ); \
|
|
|
|
} \
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
ROPS_WITHOUT_COPY( dst[0], src[0] );
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
2016-08-25 10:43:11 +02:00
|
|
|
#undef LOOP
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_rect_bits_rev_shl_1( BYTE *dst_start, int dst_x, const BYTE *src_start, int src_x,
|
|
|
|
const SIZE *size, int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const BYTE *src;
|
|
|
|
BYTE *dst, mask, src_val, last_src;
|
|
|
|
int y, i, full_bytes, dst_end = dst_x + size->cx, src_end = src_x + size->cx;
|
|
|
|
int off = ((src_end - 1) & 7) - ((dst_end - 1) & 7);
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
src_start += (src_end - 1) / 8;
|
|
|
|
dst_start += (dst_end - 1) / 8;
|
|
|
|
full_bytes = (dst_end - ((dst_x + 7) & ~7)) / 8;
|
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride) \
|
|
|
|
{ \
|
|
|
|
dst = dst_start; \
|
|
|
|
src = src_start; \
|
|
|
|
last_src = 0; \
|
|
|
|
if (dst_end & 7) \
|
|
|
|
{ \
|
|
|
|
last_src = src[0]; \
|
|
|
|
mask = ~edge_masks_1[dst_end & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src[0] << off, &codes, mask ); \
|
|
|
|
src--; \
|
|
|
|
dst--; \
|
|
|
|
} \
|
|
|
|
for (i = 0; i < full_bytes; i++, src--, dst--) \
|
|
|
|
{ \
|
|
|
|
src_val = (src[0] << off) | (last_src >> (8 - off)); \
|
|
|
|
last_src = src[0]; \
|
|
|
|
op; \
|
|
|
|
} \
|
|
|
|
if (dst_x & 7) \
|
|
|
|
{ \
|
|
|
|
src_val = last_src >> (8 - off); \
|
|
|
|
if ((dst_x & 7) + off < 8) \
|
|
|
|
src_val |= (src[0] << off); \
|
|
|
|
mask = edge_masks_1[dst_x & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src_val, &codes, mask ); \
|
|
|
|
} \
|
|
|
|
}
|
2016-08-25 10:43:10 +02:00
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
switch( rop2 )
|
|
|
|
{
|
|
|
|
ROPS_ALL( dst[0], src_val );
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
2016-08-25 10:43:11 +02:00
|
|
|
#undef LOOP
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_rect_bits_rev_shr_1( BYTE *dst_start, int dst_x, const BYTE *src_start, int src_x,
|
|
|
|
const SIZE *size, int dst_stride, int src_stride, int rop2 )
|
|
|
|
{
|
|
|
|
const BYTE *src;
|
|
|
|
BYTE *dst, mask, src_val;
|
|
|
|
int y, i, full_bytes, dst_end = dst_x + size->cx, src_end = src_x + size->cx;
|
|
|
|
int off = ((src_end - 1) & 7) - ((dst_end - 1) & 7);
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
src_start += (src_end - 1) / 8;
|
|
|
|
dst_start += (dst_end - 1) / 8;
|
|
|
|
full_bytes = (dst_end - ((dst_x + 7) & ~7)) / 8;
|
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = 0; y < size->cy; y++, dst_start += dst_stride, src_start += src_stride) \
|
|
|
|
{ \
|
|
|
|
dst = dst_start; \
|
|
|
|
src = src_start; \
|
|
|
|
if (dst_end & 7) \
|
|
|
|
{ \
|
|
|
|
mask = edge_masks_1[dst_x & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, (src[-1] << (8 + off)) | (src[0] >> -off), &codes, mask ); \
|
|
|
|
src--; \
|
|
|
|
dst--; \
|
|
|
|
} \
|
|
|
|
for (i = 0; i < full_bytes; i++, src--, dst--) \
|
|
|
|
op; \
|
|
|
|
if (dst_x & 7) \
|
|
|
|
{ \
|
|
|
|
src_val = src[0] >> -off; \
|
|
|
|
if ((dst_x & 7) + off < 0) \
|
|
|
|
src_val |= (src[-1] << (8 + off)); \
|
|
|
|
mask = edge_masks_1[dst_x & 7]; \
|
|
|
|
do_rop_codes_mask_8( dst, src_val, &codes, mask ); \
|
|
|
|
} \
|
|
|
|
}
|
2016-08-25 10:43:10 +02:00
|
|
|
|
2016-08-25 10:43:11 +02:00
|
|
|
switch( rop2 )
|
|
|
|
{
|
|
|
|
ROPS_ALL( dst[0], (src[-1] << (8 + off)) | (src[0] >> -off) );
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
2016-08-25 10:43:11 +02:00
|
|
|
#undef LOOP
|
2016-08-25 10:43:10 +02:00
|
|
|
}
|
|
|
|
|
2011-08-02 15:11:08 +02:00
|
|
|
static void copy_rect_1(const dib_info *dst, const RECT *rc,
|
2011-09-22 09:57:58 +02:00
|
|
|
const dib_info *src, const POINT *origin, int rop2, int overlap)
|
2011-08-02 15:11:08 +02:00
|
|
|
{
|
2011-09-22 09:57:58 +02:00
|
|
|
BYTE *dst_start, *src_start;
|
|
|
|
int y, dst_stride, src_stride;
|
2012-04-27 14:44:53 +02:00
|
|
|
int left = dst->rect.left + rc->left;
|
|
|
|
int right = dst->rect.left + rc->right;
|
|
|
|
int org_x = src->rect.left + origin->x;
|
2016-08-25 10:43:10 +02:00
|
|
|
SIZE size;
|
2011-08-02 15:11:08 +02:00
|
|
|
|
2011-09-22 09:57:58 +02:00
|
|
|
if (overlap & OVERLAP_BELOW)
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
dst_start = get_pixel_ptr_1(dst, rc->left, rc->bottom - 1);
|
|
|
|
src_start = get_pixel_ptr_1(src, origin->x, origin->y + rc->bottom - rc->top - 1);
|
2011-09-22 09:57:58 +02:00
|
|
|
dst_stride = -dst->stride;
|
|
|
|
src_stride = -src->stride;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
dst_start = get_pixel_ptr_1(dst, rc->left, rc->top);
|
|
|
|
src_start = get_pixel_ptr_1(src, origin->x, origin->y);
|
2011-09-22 09:57:58 +02:00
|
|
|
dst_stride = dst->stride;
|
|
|
|
src_stride = src->stride;
|
|
|
|
}
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
if (rop2 == R2_COPYPEN && (left & 7) == 0 && (org_x & 7) == 0 && (right & 7) == 0)
|
2011-09-22 09:57:58 +02:00
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_start += dst_stride, src_start += src_stride)
|
2012-04-27 14:44:53 +02:00
|
|
|
memmove( dst_start, src_start, (right - left) / 8 );
|
2011-08-02 15:11:08 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-09-22 09:57:58 +02:00
|
|
|
|
2016-08-25 10:43:10 +02:00
|
|
|
size.cx = right - left;
|
|
|
|
size.cy = rc->bottom - rc->top;
|
|
|
|
|
|
|
|
/* Special case starting and finishing in same byte, neither on byte boundary */
|
|
|
|
if ((left & 7) && (right & 7) && (left & ~7) == (right & ~7))
|
|
|
|
copy_rect_bits_partial_1( dst_start, left & 7, src_start, org_x & 7, &size, dst_stride, src_stride, rop2 );
|
|
|
|
else if (overlap & OVERLAP_RIGHT)
|
2011-09-22 09:57:58 +02:00
|
|
|
{
|
2016-08-25 10:43:10 +02:00
|
|
|
int off = ((org_x + right - left - 1) & 7) - ((right - 1) & 7);
|
|
|
|
|
|
|
|
if (off == 0)
|
|
|
|
copy_rect_bits_rev_align_1( dst_start, left & 7, src_start, org_x & 7, &size, dst_stride, src_stride, rop2 );
|
|
|
|
else if (off > 0)
|
|
|
|
copy_rect_bits_rev_shl_1( dst_start, left & 7, src_start, org_x & 7, &size, dst_stride, src_stride, rop2 );
|
|
|
|
else
|
|
|
|
copy_rect_bits_rev_shr_1( dst_start, left & 7, src_start, org_x & 7, &size, dst_stride, src_stride, rop2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int off = (org_x & 7) - (left & 7);
|
|
|
|
|
|
|
|
if (off == 0)
|
|
|
|
copy_rect_bits_align_1( dst_start, left & 7, src_start, org_x & 7, &size, dst_stride, src_stride, rop2 );
|
|
|
|
else if (off > 0)
|
|
|
|
copy_rect_bits_shl_1( dst_start, left & 7, src_start, org_x & 7, &size, dst_stride, src_stride, rop2 );
|
2011-09-22 09:57:58 +02:00
|
|
|
else
|
2016-08-25 10:43:10 +02:00
|
|
|
copy_rect_bits_shr_1( dst_start, left & 7, src_start, org_x & 7, &size, dst_stride, src_stride, rop2 );
|
2011-09-22 09:57:58 +02:00
|
|
|
}
|
2011-08-02 15:11:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_rect_null(const dib_info *dst, const RECT *rc,
|
2011-09-22 09:57:58 +02:00
|
|
|
const dib_info *src, const POINT *origin, int rop2, int overlap)
|
2011-08-02 15:11:08 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-18 15:48:24 +01:00
|
|
|
static DWORD get_pixel_32(const dib_info *dib, int x, int y)
|
2011-10-19 13:41:57 +02:00
|
|
|
{
|
2012-01-18 15:48:24 +01:00
|
|
|
DWORD *ptr = get_pixel_ptr_32( dib, x, y );
|
2011-10-19 13:41:57 +02:00
|
|
|
return *ptr;
|
|
|
|
}
|
|
|
|
|
2012-01-18 15:48:24 +01:00
|
|
|
static DWORD get_pixel_24(const dib_info *dib, int x, int y)
|
2011-10-19 13:41:57 +02:00
|
|
|
{
|
2012-01-18 15:48:24 +01:00
|
|
|
BYTE *ptr = get_pixel_ptr_24( dib, x, y );
|
2011-10-19 13:41:57 +02:00
|
|
|
return ptr[0] | ((DWORD)ptr[1] << 8) | ((DWORD)ptr[2] << 16);
|
|
|
|
}
|
|
|
|
|
2012-01-18 15:48:24 +01:00
|
|
|
static DWORD get_pixel_16(const dib_info *dib, int x, int y)
|
2011-10-19 13:41:57 +02:00
|
|
|
{
|
2012-01-18 15:48:24 +01:00
|
|
|
WORD *ptr = get_pixel_ptr_16( dib, x, y );
|
2011-10-19 13:41:57 +02:00
|
|
|
return *ptr;
|
|
|
|
}
|
|
|
|
|
2012-01-18 15:48:24 +01:00
|
|
|
static DWORD get_pixel_8(const dib_info *dib, int x, int y)
|
2011-10-19 13:41:57 +02:00
|
|
|
{
|
2012-01-18 15:48:24 +01:00
|
|
|
BYTE *ptr = get_pixel_ptr_8( dib, x, y );
|
2011-10-19 13:41:57 +02:00
|
|
|
return *ptr;
|
|
|
|
}
|
|
|
|
|
2012-01-18 15:48:24 +01:00
|
|
|
static DWORD get_pixel_4(const dib_info *dib, int x, int y)
|
2011-10-19 13:41:57 +02:00
|
|
|
{
|
2012-01-18 15:48:24 +01:00
|
|
|
BYTE *ptr = get_pixel_ptr_4( dib, x, y );
|
2011-10-19 13:41:57 +02:00
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
if ((dib->rect.left + x) & 1)
|
2011-10-19 13:41:57 +02:00
|
|
|
return *ptr & 0x0f;
|
|
|
|
else
|
|
|
|
return (*ptr >> 4) & 0x0f;
|
|
|
|
}
|
|
|
|
|
2012-01-18 15:48:24 +01:00
|
|
|
static DWORD get_pixel_1(const dib_info *dib, int x, int y)
|
2011-10-19 13:41:57 +02:00
|
|
|
{
|
2012-01-18 15:48:24 +01:00
|
|
|
BYTE *ptr = get_pixel_ptr_1( dib, x, y );
|
2012-04-27 14:44:53 +02:00
|
|
|
return (*ptr & pixel_masks_1[(dib->rect.left + x) & 7]) ? 1 : 0;
|
2011-10-19 13:41:57 +02:00
|
|
|
}
|
|
|
|
|
2012-01-18 15:48:24 +01:00
|
|
|
static DWORD get_pixel_null(const dib_info *dib, int x, int y)
|
2011-10-19 13:41:57 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-05 14:23:20 +02:00
|
|
|
static DWORD colorref_to_pixel_888(const dib_info *dib, COLORREF color)
|
|
|
|
{
|
|
|
|
return ( ((color >> 16) & 0xff) | (color & 0xff00) | ((color << 16) & 0xff0000) );
|
|
|
|
}
|
|
|
|
|
2011-10-12 23:25:32 +02:00
|
|
|
static const DWORD field_masks[33] =
|
|
|
|
{
|
|
|
|
0x00, /* should never happen */
|
|
|
|
0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline DWORD get_field(DWORD field, int shift, int len)
|
|
|
|
{
|
|
|
|
shift = shift - (8 - len);
|
|
|
|
if (shift < 0)
|
|
|
|
field <<= -shift;
|
|
|
|
else
|
|
|
|
field >>= shift;
|
|
|
|
field &= field_masks[len];
|
|
|
|
field |= field >> len;
|
|
|
|
return field;
|
|
|
|
}
|
|
|
|
|
2011-04-05 14:26:08 +02:00
|
|
|
static inline DWORD put_field(DWORD field, int shift, int len)
|
|
|
|
{
|
|
|
|
shift = shift - (8 - len);
|
2011-10-12 23:25:32 +02:00
|
|
|
field &= field_masks[len];
|
2011-04-05 14:26:08 +02:00
|
|
|
if (shift < 0)
|
|
|
|
field >>= -shift;
|
|
|
|
else
|
|
|
|
field <<= shift;
|
|
|
|
return field;
|
|
|
|
}
|
|
|
|
|
2017-03-08 20:57:41 +01:00
|
|
|
static DWORD rgb_to_pixel_masks(const dib_info *dib, DWORD r, DWORD g, DWORD b)
|
2011-04-05 14:26:08 +02:00
|
|
|
{
|
|
|
|
return put_field(r, dib->red_shift, dib->red_len) |
|
|
|
|
put_field(g, dib->green_shift, dib->green_len) |
|
|
|
|
put_field(b, dib->blue_shift, dib->blue_len);
|
|
|
|
}
|
|
|
|
|
2017-03-08 20:57:41 +01:00
|
|
|
static DWORD rgbquad_to_pixel_masks(const dib_info *dib, RGBQUAD rgb)
|
|
|
|
{
|
|
|
|
return rgb_to_pixel_masks(dib, rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD colorref_to_pixel_masks(const dib_info *dib, COLORREF colour)
|
|
|
|
{
|
|
|
|
return rgb_to_pixel_masks(dib, GetRValue(colour), GetGValue(colour), GetBValue(colour));
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
static DWORD colorref_to_pixel_555(const dib_info *dib, COLORREF color)
|
|
|
|
{
|
|
|
|
return ( ((color >> 19) & 0x1f) | ((color >> 6) & 0x03e0) | ((color << 7) & 0x7c00) );
|
|
|
|
}
|
|
|
|
|
2011-10-13 11:21:58 +02:00
|
|
|
static DWORD rgb_to_pixel_colortable(const dib_info *dib, BYTE r, BYTE g, BYTE b)
|
2011-05-27 15:26:02 +02:00
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( dib );
|
|
|
|
int size = dib->color_table ? dib->color_table_size : 1 << dib->bit_count;
|
2011-05-27 15:26:02 +02:00
|
|
|
int i, best_index = 0;
|
|
|
|
DWORD diff, best_diff = 0xffffffff;
|
|
|
|
|
2012-05-23 11:34:22 +02:00
|
|
|
for(i = 0; i < size; i++)
|
2011-05-27 15:26:02 +02:00
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *cur = color_table + i;
|
2011-10-13 11:21:58 +02:00
|
|
|
diff = (r - cur->rgbRed) * (r - cur->rgbRed)
|
|
|
|
+ (g - cur->rgbGreen) * (g - cur->rgbGreen)
|
|
|
|
+ (b - cur->rgbBlue) * (b - cur->rgbBlue);
|
2011-05-27 15:26:02 +02:00
|
|
|
|
|
|
|
if(diff == 0)
|
|
|
|
{
|
|
|
|
best_index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(diff < best_diff)
|
|
|
|
{
|
|
|
|
best_diff = diff;
|
|
|
|
best_index = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return best_index;
|
|
|
|
}
|
2011-05-27 14:10:29 +02:00
|
|
|
|
2017-03-08 21:03:59 +01:00
|
|
|
static DWORD rgb_to_pixel_mono(const dib_info *dib, BOOL dither, int x, int y,
|
|
|
|
DWORD src_pixel, DWORD bg_pixel, BYTE r, BYTE g, BYTE b)
|
2012-05-22 10:57:01 +02:00
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2017-03-09 12:30:20 +01:00
|
|
|
if (dib->color_table_size != 1)
|
|
|
|
{
|
|
|
|
if (dither)
|
|
|
|
{
|
|
|
|
if (((30 * r + 59 * g + 11 * b) / 100 + bayer_16x16[y % 16][x % 16]) > 255) r = g = b = 255;
|
|
|
|
else r = g = b = 0;
|
|
|
|
}
|
2017-03-08 21:03:59 +01:00
|
|
|
ret = rgb_to_pixel_colortable( dib, r, g, b );
|
2017-03-09 12:30:20 +01:00
|
|
|
}
|
|
|
|
else ret = (src_pixel == bg_pixel); /* only match raw pixel value */
|
2012-05-22 10:57:01 +02:00
|
|
|
|
|
|
|
return ret ? 0xff : 0;
|
|
|
|
}
|
|
|
|
|
2017-03-08 20:57:41 +01:00
|
|
|
static DWORD rgbquad_to_pixel_colortable(const dib_info *dib, RGBQUAD rgb)
|
|
|
|
{
|
|
|
|
return rgb_to_pixel_colortable( dib, rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue );
|
|
|
|
}
|
|
|
|
|
2011-10-13 11:21:58 +02:00
|
|
|
static DWORD colorref_to_pixel_colortable(const dib_info *dib, COLORREF color)
|
|
|
|
{
|
|
|
|
return rgb_to_pixel_colortable( dib, GetRValue(color), GetGValue(color), GetBValue(color) );
|
|
|
|
}
|
|
|
|
|
2011-04-05 14:23:20 +02:00
|
|
|
static DWORD colorref_to_pixel_null(const dib_info *dib, COLORREF color)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-19 13:41:54 +02:00
|
|
|
static COLORREF pixel_to_colorref_888(const dib_info *dib, DWORD pixel)
|
|
|
|
{
|
|
|
|
return ( ((pixel >> 16) & 0xff) | (pixel & 0xff00) | ((pixel << 16) & 0xff0000) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static COLORREF pixel_to_colorref_masks(const dib_info *dib, DWORD pixel)
|
|
|
|
{
|
|
|
|
return RGB( get_field( pixel, dib->red_shift, dib->red_len ),
|
|
|
|
get_field( pixel, dib->green_shift, dib->green_len ),
|
|
|
|
get_field( pixel, dib->blue_shift, dib->blue_len ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static COLORREF pixel_to_colorref_555(const dib_info *dib, DWORD pixel)
|
|
|
|
{
|
|
|
|
return RGB( ((pixel >> 7) & 0xf8) | ((pixel >> 12) & 0x07),
|
|
|
|
((pixel >> 2) & 0xf8) | ((pixel >> 7) & 0x07),
|
|
|
|
((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x07) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static COLORREF pixel_to_colorref_colortable(const dib_info *dib, DWORD pixel)
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( dib );
|
|
|
|
|
|
|
|
if (!dib->color_table || pixel < dib->color_table_size)
|
2011-12-12 20:52:41 +01:00
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
RGBQUAD quad = color_table[pixel];
|
2011-12-12 20:52:41 +01:00
|
|
|
return RGB( quad.rgbRed, quad.rgbGreen, quad.rgbBlue );
|
|
|
|
}
|
|
|
|
return 0;
|
2011-10-19 13:41:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static COLORREF pixel_to_colorref_null(const dib_info *dib, DWORD pixel)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-13 14:04:58 +02:00
|
|
|
static inline BOOL bit_fields_match(const dib_info *d1, const dib_info *d2)
|
|
|
|
{
|
|
|
|
assert( d1->bit_count > 8 && d1->bit_count == d2->bit_count );
|
|
|
|
|
|
|
|
return d1->red_mask == d2->red_mask &&
|
|
|
|
d1->green_mask == d2->green_mask &&
|
|
|
|
d1->blue_mask == d2->blue_mask;
|
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_8888(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-05-27 14:41:32 +02:00
|
|
|
{
|
2011-08-19 17:26:15 +02:00
|
|
|
DWORD *dst_start = get_pixel_ptr_32(dst, 0, 0), *dst_pixel, src_val;
|
2011-07-15 15:19:09 +02:00
|
|
|
int x, y, pad_size = (dst->width - (src_rect->right - src_rect->left)) * 4;
|
2011-05-27 14:41:32 +02:00
|
|
|
|
|
|
|
switch(src->bit_count)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
{
|
2011-07-13 14:04:59 +02:00
|
|
|
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
|
2011-05-27 14:41:32 +02:00
|
|
|
if(src->funcs == &funcs_8888)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (src->stride > 0 && src->stride == dst->stride && !pad_size)
|
2011-08-19 17:26:15 +02:00
|
|
|
memcpy(dst_start, src_start, (src_rect->bottom - src_rect->top) * src->stride);
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
memcpy(dst_start, src_start, (src_rect->right - src_rect->left) * 4);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_start + (src_rect->right - src_rect->left), 0, pad_size);
|
2011-05-27 14:41:32 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
else if(src->red_len == 8 && src->green_len == 8 && src->blue_len == 8)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) & 0xff) << 16) |
|
|
|
|
(((src_val >> src->green_shift) & 0xff) << 8) |
|
|
|
|
((src_val >> src->blue_shift) & 0xff);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:04:59 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-12 23:25:32 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (get_field( src_val, src->red_shift, src->red_len ) << 16 |
|
|
|
|
get_field( src_val, src->green_shift, src->green_len ) << 8 |
|
|
|
|
get_field( src_val, src->blue_shift, src->blue_len ));
|
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:41 +02:00
|
|
|
case 24:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
RGBQUAD rgb;
|
|
|
|
rgb.rgbBlue = *src_pixel++;
|
|
|
|
rgb.rgbGreen = *src_pixel++;
|
|
|
|
rgb.rgbRed = *src_pixel++;
|
|
|
|
|
|
|
|
*dst_pixel++ = ((rgb.rgbRed << 16) & 0xff0000) | ((rgb.rgbGreen << 8) & 0x00ff00) | (rgb.rgbBlue & 0x0000ff);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-06-01 10:41:41 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:41:32 +02:00
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
if(src->funcs == &funcs_555)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = ((src_val << 9) & 0xf80000) | ((src_val << 4) & 0x070000) |
|
|
|
|
((src_val << 6) & 0x00f800) | ((src_val << 1) & 0x000700) |
|
|
|
|
((src_val << 3) & 0x0000f8) | ((src_val >> 2) & 0x000007);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 14:41:32 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
else if(src->red_len == 5 && src->green_len == 5 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) << 19) & 0xf80000) |
|
|
|
|
(((src_val >> src->red_shift) << 14) & 0x070000) |
|
|
|
|
(((src_val >> src->green_shift) << 11) & 0x00f800) |
|
|
|
|
(((src_val >> src->green_shift) << 6) & 0x000700) |
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0x0000f8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x000007);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(src->red_len == 5 && src->green_len == 6 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) << 19) & 0xf80000) |
|
|
|
|
(((src_val >> src->red_shift) << 14) & 0x070000) |
|
|
|
|
(((src_val >> src->green_shift) << 10) & 0x00fc00) |
|
|
|
|
(((src_val >> src->green_shift) << 4) & 0x000300) |
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0x0000f8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x000007);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-13 00:12:04 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (get_field( src_val, src->red_shift, src->red_len ) << 16 |
|
|
|
|
get_field( src_val, src->green_shift, src->green_len ) << 8 |
|
|
|
|
get_field( src_val, src->blue_shift, src->blue_len ));
|
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
case 8:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-27 15:36:55 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
DWORD dst_colors[256], i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_colors[i] = color_table[i].rgbRed << 16 | color_table[i].rgbGreen << 8 |
|
|
|
|
color_table[i].rgbBlue;
|
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
2016-07-07 09:44:32 +02:00
|
|
|
*dst_pixel++ = dst_colors[*src_pixel++];
|
|
|
|
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 15:36:55 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
case 4:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-31 11:02:05 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
DWORD dst_colors[16], i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_colors[i] = color_table[i].rgbRed << 16 | color_table[i].rgbGreen << 8 |
|
|
|
|
color_table[i].rgbBlue;
|
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 1;
|
2011-05-31 11:02:05 +02:00
|
|
|
src_pixel = src_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-05-31 11:02:05 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (pos & 1)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel++ & 0xf];
|
2011-05-31 11:02:05 +02:00
|
|
|
else
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel >> 4];
|
2011-05-31 11:02:05 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-05-31 11:02:05 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
case 1:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2012-04-27 14:44:53 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
|
2016-07-07 09:44:32 +02:00
|
|
|
DWORD dst_colors[2], i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_colors[i] = color_table[i].rgbRed << 16 | color_table[i].rgbGreen << 8 |
|
|
|
|
color_table[i].rgbBlue;
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 7;
|
|
|
|
for(x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-06-15 14:43:51 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
src_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[src_val];
|
2011-06-15 14:43:51 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_32(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-05-27 14:41:32 +02:00
|
|
|
{
|
2011-08-19 17:26:15 +02:00
|
|
|
DWORD *dst_start = get_pixel_ptr_32(dst, 0, 0), *dst_pixel, src_val;
|
2011-07-15 15:19:09 +02:00
|
|
|
int x, y, pad_size = (dst->width - (src_rect->right - src_rect->left)) * 4;
|
2011-05-27 14:41:32 +02:00
|
|
|
|
|
|
|
switch(src->bit_count)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
if(src->funcs == &funcs_8888)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst, src_val >> 16, src_val >> 8, src_val);
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 14:41:32 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:58 +02:00
|
|
|
else if(bit_fields_match(src, dst))
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (src->stride > 0 && src->stride == dst->stride && !pad_size)
|
2011-08-19 17:26:15 +02:00
|
|
|
memcpy(dst_start, src_start, (src_rect->bottom - src_rect->top) * src->stride);
|
2011-07-13 14:04:58 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
memcpy(dst_start, src_start, (src_rect->right - src_rect->left) * 4);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_start + (src_rect->right - src_rect->left), 0, pad_size);
|
2011-07-13 14:04:58 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
else if(src->red_len == 8 && src->green_len == 8 && src->blue_len == 8 &&
|
|
|
|
dst->red_len == 8 && dst->green_len == 8 && dst->blue_len == 8)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) & 0xff) << dst->red_shift) |
|
|
|
|
(((src_val >> src->green_shift) & 0xff) << dst->green_shift) |
|
|
|
|
(((src_val >> src->blue_shift) & 0xff) << dst->blue_shift);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:04:59 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-12 23:25:32 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-12 23:25:32 +02:00
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:41 +02:00
|
|
|
case 24:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
2017-03-08 20:57:41 +01:00
|
|
|
for(x = src_rect->left; x < src_rect->right; x++, src_pixel += 3)
|
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst, src_pixel[2], src_pixel[1], src_pixel[0]);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-06-01 10:41:41 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:41:32 +02:00
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
if(src->funcs == &funcs_555)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
((src_val >> 7) & 0xf8) | ((src_val >> 12) & 0x07),
|
|
|
|
((src_val >> 2) & 0xf8) | ((src_val >> 7) & 0x07),
|
|
|
|
((src_val << 3) & 0xf8) | ((src_val >> 2) & 0x07));
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 14:41:32 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
else if(src->red_len == 5 && src->green_len == 5 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->green_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07));
|
2011-07-13 14:05:00 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(src->red_len == 5 && src->green_len == 6 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 2) & 0xfc) |
|
|
|
|
(((src_val >> src->green_shift) >> 4) & 0x03),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07));
|
2011-07-13 14:05:00 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-13 00:12:04 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-13 00:12:04 +02:00
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
case 8:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-27 15:36:55 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
DWORD dst_colors[256], i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
2016-07-07 09:44:32 +02:00
|
|
|
*dst_pixel++ = dst_colors[*src_pixel++];
|
|
|
|
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 15:36:55 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
case 4:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-31 11:02:05 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
DWORD dst_colors[16], i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 1;
|
2011-05-31 11:02:05 +02:00
|
|
|
src_pixel = src_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-05-31 11:02:05 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (pos & 1)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel++ & 0xf];
|
2011-05-31 11:02:05 +02:00
|
|
|
else
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel >> 4];
|
2011-05-31 11:02:05 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-05-31 11:02:05 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
case 1:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2012-04-27 14:44:53 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
|
2016-07-07 09:44:32 +02:00
|
|
|
DWORD dst_colors[2], i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 7;
|
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-06-15 14:43:51 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
src_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[src_val];
|
2011-06-15 14:43:51 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_24(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
2011-08-19 17:26:15 +02:00
|
|
|
BYTE *dst_start = get_pixel_ptr_24(dst, 0, 0), *dst_pixel;
|
2011-06-01 10:41:39 +02:00
|
|
|
DWORD src_val;
|
2011-07-15 15:19:09 +02:00
|
|
|
int x, y, pad_size = ((dst->width * 3 + 3) & ~3) - (src_rect->right - src_rect->left) * 3;
|
2011-06-01 10:41:39 +02:00
|
|
|
|
|
|
|
switch(src->bit_count)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
if(src->funcs == &funcs_8888)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = src_val & 0xff;
|
|
|
|
*dst_pixel++ = (src_val >> 8) & 0xff;
|
|
|
|
*dst_pixel++ = (src_val >> 16) & 0xff;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-06-01 10:41:39 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
else if(src->red_len == 8 && src->green_len == 8 && src->blue_len == 8)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (src_val >> src->blue_shift) & 0xff;
|
|
|
|
*dst_pixel++ = (src_val >> src->green_shift) & 0xff;
|
|
|
|
*dst_pixel++ = (src_val >> src->red_shift) & 0xff;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:04:59 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-12 23:25:32 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = get_field( src_val, src->blue_shift, src->blue_len );
|
|
|
|
*dst_pixel++ = get_field( src_val, src->green_shift, src->green_len );
|
|
|
|
*dst_pixel++ = get_field( src_val, src->red_shift, src->red_len );
|
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:41 +02:00
|
|
|
case 24:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top);
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
if (src->stride > 0 && src->stride == dst->stride && !pad_size)
|
2011-08-19 17:26:15 +02:00
|
|
|
memcpy(dst_start, src_start, (src_rect->bottom - src_rect->top) * src->stride);
|
2011-06-01 10:41:41 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
memcpy(dst_start, src_start, (src_rect->right - src_rect->left) * 3);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_start + (src_rect->right - src_rect->left) * 3, 0, pad_size);
|
2011-06-01 10:41:41 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:39 +02:00
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
if(src->funcs == &funcs_555)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = ((src_val << 3) & 0xf8) | ((src_val >> 2) & 0x07);
|
|
|
|
*dst_pixel++ = ((src_val >> 2) & 0xf8) | ((src_val >> 7) & 0x07);
|
|
|
|
*dst_pixel++ = ((src_val >> 7) & 0xf8) | ((src_val >> 12) & 0x07);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-06-01 10:41:39 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
else if(src->red_len == 5 && src->green_len == 5 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07);
|
|
|
|
*dst_pixel++ = (((src_val >> src->green_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->green_shift) >> 2) & 0x07);
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(src->red_len == 5 && src->green_len == 6 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07);
|
|
|
|
*dst_pixel++ = (((src_val >> src->green_shift) << 2) & 0xfc) |
|
|
|
|
(((src_val >> src->green_shift) >> 4) & 0x03);
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-13 00:12:04 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = get_field(src_val, src->blue_shift, src->blue_len );
|
|
|
|
*dst_pixel++ = get_field(src_val, src->green_shift, src->green_len );
|
|
|
|
*dst_pixel++ = get_field(src_val, src->red_shift, src->red_len );
|
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-06-01 10:41:39 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
RGBQUAD rgb = color_table[*src_pixel++];
|
2011-06-01 10:41:39 +02:00
|
|
|
*dst_pixel++ = rgb.rgbBlue;
|
|
|
|
*dst_pixel++ = rgb.rgbGreen;
|
|
|
|
*dst_pixel++ = rgb.rgbRed;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-06-01 10:41:39 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-06-01 10:41:39 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 1;
|
2011-06-01 10:41:39 +02:00
|
|
|
src_pixel = src_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-06-01 10:41:39 +02:00
|
|
|
{
|
|
|
|
RGBQUAD rgb;
|
2012-04-27 14:44:53 +02:00
|
|
|
if (pos & 1)
|
2012-05-23 11:34:22 +02:00
|
|
|
rgb = color_table[*src_pixel++ & 0xf];
|
2011-06-01 10:41:39 +02:00
|
|
|
else
|
2012-05-23 11:34:22 +02:00
|
|
|
rgb = color_table[*src_pixel >> 4];
|
2012-04-27 14:44:53 +02:00
|
|
|
dst_start[x * 3] = rgb.rgbBlue;
|
|
|
|
dst_start[x * 3 + 1] = rgb.rgbGreen;
|
|
|
|
dst_start[x * 3 + 2] = rgb.rgbRed;
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x * 3, 0, pad_size);
|
2011-06-01 10:41:39 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
case 1:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2012-04-27 14:44:53 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
|
2011-06-15 14:43:51 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 7;
|
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-06-15 14:43:51 +02:00
|
|
|
{
|
|
|
|
RGBQUAD rgb;
|
2012-04-27 14:44:53 +02:00
|
|
|
src_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
2012-05-23 11:34:22 +02:00
|
|
|
rgb = color_table[src_val];
|
2012-04-27 14:44:53 +02:00
|
|
|
dst_start[x * 3] = rgb.rgbBlue;
|
|
|
|
dst_start[x * 3 + 1] = rgb.rgbGreen;
|
|
|
|
dst_start[x * 3 + 2] = rgb.rgbRed;
|
2011-06-15 14:43:51 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x * 3, 0, pad_size);
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-06-01 10:41:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_555(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-05-27 14:41:32 +02:00
|
|
|
{
|
2011-08-19 17:26:15 +02:00
|
|
|
WORD *dst_start = get_pixel_ptr_16(dst, 0, 0), *dst_pixel;
|
2011-07-15 15:19:09 +02:00
|
|
|
INT x, y, pad_size = ((dst->width + 1) & ~1) * 2 - (src_rect->right - src_rect->left) * 2;
|
2011-05-27 14:41:32 +02:00
|
|
|
DWORD src_val;
|
|
|
|
|
|
|
|
switch(src->bit_count)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
if(src->funcs == &funcs_8888)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = ((src_val >> 9) & 0x7c00) |
|
|
|
|
((src_val >> 6) & 0x03e0) |
|
2011-06-01 10:41:43 +02:00
|
|
|
((src_val >> 3) & 0x001f);
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 14:41:32 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
else if(src->red_len == 8 && src->green_len == 8 && src->blue_len == 8)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) << 7) & 0x7c00) |
|
|
|
|
(((src_val >> src->green_shift) << 2) & 0x03e0) |
|
|
|
|
(((src_val >> src->blue_shift) >> 3) & 0x001f);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:04:59 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-12 23:25:32 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((get_field(src_val, src->red_shift, src->red_len ) << 7) & 0x7c00) |
|
|
|
|
((get_field(src_val, src->green_shift, src->green_len ) << 2) & 0x03e0) |
|
|
|
|
( get_field(src_val, src->blue_shift, src->blue_len ) >> 3));
|
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:41 +02:00
|
|
|
case 24:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
RGBQUAD rgb;
|
|
|
|
rgb.rgbBlue = *src_pixel++;
|
|
|
|
rgb.rgbGreen = *src_pixel++;
|
|
|
|
rgb.rgbRed = *src_pixel++;
|
|
|
|
|
|
|
|
*dst_pixel++ = ((rgb.rgbRed << 7) & 0x7c00) |
|
|
|
|
((rgb.rgbGreen << 2) & 0x03e0) |
|
|
|
|
((rgb.rgbBlue >> 3) & 0x001f);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-06-01 10:41:41 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:41:32 +02:00
|
|
|
case 16:
|
|
|
|
{
|
2011-07-13 14:05:00 +02:00
|
|
|
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
|
2011-05-27 14:41:32 +02:00
|
|
|
if(src->funcs == &funcs_555)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (src->stride > 0 && src->stride == dst->stride && !pad_size)
|
2011-08-19 17:26:15 +02:00
|
|
|
memcpy(dst_start, src_start, (src_rect->bottom - src_rect->top) * src->stride);
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
memcpy(dst_start, src_start, (src_rect->right - src_rect->left) * 2);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_start + (src_rect->right - src_rect->left), 0, pad_size);
|
2011-05-27 14:41:32 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
else if(src->red_len == 5 && src->green_len == 5 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) << 10) & 0x7c00) |
|
|
|
|
(((src_val >> src->green_shift) << 5) & 0x03e0) |
|
|
|
|
( (src_val >> src->blue_shift) & 0x001f);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(src->red_len == 5 && src->green_len == 6 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((src_val >> src->red_shift) << 10) & 0x7c00) |
|
|
|
|
(((src_val >> src->green_shift) << 4) & 0x03e0) |
|
|
|
|
( (src_val >> src->blue_shift) & 0x001f);
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-13 00:12:04 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
|
|
|
*dst_pixel++ = (((get_field(src_val, src->red_shift, src->red_len) << 7) & 0x7c00) |
|
|
|
|
((get_field(src_val, src->green_shift, src->green_len) << 2) & 0x03e0) |
|
|
|
|
( get_field(src_val, src->blue_shift, src->blue_len) >> 3));
|
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
case 8:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-27 15:36:55 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
WORD dst_colors[256];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_colors[i] = ((color_table[i].rgbRed << 7) & 0x7c00) |
|
|
|
|
((color_table[i].rgbGreen << 2) & 0x03e0) |
|
|
|
|
((color_table[i].rgbBlue >> 3) & 0x001f);
|
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
2016-07-07 09:44:32 +02:00
|
|
|
*dst_pixel++ = dst_colors[*src_pixel++];
|
|
|
|
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 15:36:55 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
case 4:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-31 11:02:05 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
WORD dst_colors[16];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_colors[i] = ((color_table[i].rgbRed << 7) & 0x7c00) |
|
|
|
|
((color_table[i].rgbGreen << 2) & 0x03e0) |
|
|
|
|
((color_table[i].rgbBlue >> 3) & 0x001f);
|
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 1;
|
2011-05-31 11:02:05 +02:00
|
|
|
src_pixel = src_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-05-31 11:02:05 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (pos & 1)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel++ & 0xf];
|
2011-05-31 11:02:05 +02:00
|
|
|
else
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel >> 4];
|
2011-05-31 11:02:05 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-05-31 11:02:05 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
case 1:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2012-04-27 14:44:53 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
|
2016-07-07 09:44:32 +02:00
|
|
|
WORD dst_colors[2];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_colors[i] = ((color_table[i].rgbRed << 7) & 0x7c00) |
|
|
|
|
((color_table[i].rgbGreen << 2) & 0x03e0) |
|
|
|
|
((color_table[i].rgbBlue >> 3) & 0x001f);
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 7;
|
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-06-15 14:43:51 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
src_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[src_val];
|
2011-06-15 14:43:51 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_16(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-05-27 14:41:32 +02:00
|
|
|
{
|
2011-08-19 17:26:15 +02:00
|
|
|
WORD *dst_start = get_pixel_ptr_16(dst, 0, 0), *dst_pixel;
|
2011-07-15 15:19:09 +02:00
|
|
|
INT x, y, pad_size = ((dst->width + 1) & ~1) * 2 - (src_rect->right - src_rect->left) * 2;
|
2011-05-27 14:41:32 +02:00
|
|
|
DWORD src_val;
|
|
|
|
|
|
|
|
switch(src->bit_count)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
if(src->funcs == &funcs_8888)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst, src_val >> 16, src_val >> 8, src_val);
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 14:41:32 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
else if(src->red_len == 8 && src->green_len == 8 && src->blue_len == 8)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
src_val >> src->red_shift,
|
|
|
|
src_val >> src->green_shift,
|
|
|
|
src_val >> src->blue_shift);
|
2011-07-13 14:04:59 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:04:59 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-12 23:25:32 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len ));
|
2011-10-12 23:25:32 +02:00
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:41 +02:00
|
|
|
case 24:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
2017-03-08 20:57:41 +01:00
|
|
|
for(x = src_rect->left; x < src_rect->right; x++, src_pixel += 3)
|
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst, src_pixel[2], src_pixel[1], src_pixel[0]);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-06-01 10:41:41 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 14:41:32 +02:00
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
if(src->funcs == &funcs_555)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
((src_val >> 7) & 0xf8) | ((src_val >> 12) & 0x07),
|
|
|
|
((src_val >> 2) & 0xf8) | ((src_val >> 7) & 0x07),
|
|
|
|
((src_val << 3) & 0xf8) | ((src_val >> 2) & 0x07));
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 14:41:32 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:58 +02:00
|
|
|
else if(bit_fields_match(src, dst))
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (src->stride > 0 && src->stride == dst->stride && !pad_size)
|
2011-08-19 17:26:15 +02:00
|
|
|
memcpy(dst_start, src_start, (src_rect->bottom - src_rect->top) * src->stride);
|
2011-07-13 14:04:58 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
memcpy(dst_start, src_start, (src_rect->right - src_rect->left) * 2);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_start + (src_rect->right - src_rect->left), 0, pad_size);
|
2011-07-13 14:04:58 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
else if(src->red_len == 5 && src->green_len == 5 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->green_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07));
|
2011-07-13 14:05:00 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(src->red_len == 5 && src->green_len == 6 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 2) & 0xfc) |
|
|
|
|
(((src_val >> src->green_shift) >> 4) & 0x03),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07));
|
2011-07-13 14:05:00 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-13 00:12:04 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 20:57:41 +01:00
|
|
|
*dst_pixel++ = rgb_to_pixel_masks(dst,
|
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-13 00:12:04 +02:00
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
case 8:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-27 15:36:55 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
WORD dst_colors[256];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
2016-07-07 09:44:32 +02:00
|
|
|
*dst_pixel++ = dst_colors[*src_pixel++];
|
|
|
|
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 15:36:55 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
case 4:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-31 11:02:05 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
WORD dst_colors[16];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 1;
|
2011-05-31 11:02:05 +02:00
|
|
|
src_pixel = src_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-05-31 11:02:05 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (pos & 1)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel++ & 0xf];
|
2011-05-31 11:02:05 +02:00
|
|
|
else
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel >> 4];
|
2011-05-31 11:02:05 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-05-31 11:02:05 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
case 1:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2012-04-27 14:44:53 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
|
2016-07-07 09:44:32 +02:00
|
|
|
WORD dst_colors[2];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 7;
|
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-06-15 14:43:51 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
src_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[src_val];
|
2011-06-15 14:43:51 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
static inline BOOL color_tables_match(const dib_info *d1, const dib_info *d2)
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
if (!d1->color_table || !d2->color_table) return (!d1->color_table && !d2->color_table);
|
2011-12-12 20:52:41 +01:00
|
|
|
return !memcmp(d1->color_table, d2->color_table, (1 << d1->bit_count) * sizeof(d1->color_table[0]));
|
2011-05-27 15:36:55 +02:00
|
|
|
}
|
|
|
|
|
2011-10-14 00:47:05 +02:00
|
|
|
static inline DWORD rgb_lookup_colortable(const dib_info *dst, BYTE r, BYTE g, BYTE b)
|
|
|
|
{
|
|
|
|
/* Windows reduces precision to 5 bits, probably in order to build some sort of lookup cache */
|
|
|
|
return rgb_to_pixel_colortable( dst, (r & ~7) + 4, (g & ~7) + 4, (b & ~7) + 4 );
|
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-05-27 15:26:02 +02:00
|
|
|
{
|
2011-08-19 17:26:15 +02:00
|
|
|
BYTE *dst_start = get_pixel_ptr_8(dst, 0, 0), *dst_pixel;
|
2011-07-15 15:19:09 +02:00
|
|
|
INT x, y, pad_size = ((dst->width + 3) & ~3) - (src_rect->right - src_rect->left);
|
2011-05-27 15:26:02 +02:00
|
|
|
DWORD src_val;
|
|
|
|
|
|
|
|
switch(src->bit_count)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
if(src->funcs == &funcs_8888)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-14 00:47:05 +02:00
|
|
|
*dst_pixel++ = rgb_lookup_colortable(dst, src_val >> 16, src_val >> 8, src_val );
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 15:26:02 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
else if(src->red_len == 8 && src->green_len == 8 && src->blue_len == 8)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-14 00:47:05 +02:00
|
|
|
*dst_pixel++ = rgb_lookup_colortable(dst,
|
|
|
|
src_val >> src->red_shift,
|
|
|
|
src_val >> src->green_shift,
|
|
|
|
src_val >> src->blue_shift );
|
2011-07-13 14:04:59 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:04:59 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 15:26:02 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-12 23:25:32 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-14 00:47:05 +02:00
|
|
|
*dst_pixel++ = rgb_lookup_colortable(dst,
|
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-12 23:25:32 +02:00
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:41 +02:00
|
|
|
case 24:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
2011-10-13 11:21:58 +02:00
|
|
|
for(x = src_rect->left; x < src_rect->right; x++, src_pixel += 3)
|
2011-06-01 10:41:41 +02:00
|
|
|
{
|
2011-10-14 00:47:05 +02:00
|
|
|
*dst_pixel++ = rgb_lookup_colortable(dst, src_pixel[2], src_pixel[1], src_pixel[0] );
|
2011-06-01 10:41:41 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-06-01 10:41:41 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
if(src->funcs == &funcs_555)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-14 00:47:05 +02:00
|
|
|
*dst_pixel++ = rgb_lookup_colortable(dst,
|
|
|
|
((src_val >> 7) & 0xf8) | ((src_val >> 12) & 0x07),
|
|
|
|
((src_val >> 2) & 0xf8) | ((src_val >> 7) & 0x07),
|
|
|
|
((src_val << 3) & 0xf8) | ((src_val >> 2) & 0x07) );
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 15:26:02 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
else if(src->red_len == 5 && src->green_len == 5 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-14 00:47:05 +02:00
|
|
|
*dst_pixel++ = rgb_lookup_colortable(dst,
|
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->green_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07) );
|
2011-07-13 14:05:00 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(src->red_len == 5 && src->green_len == 6 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-14 00:47:05 +02:00
|
|
|
*dst_pixel++ = rgb_lookup_colortable(dst,
|
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 2) & 0xfc) |
|
|
|
|
(((src_val >> src->green_shift) >> 4) & 0x03),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07) );
|
2011-07-13 14:05:00 +02:00
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 15:26:02 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-13 00:12:04 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-14 00:47:05 +02:00
|
|
|
*dst_pixel++ = rgb_lookup_colortable(dst,
|
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-13 00:12:04 +02:00
|
|
|
}
|
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
|
|
|
break;
|
2011-05-27 15:36:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
if(color_tables_match(dst, src))
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (src->stride > 0 && src->stride == dst->stride && !pad_size)
|
2011-08-19 17:26:15 +02:00
|
|
|
memcpy(dst_start, src_start, (src_rect->bottom - src_rect->top) * src->stride);
|
2011-05-27 15:36:55 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
memcpy(dst_start, src_start, src_rect->right - src_rect->left);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_start + (src_rect->right - src_rect->left), 0, pad_size);
|
2011-05-27 15:36:55 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2016-07-07 09:44:32 +02:00
|
|
|
BYTE dst_colors[256];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_colortable(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-05-27 15:36:55 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
2016-07-07 09:44:32 +02:00
|
|
|
*dst_pixel++ = dst_colors[*src_pixel++];
|
|
|
|
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_pixel, 0, pad_size);
|
2011-05-27 15:36:55 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
case 4:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-31 11:02:05 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
BYTE dst_colors[16];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_colortable(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 1;
|
2011-05-31 11:02:05 +02:00
|
|
|
src_pixel = src_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-05-31 11:02:05 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (pos & 1)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel++ & 0xf];
|
2011-05-31 11:02:05 +02:00
|
|
|
else
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[*src_pixel >> 4];
|
2011-05-31 11:02:05 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-05-31 11:02:05 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
case 1:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2012-04-27 14:44:53 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
|
2016-07-07 09:44:32 +02:00
|
|
|
BYTE dst_colors[2];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 21:29:51 +01:00
|
|
|
dst_colors[i] = FILTER_DIBINDEX(color_table[i], rgbquad_to_pixel_colortable(dst, color_table[i]));
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 7;
|
|
|
|
for (x = 0; x < src_rect->right - src_rect->left; x++, pos++)
|
2011-06-15 14:43:51 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
src_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_start[x] = dst_colors[src_val];
|
2011-06-15 14:43:51 +02:00
|
|
|
}
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pad_size) memset(dst_start + x, 0, pad_size);
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-05-27 15:26:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_4(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-05-31 11:02:03 +02:00
|
|
|
{
|
2011-08-19 17:26:15 +02:00
|
|
|
BYTE *dst_start = get_pixel_ptr_4(dst, 0, 0), *dst_pixel, dst_val;
|
2011-07-15 15:19:09 +02:00
|
|
|
INT x, y, pad_size = ((dst->width + 7) & ~7) / 2 - (src_rect->right - src_rect->left + 1) / 2;
|
2011-05-31 11:02:03 +02:00
|
|
|
DWORD src_val;
|
|
|
|
|
|
|
|
switch(src->bit_count)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
if(src->funcs == &funcs_8888)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-13 11:21:58 +02:00
|
|
|
dst_val = rgb_to_pixel_colortable(dst, src_val >> 16, src_val >> 8, src_val);
|
2011-05-31 11:02:03 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
else if(src->red_len == 8 && src->green_len == 8 && src->blue_len == 8)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-13 11:21:58 +02:00
|
|
|
dst_val = rgb_to_pixel_colortable(dst,
|
|
|
|
src_val >> src->red_shift,
|
|
|
|
src_val >> src->green_shift,
|
|
|
|
src_val >> src->blue_shift);
|
2011-07-13 14:04:59 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-12 23:25:32 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-13 11:21:58 +02:00
|
|
|
dst_val = rgb_to_pixel_colortable(dst,
|
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-12 23:25:32 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:41:41 +02:00
|
|
|
case 24:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
2011-10-13 11:21:58 +02:00
|
|
|
for(x = src_rect->left; x < src_rect->right; x++, src_pixel += 3)
|
2011-06-01 10:41:41 +02:00
|
|
|
{
|
2011-10-13 11:21:58 +02:00
|
|
|
dst_val = rgb_to_pixel_colortable(dst, src_pixel[2], src_pixel[1], src_pixel[0]);
|
2011-06-01 10:41:41 +02:00
|
|
|
|
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-06-01 10:41:41 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:03 +02:00
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
if(src->funcs == &funcs_555)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-13 11:21:58 +02:00
|
|
|
dst_val = rgb_to_pixel_colortable(dst,
|
|
|
|
((src_val >> 7) & 0xf8) | ((src_val >> 12) & 0x07),
|
|
|
|
((src_val >> 2) & 0xf8) | ((src_val >> 7) & 0x07),
|
|
|
|
((src_val << 3) & 0xf8) | ((src_val >> 2) & 0x07) );
|
2011-05-31 11:02:03 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
else if(src->red_len == 5 && src->green_len == 5 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-13 11:21:58 +02:00
|
|
|
dst_val = rgb_to_pixel_colortable(dst,
|
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->green_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07) );
|
2011-07-13 14:05:00 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(src->red_len == 5 && src->green_len == 6 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-13 11:21:58 +02:00
|
|
|
dst_val = rgb_to_pixel_colortable(dst,
|
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 2) & 0xfc) |
|
|
|
|
(((src_val >> src->green_shift) >> 4) & 0x03),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07) );
|
2011-07-13 14:05:00 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-13 00:12:04 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2011-10-13 11:21:58 +02:00
|
|
|
dst_val = rgb_to_pixel_colortable(dst,
|
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-13 00:12:04 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-05-31 11:02:03 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
|
2016-07-07 09:44:32 +02:00
|
|
|
BYTE dst_colors[256];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_colortable(dst, color_table[i]);
|
2011-05-31 11:02:03 +02:00
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left; x < src_rect->right; x++)
|
|
|
|
{
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_val = dst_colors[*src_pixel++];
|
2011-05-31 11:02:03 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
|
|
|
|
|
2012-04-27 14:44:53 +02:00
|
|
|
if(color_tables_match(dst, src) && ((src->rect.left + src_rect->left) & 1) == 0)
|
2011-05-31 11:02:05 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if (src->stride > 0 && src->stride == dst->stride && !pad_size)
|
2011-08-19 17:26:15 +02:00
|
|
|
memcpy(dst_start, src_start, (src_rect->bottom - src_rect->top) * src->stride);
|
2011-05-31 11:02:05 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
memcpy(dst_start, src_start, (src_rect->right - src_rect->left + 1) / 2);
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size) memset(dst_start + (src_rect->right - src_rect->left + 1) / 2, 0, pad_size);
|
2011-05-31 11:02:05 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2016-07-07 09:44:32 +02:00
|
|
|
BYTE dst_colors[16];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_colortable(dst, color_table[i]);
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-05-31 11:02:05 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 1;
|
2011-05-31 11:02:05 +02:00
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for(x = src_rect->left; x < src_rect->right; x++, pos++)
|
2011-05-31 11:02:05 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
if(pos & 1)
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_val = dst_colors[*src_pixel++ & 0xf];
|
2011-05-31 11:02:05 +02:00
|
|
|
else
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_val = dst_colors[*src_pixel >> 4];
|
2011-05-31 11:02:05 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-05-31 11:02:05 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
case 1:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2012-04-27 14:44:53 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
|
2016-07-07 09:44:32 +02:00
|
|
|
BYTE dst_colors[2];
|
|
|
|
int i;
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 21:29:51 +01:00
|
|
|
dst_colors[i] = FILTER_DIBINDEX(color_table[i], rgbquad_to_pixel_colortable(dst, color_table[i]));
|
2016-07-07 09:44:32 +02:00
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 7;
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_pixel = dst_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for(x = src_rect->left; x < src_rect->right; x++, pos++)
|
2011-06-15 14:43:51 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
src_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
2016-07-07 09:44:32 +02:00
|
|
|
dst_val = dst_colors[src_val];
|
2011-06-15 14:43:51 +02:00
|
|
|
if((x - src_rect->left) & 1)
|
|
|
|
{
|
|
|
|
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
|
|
|
|
dst_pixel++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dst_pixel = (dst_val << 4) & 0xf0;
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if((x - src_rect->left) & 1) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-05-31 11:02:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_1(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-05-27 14:41:32 +02:00
|
|
|
{
|
2011-08-19 17:26:15 +02:00
|
|
|
BYTE *dst_start = get_pixel_ptr_1(dst, 0, 0), *dst_pixel, dst_val;
|
2011-07-15 15:19:09 +02:00
|
|
|
INT x, y, pad_size = ((dst->width + 31) & ~31) / 8 - (src_rect->right - src_rect->left + 7) / 8;
|
2017-03-08 21:03:59 +01:00
|
|
|
RGBQUAD rgb, bg_entry = *get_dib_color_table( dst ); /* entry 0 is the background color */
|
2011-06-15 14:43:49 +02:00
|
|
|
DWORD src_val;
|
|
|
|
int bit_pos;
|
|
|
|
|
|
|
|
switch(src->bit_count)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
|
2017-03-08 21:29:51 +01:00
|
|
|
DWORD bg_pixel = FILTER_DIBINDEX(bg_entry, rgbquad_to_pixel_masks(src, bg_entry));
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
if(src->funcs == &funcs_8888)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 21:03:59 +01:00
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
|
|
|
src_val >> 16, src_val >> 8, src_val);
|
2011-06-15 14:43:49 +02:00
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
else if(src->red_len == 8 && src->green_len == 8 && src->blue_len == 8)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 21:03:59 +01:00
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
2012-05-22 10:57:01 +02:00
|
|
|
src_val >> src->red_shift,
|
|
|
|
src_val >> src->green_shift,
|
|
|
|
src_val >> src->blue_shift);
|
2011-07-13 14:04:59 +02:00
|
|
|
|
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-07-13 14:04:59 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-12 23:25:32 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 21:03:59 +01:00
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
2012-05-22 10:57:01 +02:00
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-12 23:25:32 +02:00
|
|
|
|
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 4;
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
{
|
|
|
|
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top), *src_pixel;
|
2017-03-08 21:29:51 +01:00
|
|
|
DWORD bg_pixel = FILTER_DIBINDEX(bg_entry, RGB(bg_entry.rgbRed, bg_entry.rgbGreen, bg_entry.rgbBlue));
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
2011-10-13 11:21:58 +02:00
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++, src_pixel += 3)
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
2017-03-08 21:03:59 +01:00
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, RGB(src_pixel[2], src_pixel[1], src_pixel[0]),
|
|
|
|
bg_pixel, src_pixel[2], src_pixel[1], src_pixel[0]);
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
|
2017-03-08 21:29:51 +01:00
|
|
|
DWORD bg_pixel = FILTER_DIBINDEX(bg_entry, rgbquad_to_pixel_masks(src, bg_entry));
|
2017-03-08 21:03:59 +01:00
|
|
|
|
2011-06-15 14:43:49 +02:00
|
|
|
if(src->funcs == &funcs_555)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 21:03:59 +01:00
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
2012-05-22 10:57:01 +02:00
|
|
|
((src_val >> 7) & 0xf8) | ((src_val >> 12) & 0x07),
|
|
|
|
((src_val >> 2) & 0xf8) | ((src_val >> 7) & 0x07),
|
|
|
|
((src_val << 3) & 0xf8) | ((src_val >> 2) & 0x07));
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
else if(src->red_len == 5 && src->green_len == 5 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 21:03:59 +01:00
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
2012-05-22 10:57:01 +02:00
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->green_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07));
|
2011-07-13 14:05:00 +02:00
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(src->red_len == 5 && src->green_len == 6 && src->blue_len == 5)
|
|
|
|
{
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 21:03:59 +01:00
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
2012-05-22 10:57:01 +02:00
|
|
|
(((src_val >> src->red_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->red_shift) >> 2) & 0x07),
|
|
|
|
(((src_val >> src->green_shift) << 2) & 0xfc) |
|
|
|
|
(((src_val >> src->green_shift) >> 4) & 0x03),
|
|
|
|
(((src_val >> src->blue_shift) << 3) & 0xf8) |
|
|
|
|
(((src_val >> src->blue_shift) >> 2) & 0x07));
|
2011-07-13 14:05:00 +02:00
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-07-13 14:05:00 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-13 00:12:04 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++)
|
|
|
|
{
|
|
|
|
src_val = *src_pixel++;
|
2017-03-08 21:03:59 +01:00
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
2012-05-22 10:57:01 +02:00
|
|
|
get_field(src_val, src->red_shift, src->red_len),
|
|
|
|
get_field(src_val, src->green_shift, src->green_len),
|
|
|
|
get_field(src_val, src->blue_shift, src->blue_len));
|
2011-10-13 00:12:04 +02:00
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride / 2;
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-06-15 14:43:49 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
|
2017-03-08 21:29:51 +01:00
|
|
|
DWORD bg_pixel = FILTER_DIBINDEX(bg_entry, rgbquad_to_pixel_colortable(src, bg_entry));
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++)
|
|
|
|
{
|
2017-03-08 21:03:59 +01:00
|
|
|
BYTE src_val = *src_pixel++;
|
|
|
|
rgb = color_table[src_val];
|
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
|
|
|
rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue);
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2011-06-15 14:43:49 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
|
2017-03-08 21:29:51 +01:00
|
|
|
DWORD bg_pixel = FILTER_DIBINDEX(bg_entry, rgbquad_to_pixel_colortable(src, bg_entry));
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 1;
|
2011-06-15 14:43:49 +02:00
|
|
|
dst_pixel = dst_start;
|
|
|
|
src_pixel = src_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++, pos++)
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
2017-03-08 21:03:59 +01:00
|
|
|
src_val = (pos & 1) ? *src_pixel++ & 0xf : *src_pixel >> 4;
|
|
|
|
rgb = color_table[src_val];
|
|
|
|
dst_val = rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
|
|
|
rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue);
|
2011-06-15 14:43:49 +02:00
|
|
|
|
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
/* Note that while MSDN states that a 1 bpp dib brush -> mono dc
|
|
|
|
uses text/bkgnd colours instead of the dib's colour table, this
|
|
|
|
doesn't appear to be the case for a dc backed by a
|
|
|
|
dibsection. */
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
2012-04-27 14:44:53 +02:00
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
|
2017-03-08 21:29:51 +01:00
|
|
|
DWORD bg_pixel = FILTER_DIBINDEX(bg_entry, rgbquad_to_pixel_colortable(src, bg_entry));
|
2017-03-08 21:03:59 +01:00
|
|
|
|
2011-06-15 14:43:51 +02:00
|
|
|
for(y = src_rect->top; y < src_rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
int pos = (src->rect.left + src_rect->left) & 7;
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_pixel = dst_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
for(x = src_rect->left, bit_pos = 0; x < src_rect->right; x++, pos++)
|
2011-06-15 14:43:51 +02:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
src_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
2012-05-23 11:34:22 +02:00
|
|
|
rgb = color_table[src_val];
|
2017-03-08 21:29:51 +01:00
|
|
|
dst_val = FILTER_DIBINDEX(rgb, rgb_to_pixel_mono(dst, dither, x, y, src_val, bg_pixel,
|
|
|
|
rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue));
|
2011-06-15 14:43:51 +02:00
|
|
|
if(bit_pos == 0) *dst_pixel = 0;
|
|
|
|
*dst_pixel = (*dst_pixel & ~pixel_masks_1[bit_pos]) | (dst_val & pixel_masks_1[bit_pos]);
|
|
|
|
|
|
|
|
if(++bit_pos == 8)
|
|
|
|
{
|
|
|
|
dst_pixel++;
|
|
|
|
bit_pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 15:19:09 +02:00
|
|
|
if(pad_size)
|
|
|
|
{
|
|
|
|
if(bit_pos != 0) dst_pixel++;
|
|
|
|
memset(dst_pixel, 0, pad_size);
|
|
|
|
}
|
2011-06-15 14:43:51 +02:00
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-06-15 14:43:49 +02:00
|
|
|
}
|
2011-05-27 14:41:32 +02:00
|
|
|
}
|
|
|
|
|
2012-05-22 10:57:01 +02:00
|
|
|
static void convert_to_null(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
|
2011-06-15 14:43:49 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-10-14 12:30:28 +02:00
|
|
|
static inline BYTE blend_color(BYTE dst, BYTE src, DWORD alpha)
|
|
|
|
{
|
|
|
|
return (src * alpha + dst * (255 - alpha) + 127) / 255;
|
|
|
|
}
|
|
|
|
|
2012-04-28 17:29:40 +02:00
|
|
|
static inline DWORD blend_argb_constant_alpha( DWORD dst, DWORD src, DWORD alpha )
|
2011-10-14 12:30:28 +02:00
|
|
|
{
|
|
|
|
return (blend_color( dst, src, alpha ) |
|
|
|
|
blend_color( dst >> 8, src >> 8, alpha ) << 8 |
|
|
|
|
blend_color( dst >> 16, src >> 16, alpha ) << 16 |
|
|
|
|
blend_color( dst >> 24, src >> 24, alpha ) << 24);
|
|
|
|
}
|
|
|
|
|
2012-10-10 17:19:42 +02:00
|
|
|
static inline DWORD blend_argb_no_src_alpha( DWORD dst, DWORD src, DWORD alpha )
|
|
|
|
{
|
|
|
|
return (blend_color( dst, src, alpha ) |
|
|
|
|
blend_color( dst >> 8, src >> 8, alpha ) << 8 |
|
|
|
|
blend_color( dst >> 16, src >> 16, alpha ) << 16 |
|
|
|
|
blend_color( dst >> 24, 255, alpha ) << 24);
|
|
|
|
}
|
|
|
|
|
2012-04-28 17:29:40 +02:00
|
|
|
static inline DWORD blend_argb( DWORD dst, DWORD src )
|
|
|
|
{
|
|
|
|
BYTE b = (BYTE)src;
|
|
|
|
BYTE g = (BYTE)(src >> 8);
|
|
|
|
BYTE r = (BYTE)(src >> 16);
|
|
|
|
DWORD alpha = (BYTE)(src >> 24);
|
|
|
|
return ((b + ((BYTE)dst * (255 - alpha) + 127) / 255) |
|
|
|
|
(g + ((BYTE)(dst >> 8) * (255 - alpha) + 127) / 255) << 8 |
|
|
|
|
(r + ((BYTE)(dst >> 16) * (255 - alpha) + 127) / 255) << 16 |
|
|
|
|
(alpha + ((BYTE)(dst >> 24) * (255 - alpha) + 127) / 255) << 24);
|
|
|
|
}
|
|
|
|
|
2011-10-14 12:30:28 +02:00
|
|
|
static inline DWORD blend_argb_alpha( DWORD dst, DWORD src, DWORD alpha )
|
|
|
|
{
|
|
|
|
BYTE b = ((BYTE)src * alpha + 127) / 255;
|
|
|
|
BYTE g = ((BYTE)(src >> 8) * alpha + 127) / 255;
|
|
|
|
BYTE r = ((BYTE)(src >> 16) * alpha + 127) / 255;
|
|
|
|
alpha = ((BYTE)(src >> 24) * alpha + 127) / 255;
|
|
|
|
return ((b + ((BYTE)dst * (255 - alpha) + 127) / 255) |
|
|
|
|
(g + ((BYTE)(dst >> 8) * (255 - alpha) + 127) / 255) << 8 |
|
|
|
|
(r + ((BYTE)(dst >> 16) * (255 - alpha) + 127) / 255) << 16 |
|
|
|
|
(alpha + ((BYTE)(dst >> 24) * (255 - alpha) + 127) / 255) << 24);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD blend_rgb( BYTE dst_r, BYTE dst_g, BYTE dst_b, DWORD src, BLENDFUNCTION blend )
|
|
|
|
{
|
|
|
|
if (blend.AlphaFormat & AC_SRC_ALPHA)
|
|
|
|
{
|
|
|
|
DWORD alpha = blend.SourceConstantAlpha;
|
|
|
|
BYTE src_b = ((BYTE)src * alpha + 127) / 255;
|
|
|
|
BYTE src_g = ((BYTE)(src >> 8) * alpha + 127) / 255;
|
|
|
|
BYTE src_r = ((BYTE)(src >> 16) * alpha + 127) / 255;
|
|
|
|
alpha = ((BYTE)(src >> 24) * alpha + 127) / 255;
|
|
|
|
return ((src_b + (dst_b * (255 - alpha) + 127) / 255) |
|
|
|
|
(src_g + (dst_g * (255 - alpha) + 127) / 255) << 8 |
|
|
|
|
(src_r + (dst_r * (255 - alpha) + 127) / 255) << 16);
|
|
|
|
}
|
|
|
|
return (blend_color( dst_b, src, blend.SourceConstantAlpha ) |
|
|
|
|
blend_color( dst_g, src >> 8, blend.SourceConstantAlpha ) << 8 |
|
|
|
|
blend_color( dst_r, src >> 16, blend.SourceConstantAlpha ) << 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_8888(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
|
|
|
|
DWORD *dst_ptr = get_pixel_ptr_32( dst, rc->left, rc->top );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
if (blend.AlphaFormat & AC_SRC_ALPHA)
|
2012-04-28 17:29:40 +02:00
|
|
|
{
|
|
|
|
if (blend.SourceConstantAlpha == 255)
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
dst_ptr[x] = blend_argb( dst_ptr[x], src_ptr[x] );
|
|
|
|
else
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
dst_ptr[x] = blend_argb_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
|
|
|
|
}
|
2012-10-10 17:19:42 +02:00
|
|
|
else if (src->compression == BI_RGB)
|
2012-04-28 17:29:40 +02:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
dst_ptr[x] = blend_argb_constant_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
|
2012-10-10 17:19:42 +02:00
|
|
|
else
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
dst_ptr[x] = blend_argb_no_src_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
|
2011-10-14 12:30:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_32(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
|
|
|
|
DWORD *dst_ptr = get_pixel_ptr_32( dst, rc->left, rc->top );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
if (dst->red_len == 8 && dst->green_len == 8 && dst->blue_len == 8)
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
{
|
|
|
|
DWORD val = blend_rgb( dst_ptr[x] >> dst->red_shift,
|
|
|
|
dst_ptr[x] >> dst->green_shift,
|
|
|
|
dst_ptr[x] >> dst->blue_shift,
|
|
|
|
src_ptr[x], blend );
|
|
|
|
dst_ptr[x] = ((( val & 0xff) << dst->blue_shift) |
|
|
|
|
(((val >> 8) & 0xff) << dst->green_shift) |
|
|
|
|
(((val >> 16) & 0xff) << dst->red_shift));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
{
|
|
|
|
DWORD val = blend_rgb( get_field( dst_ptr[x], dst->red_shift, dst->red_len ),
|
|
|
|
get_field( dst_ptr[x], dst->green_shift, dst->green_len ),
|
|
|
|
get_field( dst_ptr[x], dst->blue_shift, dst->blue_len ),
|
|
|
|
src_ptr[x], blend );
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_ptr[x] = rgb_to_pixel_masks( dst, val >> 16, val >> 8, val );
|
2011-10-14 12:30:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_24(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_24( dst, rc->left, rc->top );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
{
|
|
|
|
DWORD val = blend_rgb( dst_ptr[x * 3 + 2], dst_ptr[x * 3 + 1], dst_ptr[x * 3],
|
|
|
|
src_ptr[x], blend );
|
|
|
|
dst_ptr[x * 3] = val;
|
|
|
|
dst_ptr[x * 3 + 1] = val >> 8;
|
|
|
|
dst_ptr[x * 3 + 2] = val >> 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_555(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
|
|
|
|
WORD *dst_ptr = get_pixel_ptr_16( dst, rc->left, rc->top );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 2, src_ptr += src->stride / 4)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
{
|
|
|
|
DWORD val = blend_rgb( ((dst_ptr[x] >> 7) & 0xf8) | ((dst_ptr[x] >> 12) & 0x07),
|
|
|
|
((dst_ptr[x] >> 2) & 0xf8) | ((dst_ptr[x] >> 7) & 0x07),
|
|
|
|
((dst_ptr[x] << 3) & 0xf8) | ((dst_ptr[x] >> 2) & 0x07),
|
|
|
|
src_ptr[x], blend );
|
|
|
|
dst_ptr[x] = ((val >> 9) & 0x7c00) | ((val >> 6) & 0x03e0) | ((val >> 3) & 0x001f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_16(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
|
|
|
|
WORD *dst_ptr = get_pixel_ptr_16( dst, rc->left, rc->top );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 2, src_ptr += src->stride / 4)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
{
|
|
|
|
DWORD val = blend_rgb( get_field( dst_ptr[x], dst->red_shift, dst->red_len ),
|
|
|
|
get_field( dst_ptr[x], dst->green_shift, dst->green_len ),
|
|
|
|
get_field( dst_ptr[x], dst->blue_shift, dst->blue_len ),
|
|
|
|
src_ptr[x], blend );
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_ptr[x] = rgb_to_pixel_masks( dst, val >> 16, val >> 8, val );
|
2011-10-14 12:30:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_8(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( dst );
|
2011-10-14 12:30:28 +02:00
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_8( dst, rc->left, rc->top );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
RGBQUAD rgb = color_table[dst_ptr[x]];
|
2011-10-14 12:30:28 +02:00
|
|
|
DWORD val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[x], blend );
|
|
|
|
dst_ptr[x] = rgb_lookup_colortable( dst, val >> 16, val >> 8, val );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_4(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( dst );
|
2012-04-27 14:24:43 +02:00
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_4( dst, rc->left, rc->top );
|
|
|
|
int i, x, y;
|
2011-10-14 12:30:28 +02:00
|
|
|
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
for (i = 0, x = (dst->rect.left + rc->left) & 1; i < rc->right - rc->left; i++, x++)
|
2011-10-14 12:30:28 +02:00
|
|
|
{
|
|
|
|
DWORD val = ((x & 1) ? dst_ptr[x / 2] : (dst_ptr[x / 2] >> 4)) & 0x0f;
|
2012-05-23 11:34:22 +02:00
|
|
|
RGBQUAD rgb = color_table[val];
|
2012-04-27 14:24:43 +02:00
|
|
|
val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[i], blend );
|
2011-10-14 12:30:28 +02:00
|
|
|
val = rgb_lookup_colortable( dst, val >> 16, val >> 8, val );
|
|
|
|
if (x & 1)
|
|
|
|
dst_ptr[x / 2] = val | (dst_ptr[x / 2] & 0xf0);
|
|
|
|
else
|
|
|
|
dst_ptr[x / 2] = (val << 4) | (dst_ptr[x / 2] & 0x0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_1(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
2012-05-23 11:34:22 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( dst );
|
2012-04-27 14:24:43 +02:00
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_1( dst, rc->left, rc->top );
|
|
|
|
int i, x, y;
|
2011-10-14 12:30:28 +02:00
|
|
|
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
for (i = 0, x = (dst->rect.left + rc->left) & 7; i < rc->right - rc->left; i++, x++)
|
2011-10-14 12:30:28 +02:00
|
|
|
{
|
|
|
|
DWORD val = (dst_ptr[x / 8] & pixel_masks_1[x % 8]) ? 1 : 0;
|
2012-05-23 11:34:22 +02:00
|
|
|
RGBQUAD rgb = color_table[val];
|
2012-04-27 14:24:43 +02:00
|
|
|
val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[i], blend );
|
2011-10-14 12:30:28 +02:00
|
|
|
val = rgb_to_pixel_colortable(dst, val >> 16, val >> 8, val) ? 0xff : 0;
|
|
|
|
dst_ptr[x / 8] = (dst_ptr[x / 8] & ~pixel_masks_1[x % 8]) | (val & pixel_masks_1[x % 8]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_rect_null(const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-11-28 13:21:52 +01:00
|
|
|
static inline DWORD gradient_rgb_8888( const TRIVERTEX *v, unsigned int pos, unsigned int len )
|
|
|
|
{
|
|
|
|
BYTE r, g, b, a;
|
|
|
|
r = (v[0].Red * (len - pos) + v[1].Red * pos) / len / 256;
|
|
|
|
g = (v[0].Green * (len - pos) + v[1].Green * pos) / len / 256;
|
|
|
|
b = (v[0].Blue * (len - pos) + v[1].Blue * pos) / len / 256;
|
|
|
|
a = (v[0].Alpha * (len - pos) + v[1].Alpha * pos) / len / 256;
|
|
|
|
return a << 24 | r << 16 | g << 8 | b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD gradient_rgb_24( const TRIVERTEX *v, unsigned int pos, unsigned int len )
|
|
|
|
{
|
|
|
|
BYTE r, g, b;
|
|
|
|
r = (v[0].Red * (len - pos) + v[1].Red * pos) / len / 256;
|
|
|
|
g = (v[0].Green * (len - pos) + v[1].Green * pos) / len / 256;
|
|
|
|
b = (v[0].Blue * (len - pos) + v[1].Blue * pos) / len / 256;
|
|
|
|
return r << 16 | g << 8 | b;
|
|
|
|
}
|
|
|
|
|
2011-11-29 14:18:02 +01:00
|
|
|
static inline WORD gradient_rgb_555( const TRIVERTEX *v, unsigned int pos, unsigned int len,
|
|
|
|
unsigned int x, unsigned int y )
|
|
|
|
{
|
2011-12-04 17:10:30 +01:00
|
|
|
int r = (v[0].Red * (len - pos) + v[1].Red * pos) / len / 128 + bayer_4x4[y % 4][x % 4];
|
|
|
|
int g = (v[0].Green * (len - pos) + v[1].Green * pos) / len / 128 + bayer_4x4[y % 4][x % 4];
|
|
|
|
int b = (v[0].Blue * (len - pos) + v[1].Blue * pos) / len / 128 + bayer_4x4[y % 4][x % 4];
|
2011-11-29 14:18:02 +01:00
|
|
|
r = min( 31, max( 0, r / 16 ));
|
|
|
|
g = min( 31, max( 0, g / 16 ));
|
|
|
|
b = min( 31, max( 0, b / 16 ));
|
|
|
|
return (r << 10) | (g << 5) | b;
|
|
|
|
}
|
|
|
|
|
2011-11-29 14:22:59 +01:00
|
|
|
static inline BYTE gradient_rgb_8( const dib_info *dib, const TRIVERTEX *v,
|
|
|
|
unsigned int pos, unsigned int len, unsigned int x, unsigned int y )
|
|
|
|
{
|
2011-12-04 17:10:30 +01:00
|
|
|
BYTE r = ((v[0].Red * (len - pos) + v[1].Red * pos) / len / 128 + bayer_16x16[y % 16][x % 16]) / 256;
|
|
|
|
BYTE g = ((v[0].Green * (len - pos) + v[1].Green * pos) / len / 128 + bayer_16x16[y % 16][x % 16]) / 256;
|
|
|
|
BYTE b = ((v[0].Blue * (len - pos) + v[1].Blue * pos) / len / 128 + bayer_16x16[y % 16][x % 16]) / 256;
|
2011-11-29 14:22:59 +01:00
|
|
|
return rgb_to_pixel_colortable( dib, r * 127, g * 127, b * 127 );
|
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
/* compute the left/right triangle limit for row y */
|
|
|
|
static inline void triangle_coords( const TRIVERTEX *v, const RECT *rc, int y, int *left, int *right )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2011-12-04 17:10:30 +01:00
|
|
|
int x1, x2;
|
|
|
|
|
|
|
|
if (y < v[1].y) x1 = edge_coord( y, v[0].x, v[0].y, v[1].x, v[1].y );
|
|
|
|
else x1 = edge_coord( y, v[1].x, v[1].y, v[2].x, v[2].y );
|
|
|
|
|
|
|
|
x2 = edge_coord( y, v[0].x, v[0].y, v[2].x, v[2].y );
|
|
|
|
|
|
|
|
*left = max( rc->left, min( x1, x2 ) );
|
|
|
|
*right = min( rc->right, max( x1, x2 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute the matrix determinant for triangular barycentric coordinates (constant across the triangle) */
|
|
|
|
static inline int triangle_det( const TRIVERTEX *v )
|
|
|
|
{
|
|
|
|
return (v[2].y - v[1].y) * (v[2].x - v[0].x) - (v[2].x - v[1].x) * (v[2].y - v[0].y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute the barycentric weights for a given point inside the triangle */
|
|
|
|
static inline void triangle_weights( const TRIVERTEX *v, int x, int y, INT64 *l1, INT64 *l2 )
|
|
|
|
{
|
|
|
|
*l1 = (v[1].y - v[2].y) * (x - v[2].x) - (v[1].x - v[2].x) * (y - v[2].y);
|
|
|
|
*l2 = (v[2].y - v[0].y) * (x - v[2].x) - (v[2].x - v[0].x) * (y - v[2].y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD gradient_triangle_8888( const TRIVERTEX *v, int x, int y, int det )
|
|
|
|
{
|
|
|
|
INT64 l1, l2;
|
|
|
|
BYTE r, g, b, a;
|
|
|
|
|
|
|
|
triangle_weights( v, x, y, &l1, &l2 );
|
|
|
|
r = (v[0].Red * l1 + v[1].Red * l2 + v[2].Red * (det - l1 - l2)) / det / 256;
|
|
|
|
g = (v[0].Green * l1 + v[1].Green * l2 + v[2].Green * (det - l1 - l2)) / det / 256;
|
|
|
|
b = (v[0].Blue * l1 + v[1].Blue * l2 + v[2].Blue * (det - l1 - l2)) / det / 256;
|
|
|
|
a = (v[0].Alpha * l1 + v[1].Alpha * l2 + v[2].Alpha * (det - l1 - l2)) / det / 256;
|
|
|
|
return a << 24 | r << 16 | g << 8 | b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD gradient_triangle_24( const TRIVERTEX *v, int x, int y, int det )
|
|
|
|
{
|
|
|
|
INT64 l1, l2;
|
|
|
|
BYTE r, g, b;
|
|
|
|
|
|
|
|
triangle_weights( v, x, y, &l1, &l2 );
|
|
|
|
r = (v[0].Red * l1 + v[1].Red * l2 + v[2].Red * (det - l1 - l2)) / det / 256;
|
|
|
|
g = (v[0].Green * l1 + v[1].Green * l2 + v[2].Green * (det - l1 - l2)) / det / 256;
|
|
|
|
b = (v[0].Blue * l1 + v[1].Blue * l2 + v[2].Blue * (det - l1 - l2)) / det / 256;
|
|
|
|
return r << 16 | g << 8 | b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD gradient_triangle_555( const TRIVERTEX *v, int x, int y, int det )
|
|
|
|
{
|
|
|
|
INT64 l1, l2;
|
|
|
|
int r, g, b;
|
|
|
|
|
|
|
|
triangle_weights( v, x, y, &l1, &l2 );
|
|
|
|
r = (v[0].Red * l1 + v[1].Red * l2 + v[2].Red * (det - l1 - l2)) / det / 128 + bayer_4x4[y % 4][x % 4];
|
|
|
|
g = (v[0].Green * l1 + v[1].Green * l2 + v[2].Green * (det - l1 - l2)) / det / 128 + bayer_4x4[y % 4][x % 4];
|
|
|
|
b = (v[0].Blue * l1 + v[1].Blue * l2 + v[2].Blue * (det - l1 - l2)) / det / 128 + bayer_4x4[y % 4][x % 4];
|
|
|
|
r = min( 31, max( 0, r / 16 ));
|
|
|
|
g = min( 31, max( 0, g / 16 ));
|
|
|
|
b = min( 31, max( 0, b / 16 ));
|
|
|
|
return (r << 10) | (g << 5) | b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD gradient_triangle_8( const dib_info *dib, const TRIVERTEX *v, int x, int y, int det )
|
|
|
|
{
|
|
|
|
INT64 l1, l2;
|
|
|
|
BYTE r, g, b;
|
|
|
|
|
|
|
|
triangle_weights( v, x, y, &l1, &l2 );
|
|
|
|
r = ((v[0].Red * l1 + v[1].Red * l2 + v[2].Red * (det - l1 - l2)) / det / 128 + bayer_16x16[y % 16][x % 16]) / 256;
|
|
|
|
g = ((v[0].Green * l1 + v[1].Green * l2 + v[2].Green * (det - l1 - l2)) / det / 128 + bayer_16x16[y % 16][x % 16]) / 256;
|
|
|
|
b = ((v[0].Blue * l1 + v[1].Blue * l2 + v[2].Blue * (det - l1 - l2)) / det / 128 + bayer_16x16[y % 16][x % 16]) / 256;
|
|
|
|
return rgb_to_pixel_colortable( dib, r * 127, g * 127, b * 127 );
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL gradient_rect_8888( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
DWORD *ptr = get_pixel_ptr_32( dib, rc->left, rc->top );
|
2011-12-04 17:10:30 +01:00
|
|
|
int x, y, left, right, det;
|
2011-11-28 13:21:52 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
|
|
|
ptr[x] = gradient_rgb_8888( v, rc->left + x - v[0].x, v[1].x - v[0].x );
|
2011-11-28 13:21:52 +01:00
|
|
|
|
2012-04-27 14:24:43 +02:00
|
|
|
for (y = rc->top + 1; y < rc->bottom; y++, ptr += dib->stride / 4)
|
2011-11-28 13:21:52 +01:00
|
|
|
memcpy( ptr + dib->stride / 4, ptr, (rc->right - rc->left) * 4 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
2011-12-04 17:10:30 +01:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride / 4)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
|
|
|
DWORD val = gradient_rgb_8888( v, y - v[0].y, v[1].y - v[0].y );
|
2012-11-30 17:59:04 +01:00
|
|
|
memset_32( ptr, val, rc->right - rc->left );
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_TRIANGLE:
|
|
|
|
if (!(det = triangle_det( v ))) return FALSE;
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride / 4)
|
|
|
|
{
|
|
|
|
triangle_coords( v, rc, y, &left, &right );
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = left; x < right; x++) ptr[x - rc->left] = gradient_triangle_8888( v, x, y, det );
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static BOOL gradient_rect_32( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
DWORD *ptr = get_pixel_ptr_32( dib, rc->left, rc->top );
|
2011-12-04 17:10:30 +01:00
|
|
|
int x, y, left, right, det;
|
2011-11-28 13:21:52 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
|
|
|
if (dib->red_len == 8 && dib->green_len == 8 && dib->blue_len == 8)
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
DWORD val = gradient_rgb_24( v, rc->left + x - v[0].x, v[1].x - v[0].x );
|
2011-11-28 13:21:52 +01:00
|
|
|
ptr[x] = ((( val & 0xff) << dib->blue_shift) |
|
|
|
|
(((val >> 8) & 0xff) << dib->green_shift) |
|
|
|
|
(((val >> 16) & 0xff) << dib->red_shift));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
DWORD val = gradient_rgb_24( v, rc->left + x - v[0].x, v[1].x - v[0].x );
|
2017-03-08 20:57:41 +01:00
|
|
|
ptr[x] = rgb_to_pixel_masks( dib, val >> 16, val >> 8, val );
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-27 14:24:43 +02:00
|
|
|
for (y = rc->top + 1; y < rc->bottom; y++, ptr += dib->stride / 4)
|
2011-11-28 13:21:52 +01:00
|
|
|
memcpy( ptr + dib->stride / 4, ptr, (rc->right - rc->left) * 4 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
2012-11-30 17:59:04 +01:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride / 4)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
|
|
|
DWORD val = gradient_rgb_24( v, y - v[0].y, v[1].y - v[0].y );
|
|
|
|
if (dib->red_len == 8 && dib->green_len == 8 && dib->blue_len == 8)
|
|
|
|
val = ((( val & 0xff) << dib->blue_shift) |
|
|
|
|
(((val >> 8) & 0xff) << dib->green_shift) |
|
|
|
|
(((val >> 16) & 0xff) << dib->red_shift));
|
|
|
|
else
|
2017-03-08 20:57:41 +01:00
|
|
|
val = rgb_to_pixel_masks( dib, val >> 16, val >> 8, val );
|
2011-11-28 13:21:52 +01:00
|
|
|
|
2012-11-30 17:59:04 +01:00
|
|
|
memset_32( ptr, val, rc->right - rc->left );
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-12-04 17:10:30 +01:00
|
|
|
|
|
|
|
case GRADIENT_FILL_TRIANGLE:
|
|
|
|
if (!(det = triangle_det( v ))) return FALSE;
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride / 4)
|
|
|
|
{
|
|
|
|
triangle_coords( v, rc, y, &left, &right );
|
|
|
|
|
|
|
|
if (dib->red_len == 8 && dib->green_len == 8 && dib->blue_len == 8)
|
|
|
|
for (x = left; x < right; x++)
|
|
|
|
{
|
|
|
|
DWORD val = gradient_triangle_24( v, x, y, det );
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[x - rc->left] = ((( val & 0xff) << dib->blue_shift) |
|
|
|
|
(((val >> 8) & 0xff) << dib->green_shift) |
|
|
|
|
(((val >> 16) & 0xff) << dib->red_shift));
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
for (x = left; x < right; x++)
|
|
|
|
{
|
|
|
|
DWORD val = gradient_triangle_24( v, x, y, det );
|
2017-03-08 20:57:41 +01:00
|
|
|
ptr[x - rc->left] = rgb_to_pixel_masks( dib, val >> 16, val >> 8, val );
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static BOOL gradient_rect_24( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
BYTE *ptr = get_pixel_ptr_24( dib, rc->left, rc->top );
|
2011-12-04 17:10:30 +01:00
|
|
|
int x, y, left, right, det;
|
2011-11-28 13:21:52 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
DWORD val = gradient_rgb_24( v, rc->left + x - v[0].x, v[1].x - v[0].x );
|
2011-11-28 13:21:52 +01:00
|
|
|
ptr[x * 3] = val;
|
|
|
|
ptr[x * 3 + 1] = val >> 8;
|
|
|
|
ptr[x * 3 + 2] = val >> 16;
|
|
|
|
}
|
|
|
|
|
2012-04-27 14:24:43 +02:00
|
|
|
for (y = rc->top + 1; y < rc->bottom; y++, ptr += dib->stride)
|
2011-11-28 13:21:52 +01:00
|
|
|
memcpy( ptr + dib->stride, ptr, (rc->right - rc->left) * 3 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
2011-12-04 17:10:30 +01:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
|
|
|
DWORD val = gradient_rgb_24( v, y - v[0].y, v[1].y - v[0].y );
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = 0; x < rc->right - rc->left; x++)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
|
|
|
ptr[x * 3] = val;
|
|
|
|
ptr[x * 3 + 1] = val >> 8;
|
|
|
|
ptr[x * 3 + 2] = val >> 16;
|
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_TRIANGLE:
|
|
|
|
if (!(det = triangle_det( v ))) return FALSE;
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride)
|
|
|
|
{
|
|
|
|
triangle_coords( v, rc, y, &left, &right );
|
|
|
|
for (x = left; x < right; x++)
|
|
|
|
{
|
|
|
|
DWORD val = gradient_triangle_24( v, x, y, det );
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[(x - rc->left) * 3] = val;
|
|
|
|
ptr[(x - rc->left) * 3 + 1] = val >> 8;
|
|
|
|
ptr[(x - rc->left) * 3 + 2] = val >> 16;
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static BOOL gradient_rect_555( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
WORD *ptr = get_pixel_ptr_16( dib, rc->left, rc->top );
|
2011-12-04 17:10:30 +01:00
|
|
|
int x, y, left, right, det;
|
2011-11-28 13:21:52 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
2011-11-29 14:18:02 +01:00
|
|
|
for (y = rc->top; y < min( rc->top + 4, rc->bottom ); y++, ptr += dib->stride / 2)
|
|
|
|
for (x = rc->left; x < rc->right; x++)
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[x - rc->left] = gradient_rgb_555( v, x - v[0].x, v[1].x - v[0].x, x, y );
|
|
|
|
for ( ; y < rc->bottom; y++, ptr += dib->stride / 2)
|
2011-11-29 14:18:02 +01:00
|
|
|
memcpy( ptr, ptr - dib->stride * 2, (rc->right - rc->left) * 2 );
|
2011-11-28 13:21:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
2011-11-29 14:18:02 +01:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride / 2)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2011-11-29 14:18:02 +01:00
|
|
|
WORD values[4];
|
|
|
|
for (x = 0; x < 4; x++) values[x] = gradient_rgb_555( v, y - v[0].y, v[1].y - v[0].y, x, y );
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = rc->left; x < rc->right; x++) ptr[x - rc->left] = values[x % 4];
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-12-04 17:10:30 +01:00
|
|
|
|
|
|
|
case GRADIENT_FILL_TRIANGLE:
|
|
|
|
if (!(det = triangle_det( v ))) return FALSE;
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride / 2)
|
|
|
|
{
|
|
|
|
triangle_coords( v, rc, y, &left, &right );
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = left; x < right; x++) ptr[x - rc->left] = gradient_triangle_555( v, x, y, det );
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static BOOL gradient_rect_16( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
WORD *ptr = get_pixel_ptr_16( dib, rc->left, rc->top );
|
2011-12-04 17:10:30 +01:00
|
|
|
int x, y, left, right, det;
|
2011-11-28 13:21:52 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
2011-11-29 14:18:02 +01:00
|
|
|
for (y = rc->top; y < min( rc->top + 4, rc->bottom ); y++, ptr += dib->stride / 2)
|
|
|
|
for (x = rc->left; x < rc->right; x++)
|
|
|
|
{
|
|
|
|
WORD val = gradient_rgb_555( v, x - v[0].x, v[1].x - v[0].x, x, y );
|
2017-03-08 20:57:41 +01:00
|
|
|
ptr[x - rc->left] = rgb_to_pixel_masks( dib,
|
|
|
|
((val >> 7) & 0xf8) | ((val >> 12) & 0x07),
|
|
|
|
((val >> 2) & 0xf8) | ((val >> 7) & 0x07),
|
|
|
|
((val << 3) & 0xf8) | ((val >> 2) & 0x07) );
|
2011-11-29 14:18:02 +01:00
|
|
|
}
|
2012-04-27 14:24:43 +02:00
|
|
|
for ( ; y < rc->bottom; y++, ptr += dib->stride / 2)
|
2011-11-29 14:18:02 +01:00
|
|
|
memcpy( ptr, ptr - dib->stride * 2, (rc->right - rc->left) * 2 );
|
2011-11-28 13:21:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
2011-11-29 14:18:02 +01:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride / 2)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2011-11-29 14:18:02 +01:00
|
|
|
WORD values[4];
|
|
|
|
for (x = 0; x < 4; x++)
|
|
|
|
{
|
|
|
|
WORD val = gradient_rgb_555( v, y - v[0].y, v[1].y - v[0].y, x, y );
|
2017-03-08 20:57:41 +01:00
|
|
|
values[x] = rgb_to_pixel_masks( dib,
|
|
|
|
((val >> 7) & 0xf8) | ((val >> 12) & 0x07),
|
|
|
|
((val >> 2) & 0xf8) | ((val >> 7) & 0x07),
|
|
|
|
((val << 3) & 0xf8) | ((val >> 2) & 0x07) );
|
2011-11-29 14:18:02 +01:00
|
|
|
}
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = rc->left; x < rc->right; x++) ptr[x - rc->left] = values[x % 4];
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-12-04 17:10:30 +01:00
|
|
|
|
|
|
|
case GRADIENT_FILL_TRIANGLE:
|
|
|
|
if (!(det = triangle_det( v ))) return FALSE;
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride / 2)
|
|
|
|
{
|
|
|
|
triangle_coords( v, rc, y, &left, &right );
|
|
|
|
for (x = left; x < right; x++)
|
|
|
|
{
|
|
|
|
WORD val = gradient_triangle_555( v, x, y, det );
|
2017-03-08 20:57:41 +01:00
|
|
|
ptr[x - rc->left] = rgb_to_pixel_masks( dib,
|
|
|
|
((val >> 7) & 0xf8) | ((val >> 12) & 0x07),
|
|
|
|
((val >> 2) & 0xf8) | ((val >> 7) & 0x07),
|
|
|
|
((val << 3) & 0xf8) | ((val >> 2) & 0x07) );
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static BOOL gradient_rect_8( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
BYTE *ptr = get_pixel_ptr_8( dib, rc->left, rc->top );
|
2011-12-04 17:10:30 +01:00
|
|
|
int x, y, left, right, det;
|
2011-11-28 13:21:52 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
2011-11-29 14:22:59 +01:00
|
|
|
for (y = rc->top; y < min( rc->top + 16, rc->bottom ); y++, ptr += dib->stride)
|
|
|
|
for (x = rc->left; x < rc->right; x++)
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[x - rc->left] = gradient_rgb_8( dib, v, x - v[0].x, v[1].x - v[0].x, x, y );
|
|
|
|
for ( ; y < rc->bottom; y++, ptr += dib->stride)
|
2011-11-29 14:22:59 +01:00
|
|
|
memcpy( ptr, ptr - dib->stride * 16, rc->right - rc->left );
|
2011-11-28 13:21:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
2011-11-29 14:22:59 +01:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2011-11-29 14:22:59 +01:00
|
|
|
BYTE values[16];
|
|
|
|
for (x = 0; x < 16; x++)
|
|
|
|
values[x] = gradient_rgb_8( dib, v, y - v[0].y, v[1].y - v[0].y, x, y );
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = rc->left; x < rc->right; x++) ptr[x - rc->left] = values[x % 16];
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-12-04 17:10:30 +01:00
|
|
|
|
|
|
|
case GRADIENT_FILL_TRIANGLE:
|
|
|
|
if (!(det = triangle_det( v ))) return FALSE;
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride)
|
|
|
|
{
|
|
|
|
triangle_coords( v, rc, y, &left, &right );
|
2012-04-27 14:24:43 +02:00
|
|
|
for (x = left; x < right; x++) ptr[x - rc->left] = gradient_triangle_8( dib, v, x, y, det );
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static BOOL gradient_rect_4( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
BYTE *ptr = get_pixel_ptr_4( dib, rc->left, rc->top );
|
|
|
|
int x, y, left, right, det, pos;
|
2011-11-28 13:21:52 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
2011-11-29 14:22:59 +01:00
|
|
|
for (y = rc->top; y < min( rc->top + 16, rc->bottom ); y++, ptr += dib->stride)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = rc->left, pos = (dib->rect.left + rc->left) & 1; x < rc->right; x++, pos++)
|
2011-11-29 14:22:59 +01:00
|
|
|
{
|
|
|
|
BYTE val = gradient_rgb_8( dib, v, x - v[0].x, v[1].x - v[0].x, x, y );
|
2012-04-27 14:24:43 +02:00
|
|
|
if (pos & 1)
|
|
|
|
ptr[pos / 2] = val | (ptr[pos / 2] & 0xf0);
|
2011-11-29 14:22:59 +01:00
|
|
|
else
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[pos / 2] = (val << 4) | (ptr[pos / 2] & 0x0f);
|
2011-11-29 14:22:59 +01:00
|
|
|
}
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
2011-11-29 14:22:59 +01:00
|
|
|
for ( ; y < rc->bottom; y++, ptr += dib->stride)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
|
|
|
x = rc->left;
|
2012-04-27 14:44:53 +02:00
|
|
|
pos = (dib->rect.left + rc->left) & 1;
|
2012-04-27 14:24:43 +02:00
|
|
|
if (pos)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[0] = (ptr[-16 * dib->stride] & 0x0f) | (ptr[0] & 0xf0);
|
|
|
|
pos++;
|
2011-11-28 13:21:52 +01:00
|
|
|
x++;
|
|
|
|
}
|
2012-04-27 14:24:43 +02:00
|
|
|
for (; x < rc->right - 1; x += 2, pos += 2) ptr[pos / 2] = ptr[pos / 2 - 16 * dib->stride];
|
2011-11-28 13:21:52 +01:00
|
|
|
if (x < rc->right)
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[pos / 2] = (ptr[pos / 2] & 0x0f) | (ptr[pos / 2 - 16 * dib->stride] & 0xf0);
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
2011-11-29 14:22:59 +01:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2011-11-29 14:22:59 +01:00
|
|
|
BYTE values[16];
|
|
|
|
for (x = 0; x < 16; x++)
|
|
|
|
values[x] = gradient_rgb_8( dib, v, y - v[0].y, v[1].y - v[0].y, x, y );
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = rc->left, pos = (dib->rect.left + rc->left) & 1; x < rc->right; x++, pos++)
|
2012-04-27 14:24:43 +02:00
|
|
|
if (pos & 1)
|
|
|
|
ptr[pos / 2] = values[x % 16] | (ptr[pos / 2] & 0xf0);
|
2011-11-29 14:22:59 +01:00
|
|
|
else
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[pos / 2] = (values[x % 16] << 4) | (ptr[pos / 2] & 0x0f);
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-12-04 17:10:30 +01:00
|
|
|
|
|
|
|
case GRADIENT_FILL_TRIANGLE:
|
|
|
|
if (!(det = triangle_det( v ))) return FALSE;
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride)
|
|
|
|
{
|
|
|
|
triangle_coords( v, rc, y, &left, &right );
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = left, pos = left - rc->left + ((dib->rect.left + rc->left) & 1); x < right; x++, pos++)
|
2011-12-04 17:10:30 +01:00
|
|
|
{
|
|
|
|
BYTE val = gradient_triangle_8( dib, v, x, y, det );
|
2012-04-27 14:24:43 +02:00
|
|
|
if (pos & 1)
|
|
|
|
ptr[pos / 2] = val | (ptr[pos / 2] & 0xf0);
|
2011-12-04 17:10:30 +01:00
|
|
|
else
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[pos / 2] = (val << 4) | (ptr[pos / 2] & 0x0f);
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static BOOL gradient_rect_1( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
BYTE *ptr = get_pixel_ptr_1( dib, rc->left, rc->top );
|
|
|
|
int x, y, left, right, det, pos;
|
2011-11-28 13:21:52 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
2011-12-05 13:46:23 +01:00
|
|
|
for (y = rc->top; y < min( rc->top + 16, rc->bottom ); y++, ptr += dib->stride)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = rc->left, pos = (dib->rect.left + rc->left) & 7; x < rc->right; x++, pos++)
|
2011-12-05 13:46:23 +01:00
|
|
|
{
|
|
|
|
BYTE val = gradient_rgb_8( dib, v, x - v[0].x, v[1].x - v[0].x, x, y ) ? 0xff : 0;
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[pos / 8] = (ptr[pos / 8] & ~pixel_masks_1[pos % 8]) | (val & pixel_masks_1[pos % 8]);
|
2011-12-05 13:46:23 +01:00
|
|
|
}
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
2011-12-05 13:46:23 +01:00
|
|
|
for ( ; y < rc->bottom; y++, ptr += dib->stride)
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = rc->left, pos = (dib->rect.left + rc->left) & 7; x < rc->right; x++, pos++)
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[pos / 8] = (ptr[pos / 8] & ~pixel_masks_1[pos % 8]) |
|
|
|
|
(ptr[pos / 8 - 16 * dib->stride] & pixel_masks_1[pos % 8]);
|
2011-11-28 13:21:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
2011-12-05 13:46:23 +01:00
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride)
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2011-12-05 13:46:23 +01:00
|
|
|
BYTE values[16];
|
|
|
|
for (x = 0; x < 16; x++)
|
|
|
|
values[x] = gradient_rgb_8( dib, v, y - v[0].y, v[1].y - v[0].y, x, y ) ? 0xff : 0;
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = rc->left, pos = (dib->rect.left + rc->left) & 7; x < rc->right; x++, pos++)
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[pos / 8] = (ptr[pos / 8] & ~pixel_masks_1[pos % 8]) |
|
|
|
|
(values[x % 16] & pixel_masks_1[pos % 8]);
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-12-04 17:10:30 +01:00
|
|
|
|
|
|
|
case GRADIENT_FILL_TRIANGLE:
|
|
|
|
if (!(det = triangle_det( v ))) return FALSE;
|
|
|
|
for (y = rc->top; y < rc->bottom; y++, ptr += dib->stride)
|
|
|
|
{
|
|
|
|
triangle_coords( v, rc, y, &left, &right );
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = left, pos = left - rc->left + ((dib->rect.left + rc->left) & 7); x < right; x++, pos++)
|
2011-12-04 17:10:30 +01:00
|
|
|
{
|
2011-12-05 13:46:23 +01:00
|
|
|
BYTE val = gradient_triangle_8( dib, v, x, y, det ) ? 0xff : 0;
|
2012-04-27 14:24:43 +02:00
|
|
|
ptr[pos / 8] = (ptr[pos / 8] & ~pixel_masks_1[pos % 8]) | (val & pixel_masks_1[pos % 8]);
|
2011-12-04 17:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:30 +01:00
|
|
|
static BOOL gradient_rect_null( const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode )
|
2011-11-28 13:21:52 +01:00
|
|
|
{
|
2011-12-04 17:10:30 +01:00
|
|
|
return TRUE;
|
2011-11-28 13:21:52 +01:00
|
|
|
}
|
|
|
|
|
2016-07-13 11:02:28 +02:00
|
|
|
static void mask_rect_32( const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, int rop2 )
|
|
|
|
{
|
2016-08-24 09:55:32 +02:00
|
|
|
DWORD *dst_start = get_pixel_ptr_32(dst, rc->left, rc->top), dst_colors[256];
|
2016-07-13 11:02:28 +02:00
|
|
|
DWORD src_val, bit_val, i, full, pos;
|
2016-08-24 09:55:33 +02:00
|
|
|
int x, y, origin_end = origin->x + rc->right - rc->left;
|
2016-07-13 11:02:28 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
|
|
|
|
|
|
|
|
if (dst->funcs == &funcs_8888)
|
2016-08-24 09:55:32 +02:00
|
|
|
for (i = 0; i < 2; i++)
|
2016-07-13 11:02:28 +02:00
|
|
|
dst_colors[i] = color_table[i].rgbRed << 16 | color_table[i].rgbGreen << 8 |
|
|
|
|
color_table[i].rgbBlue;
|
|
|
|
else
|
2016-08-24 09:55:32 +02:00
|
|
|
for (i = 0; i < 2; i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
|
2016-07-13 11:02:28 +02:00
|
|
|
|
2016-08-24 09:55:32 +02:00
|
|
|
/* Creating a BYTE-sized table so we don't need to mask the lsb of bit_val */
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 2; i < ARRAY_SIZE(dst_colors); i++)
|
2016-08-24 09:55:32 +02:00
|
|
|
dst_colors[i] = dst_colors[i & 1];
|
|
|
|
|
2016-08-24 09:55:33 +02:00
|
|
|
/* Special case starting and finishing in same byte, neither on byte boundary */
|
|
|
|
if ((origin->x & 7) && (origin_end & 7) && (origin->x & ~7) == (origin_end & ~7))
|
|
|
|
{
|
2016-08-25 10:43:09 +02:00
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
2016-08-24 09:55:33 +02:00
|
|
|
for (y = rc->top; y < rc->bottom; y++)
|
|
|
|
{
|
|
|
|
pos = origin->x & 7;
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++, pos++)
|
|
|
|
{
|
|
|
|
bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
|
|
|
do_rop_codes_32( dst_start + x, dst_colors[bit_val], &codes );
|
|
|
|
}
|
|
|
|
dst_start += dst->stride / 4;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
full = ((rc->right - rc->left) - ((8 - (origin->x & 7)) & 7)) / 8;
|
|
|
|
|
2016-08-25 10:43:09 +02:00
|
|
|
#define LOOP( op ) \
|
|
|
|
for (y = rc->top; y < rc->bottom; y++) \
|
|
|
|
{ \
|
|
|
|
pos = origin->x & 7; \
|
|
|
|
src_val = src_start[pos / 8]; \
|
|
|
|
x = 0; \
|
|
|
|
switch (pos & 7) \
|
|
|
|
{ \
|
|
|
|
case 1: bit_val = src_val >> 6; op; x++; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 2: bit_val = src_val >> 5; op; x++; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 3: bit_val = src_val >> 4; op; x++; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 4: bit_val = src_val >> 3; op; x++; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 5: bit_val = src_val >> 2; op; x++; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 6: bit_val = src_val >> 1; op; x++; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 7: bit_val = src_val; op; x++; \
|
|
|
|
pos = (pos + 7) & ~7; \
|
|
|
|
} \
|
|
|
|
for (i = 0; i < full; i++, pos += 8) \
|
|
|
|
{ \
|
|
|
|
src_val = src_start[pos / 8]; \
|
|
|
|
bit_val = src_val >> 7; op; x++; \
|
|
|
|
bit_val = src_val >> 6; op; x++; \
|
|
|
|
bit_val = src_val >> 5; op; x++; \
|
|
|
|
bit_val = src_val >> 4; op; x++; \
|
|
|
|
bit_val = src_val >> 3; op; x++; \
|
|
|
|
bit_val = src_val >> 2; op; x++; \
|
|
|
|
bit_val = src_val >> 1; op; x++; \
|
|
|
|
bit_val = src_val; op; x++; \
|
|
|
|
} \
|
|
|
|
if (origin_end & 7) \
|
|
|
|
{ \
|
|
|
|
src_val = src_start[pos / 8]; \
|
|
|
|
x += (origin_end & 7) - 1; \
|
|
|
|
switch (origin_end & 7) \
|
|
|
|
{ \
|
|
|
|
case 7: bit_val = src_val >> 1; op; x--; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 6: bit_val = src_val >> 2; op; x--; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 5: bit_val = src_val >> 3; op; x--; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 4: bit_val = src_val >> 4; op; x--; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 3: bit_val = src_val >> 5; op; x--; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 2: bit_val = src_val >> 6; op; x--; \
|
|
|
|
/* fall through */ \
|
|
|
|
case 1: bit_val = src_val >> 7; op; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
dst_start += dst->stride / 4; \
|
|
|
|
src_start += src->stride; \
|
|
|
|
}
|
2016-07-13 11:02:28 +02:00
|
|
|
|
2016-08-25 10:43:09 +02:00
|
|
|
switch (rop2)
|
|
|
|
{
|
|
|
|
ROPS_ALL( dst_start[x], dst_colors[bit_val] )
|
2016-07-13 11:02:28 +02:00
|
|
|
}
|
2016-08-25 10:43:09 +02:00
|
|
|
#undef LOOP
|
2016-07-13 11:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mask_rect_24( const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, int rop2 )
|
|
|
|
{
|
|
|
|
BYTE *dst_start = get_pixel_ptr_24(dst, rc->left, rc->top);
|
|
|
|
DWORD src_val, bit_val, i, full, pos;
|
|
|
|
struct rop_codes codes;
|
2016-08-24 09:55:33 +02:00
|
|
|
int x, y, origin_end = origin->x + rc->right - rc->left;
|
2016-07-13 11:02:28 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
|
|
|
|
RGBQUAD rgb;
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
2016-08-24 09:55:33 +02:00
|
|
|
/* Special case starting and finishing in same byte, neither on byte boundary */
|
|
|
|
if ((origin->x & 7) && (origin_end & 7) && (origin->x & ~7) == (origin_end & ~7))
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++)
|
|
|
|
{
|
|
|
|
pos = origin->x & 7;
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++, pos++)
|
|
|
|
{
|
|
|
|
bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
}
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
full = ((rc->right - rc->left) - ((8 - (origin->x & 7)) & 7)) / 8;
|
|
|
|
|
2016-07-13 11:02:28 +02:00
|
|
|
for (y = rc->top; y < rc->bottom; y++)
|
|
|
|
{
|
|
|
|
pos = origin->x & 7;
|
2016-08-24 09:55:34 +02:00
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
x = 0;
|
2016-07-13 11:02:28 +02:00
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
switch (pos & 7)
|
2016-07-13 11:02:28 +02:00
|
|
|
{
|
2016-08-24 09:55:34 +02:00
|
|
|
case 1:
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
/* fall through */
|
|
|
|
case 2:
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
2016-07-13 11:02:28 +02:00
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
2016-08-24 09:55:34 +02:00
|
|
|
x++;
|
|
|
|
/* fall through */
|
|
|
|
case 4:
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
/* fall through */
|
|
|
|
case 5:
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
/* fall through */
|
|
|
|
case 6:
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
/* fall through */
|
|
|
|
case 7:
|
|
|
|
bit_val = src_val & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
pos = (pos + 7) & ~7;
|
2016-07-13 11:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < full; i++, pos += 8)
|
|
|
|
{
|
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
|
|
|
|
bit_val = (src_val >> 7) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
|
|
|
|
bit_val = src_val & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
if (origin_end & 7)
|
2016-07-13 11:02:28 +02:00
|
|
|
{
|
2016-08-24 09:55:34 +02:00
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
x += (origin_end & 7) - 1;
|
|
|
|
|
|
|
|
switch (origin_end & 7)
|
|
|
|
{
|
|
|
|
case 7:
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x--;
|
|
|
|
/* fall through */
|
|
|
|
case 6:
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x--;
|
|
|
|
/* fall through */
|
|
|
|
case 5:
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x--;
|
|
|
|
/* fall through */
|
|
|
|
case 4:
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x--;
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x--;
|
|
|
|
/* fall through */
|
|
|
|
case 2:
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
x--;
|
|
|
|
/* fall through */
|
|
|
|
case 1:
|
|
|
|
bit_val = (src_val >> 7) & 1;
|
|
|
|
rgb = color_table[bit_val];
|
|
|
|
do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
|
|
|
|
do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
|
|
|
|
}
|
2016-07-13 11:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mask_rect_16( const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, int rop2 )
|
|
|
|
{
|
|
|
|
WORD *dst_start = get_pixel_ptr_16(dst, rc->left, rc->top), dst_colors[2];
|
|
|
|
DWORD src_val, bit_val, i, full, pos;
|
|
|
|
struct rop_codes codes;
|
2016-08-24 09:55:33 +02:00
|
|
|
int x, y, origin_end = origin->x + rc->right - rc->left;
|
2016-07-13 11:02:28 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
if (dst->funcs == &funcs_555)
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2016-07-13 11:02:28 +02:00
|
|
|
dst_colors[i] = ((color_table[i].rgbRed << 7) & 0x7c00) |
|
|
|
|
((color_table[i].rgbGreen << 2) & 0x03e0) |
|
|
|
|
((color_table[i].rgbBlue >> 3) & 0x001f);
|
|
|
|
else
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
|
2016-07-13 11:02:28 +02:00
|
|
|
|
2016-08-24 09:55:33 +02:00
|
|
|
/* Special case starting and finishing in same byte, neither on byte boundary */
|
|
|
|
if ((origin->x & 7) && (origin_end & 7) && (origin->x & ~7) == (origin_end & ~7))
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++)
|
|
|
|
{
|
|
|
|
pos = origin->x & 7;
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++, pos++)
|
|
|
|
{
|
|
|
|
bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
|
|
|
do_rop_codes_16( dst_start + x, dst_colors[bit_val], &codes );
|
|
|
|
}
|
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
full = ((rc->right - rc->left) - ((8 - (origin->x & 7)) & 7)) / 8;
|
|
|
|
|
2016-07-13 11:02:28 +02:00
|
|
|
for (y = rc->top; y < rc->bottom; y++)
|
|
|
|
{
|
|
|
|
pos = origin->x & 7;
|
2016-08-24 09:55:34 +02:00
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
x = 0;
|
2016-07-13 11:02:28 +02:00
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
switch (pos & 7)
|
2016-07-13 11:02:28 +02:00
|
|
|
{
|
2016-08-24 09:55:34 +02:00
|
|
|
case 1:
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 2:
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 4:
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 5:
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 6:
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 7:
|
|
|
|
bit_val = src_val & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
pos = (pos + 7) & ~7;
|
2016-07-13 11:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < full; i++, pos += 8)
|
|
|
|
{
|
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
|
|
|
|
bit_val = (src_val >> 7) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = src_val & 1;
|
|
|
|
do_rop_codes_16( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
}
|
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
if (origin_end & 7)
|
2016-07-13 11:02:28 +02:00
|
|
|
{
|
2016-08-24 09:55:34 +02:00
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
x += (origin_end & 7) - 1;
|
|
|
|
|
|
|
|
switch (origin_end & 7)
|
|
|
|
{
|
|
|
|
case 7:
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 6:
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 5:
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 4:
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 2:
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 1:
|
|
|
|
bit_val = (src_val >> 7) & 1;
|
|
|
|
do_rop_codes_16( dst_start + x, dst_colors[bit_val], &codes );
|
|
|
|
}
|
2016-07-13 11:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dst_start += dst->stride / 2;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mask_rect_8( const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, int rop2 )
|
|
|
|
{
|
|
|
|
BYTE *dst_start = get_pixel_ptr_8(dst, rc->left, rc->top), dst_colors[2];
|
|
|
|
DWORD src_val, bit_val, i, full, pos;
|
|
|
|
struct rop_codes codes;
|
2016-08-24 09:55:33 +02:00
|
|
|
int x, y, origin_end = origin->x + rc->right - rc->left;
|
2016-07-13 11:02:28 +02:00
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2017-03-08 21:29:51 +01:00
|
|
|
dst_colors[i] = FILTER_DIBINDEX(color_table[i], rgbquad_to_pixel_colortable(dst, color_table[i]));
|
2016-07-13 11:02:28 +02:00
|
|
|
|
2016-08-24 09:55:33 +02:00
|
|
|
/* Special case starting and finishing in same byte, neither on byte boundary */
|
|
|
|
if ((origin->x & 7) && (origin_end & 7) && (origin->x & ~7) == (origin_end & ~7))
|
|
|
|
{
|
|
|
|
for (y = rc->top; y < rc->bottom; y++)
|
|
|
|
{
|
|
|
|
pos = origin->x & 7;
|
|
|
|
for (x = 0; x < rc->right - rc->left; x++, pos++)
|
|
|
|
{
|
|
|
|
bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
|
|
|
do_rop_codes_8( dst_start + x, dst_colors[bit_val], &codes );
|
|
|
|
}
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
full = ((rc->right - rc->left) - ((8 - (origin->x & 7)) & 7)) / 8;
|
|
|
|
|
2016-07-13 11:02:28 +02:00
|
|
|
for (y = rc->top; y < rc->bottom; y++)
|
|
|
|
{
|
|
|
|
pos = origin->x & 7;
|
2016-08-24 09:55:34 +02:00
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
x = 0;
|
2016-07-13 11:02:28 +02:00
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
switch (pos & 7)
|
2016-07-13 11:02:28 +02:00
|
|
|
{
|
2016-08-24 09:55:34 +02:00
|
|
|
case 1:
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 2:
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 4:
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 5:
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 6:
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 7:
|
|
|
|
bit_val = src_val & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
pos = (pos + 7) & ~7;
|
2016-07-13 11:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < full; i++, pos += 8)
|
|
|
|
{
|
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
|
|
|
|
bit_val = (src_val >> 7) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
bit_val = src_val & 1;
|
|
|
|
do_rop_codes_8( dst_start + x++, dst_colors[bit_val], &codes );
|
|
|
|
}
|
|
|
|
|
2016-08-24 09:55:34 +02:00
|
|
|
if (origin_end & 7)
|
2016-07-13 11:02:28 +02:00
|
|
|
{
|
2016-08-24 09:55:34 +02:00
|
|
|
src_val = src_start[pos / 8];
|
|
|
|
x += (origin_end & 7) - 1;
|
|
|
|
|
|
|
|
switch (origin_end & 7)
|
|
|
|
{
|
|
|
|
case 7:
|
|
|
|
bit_val = (src_val >> 1) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 6:
|
|
|
|
bit_val = (src_val >> 2) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 5:
|
|
|
|
bit_val = (src_val >> 3) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 4:
|
|
|
|
bit_val = (src_val >> 4) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
bit_val = (src_val >> 5) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 2:
|
|
|
|
bit_val = (src_val >> 6) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x--, dst_colors[bit_val], &codes );
|
|
|
|
/* fall through */
|
|
|
|
case 1:
|
|
|
|
bit_val = (src_val >> 7) & 1;
|
|
|
|
do_rop_codes_8( dst_start + x, dst_colors[bit_val], &codes );
|
|
|
|
}
|
2016-07-13 11:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mask_rect_4( const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, int rop2 )
|
|
|
|
{
|
|
|
|
BYTE *dst_start = get_pixel_ptr_4(dst, rc->left, rc->top), dst_colors[2], *dst_ptr;
|
|
|
|
DWORD bit_val, i, pos;
|
|
|
|
struct rop_codes codes;
|
|
|
|
int x, y;
|
|
|
|
int left = dst->rect.left + rc->left;
|
|
|
|
int right = dst->rect.left + rc->right;
|
|
|
|
const RGBQUAD *color_table = get_dib_color_table( src );
|
|
|
|
BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
2018-10-05 21:35:35 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
|
2016-07-13 11:02:28 +02:00
|
|
|
{
|
2017-03-08 21:29:51 +01:00
|
|
|
dst_colors[i] = FILTER_DIBINDEX(color_table[i],rgbquad_to_pixel_colortable(dst, color_table[i]));
|
2016-07-13 11:02:28 +02:00
|
|
|
/* Set high nibble to match so we don't need to shift it later. */
|
|
|
|
dst_colors[i] |= dst_colors[i] << 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y = rc->top; y < rc->bottom; y++)
|
|
|
|
{
|
|
|
|
pos = origin->x & 7;
|
|
|
|
|
|
|
|
for (x = left, dst_ptr = dst_start; x < right; x++, pos++)
|
|
|
|
{
|
|
|
|
bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
|
|
|
|
if (x & 1)
|
|
|
|
do_rop_codes_mask_8( dst_ptr++, dst_colors[bit_val], &codes, 0x0f );
|
|
|
|
else
|
|
|
|
do_rop_codes_mask_8( dst_ptr, dst_colors[bit_val], &codes, 0xf0 );
|
|
|
|
}
|
|
|
|
dst_start += dst->stride;
|
|
|
|
src_start += src->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mask_rect_null( const dib_info *dst, const RECT *rc,
|
|
|
|
const dib_info *src, const POINT *origin, int rop2 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-11-14 13:49:06 +01:00
|
|
|
static inline BYTE aa_color( BYTE dst, BYTE text, BYTE min_comp, BYTE max_comp )
|
|
|
|
{
|
|
|
|
if (dst == text) return dst;
|
|
|
|
|
|
|
|
if (dst > text)
|
|
|
|
{
|
|
|
|
DWORD diff = dst - text;
|
|
|
|
DWORD range = max_comp - text;
|
|
|
|
dst = text + (diff * range ) / (0xff - text);
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD diff = text - dst;
|
|
|
|
DWORD range = text - min_comp;
|
|
|
|
dst = text - (diff * range) / text;
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD aa_rgb( BYTE r_dst, BYTE g_dst, BYTE b_dst, DWORD text, const struct intensity_range *range )
|
|
|
|
{
|
|
|
|
return (aa_color( b_dst, text, range->b_min, range->b_max ) |
|
|
|
|
aa_color( g_dst, text >> 8, range->g_min, range->g_max ) << 8 |
|
|
|
|
aa_color( r_dst, text >> 16, range->r_min, range->r_max ) << 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_8888( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
|
|
|
DWORD *dst_ptr = get_pixel_ptr_32( dib, rect->left, rect->top );
|
|
|
|
const BYTE *glyph_ptr = get_pixel_ptr_8( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] <= 1) continue;
|
|
|
|
if (glyph_ptr[x] >= 16) { dst_ptr[x] = text_pixel; continue; }
|
|
|
|
dst_ptr[x] = aa_rgb( dst_ptr[x] >> 16, dst_ptr[x] >> 8, dst_ptr[x], text_pixel, ranges + glyph_ptr[x] );
|
|
|
|
}
|
|
|
|
dst_ptr += dib->stride / 4;
|
|
|
|
glyph_ptr += glyph->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_32( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
|
|
|
DWORD *dst_ptr = get_pixel_ptr_32( dib, rect->left, rect->top );
|
|
|
|
const BYTE *glyph_ptr = get_pixel_ptr_8( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
DWORD text, val;
|
|
|
|
|
|
|
|
text = get_field( text_pixel, dib->red_shift, dib->red_len ) << 16 |
|
|
|
|
get_field( text_pixel, dib->green_shift, dib->green_len ) << 8 |
|
|
|
|
get_field( text_pixel, dib->blue_shift, dib->blue_len );
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] <= 1) continue;
|
|
|
|
if (glyph_ptr[x] >= 16) { dst_ptr[x] = text_pixel; continue; }
|
|
|
|
val = aa_rgb( get_field(dst_ptr[x], dib->red_shift, dib->red_len),
|
|
|
|
get_field(dst_ptr[x], dib->green_shift, dib->green_len),
|
|
|
|
get_field(dst_ptr[x], dib->blue_shift, dib->blue_len),
|
|
|
|
text, ranges + glyph_ptr[x] );
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_ptr[x] = rgb_to_pixel_masks( dib, val >> 16, val >> 8, val );
|
2011-11-14 13:49:06 +01:00
|
|
|
}
|
|
|
|
dst_ptr += dib->stride / 4;
|
|
|
|
glyph_ptr += glyph->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_24( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_24( dib, rect->left, rect->top );
|
|
|
|
const BYTE *glyph_ptr = get_pixel_ptr_8( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
DWORD val;
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] <= 1) continue;
|
|
|
|
if (glyph_ptr[x] >= 16)
|
|
|
|
val = text_pixel;
|
|
|
|
else
|
|
|
|
val = aa_rgb( dst_ptr[x * 3 + 2], dst_ptr[x * 3 + 1], dst_ptr[x * 3],
|
|
|
|
text_pixel, ranges + glyph_ptr[x] );
|
|
|
|
dst_ptr[x * 3] = val;
|
|
|
|
dst_ptr[x * 3 + 1] = val >> 8;
|
|
|
|
dst_ptr[x * 3 + 2] = val >> 16;
|
|
|
|
}
|
|
|
|
dst_ptr += dib->stride;
|
|
|
|
glyph_ptr += glyph->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_555( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
|
|
|
WORD *dst_ptr = get_pixel_ptr_16( dib, rect->left, rect->top );
|
|
|
|
const BYTE *glyph_ptr = get_pixel_ptr_8( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
DWORD text, val;
|
|
|
|
|
|
|
|
text = ((text_pixel << 9) & 0xf80000) | ((text_pixel << 4) & 0x070000) |
|
|
|
|
((text_pixel << 6) & 0x00f800) | ((text_pixel << 1) & 0x000700) |
|
|
|
|
((text_pixel << 3) & 0x0000f8) | ((text_pixel >> 2) & 0x000007);
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] <= 1) continue;
|
|
|
|
if (glyph_ptr[x] >= 16) { dst_ptr[x] = text_pixel; continue; }
|
|
|
|
val = aa_rgb( ((dst_ptr[x] >> 7) & 0xf8) | ((dst_ptr[x] >> 12) & 0x07),
|
|
|
|
((dst_ptr[x] >> 2) & 0xf8) | ((dst_ptr[x] >> 7) & 0x07),
|
|
|
|
((dst_ptr[x] << 3) & 0xf8) | ((dst_ptr[x] >> 2) & 0x07),
|
|
|
|
text, ranges + glyph_ptr[x] );
|
|
|
|
dst_ptr[x] = ((val >> 9) & 0x7c00) | ((val >> 6) & 0x03e0) | ((val >> 3) & 0x001f);
|
|
|
|
}
|
|
|
|
dst_ptr += dib->stride / 2;
|
|
|
|
glyph_ptr += glyph->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_16( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
|
|
|
WORD *dst_ptr = get_pixel_ptr_16( dib, rect->left, rect->top );
|
|
|
|
const BYTE *glyph_ptr = get_pixel_ptr_8( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
DWORD text, val;
|
|
|
|
|
|
|
|
text = get_field( text_pixel, dib->red_shift, dib->red_len ) << 16 |
|
|
|
|
get_field( text_pixel, dib->green_shift, dib->green_len ) << 8 |
|
|
|
|
get_field( text_pixel, dib->blue_shift, dib->blue_len );
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] <= 1) continue;
|
|
|
|
if (glyph_ptr[x] >= 16) { dst_ptr[x] = text_pixel; continue; }
|
|
|
|
val = aa_rgb( get_field(dst_ptr[x], dib->red_shift, dib->red_len),
|
|
|
|
get_field(dst_ptr[x], dib->green_shift, dib->green_len),
|
|
|
|
get_field(dst_ptr[x], dib->blue_shift, dib->blue_len),
|
|
|
|
text, ranges + glyph_ptr[x] );
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_ptr[x] = rgb_to_pixel_masks( dib, val >> 16, val >> 8, val );
|
2011-11-14 13:49:06 +01:00
|
|
|
}
|
|
|
|
dst_ptr += dib->stride / 2;
|
|
|
|
glyph_ptr += glyph->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_8( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_8( dib, rect->left, rect->top );
|
|
|
|
const BYTE *glyph_ptr = get_pixel_ptr_8( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
/* no antialiasing, glyph should only contain 0 or 16. */
|
|
|
|
if (glyph_ptr[x] >= 16)
|
|
|
|
dst_ptr[x] = text_pixel;
|
|
|
|
}
|
|
|
|
dst_ptr += dib->stride;
|
|
|
|
glyph_ptr += glyph->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_4( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
BYTE *dst_ptr = get_pixel_ptr_4( dib, rect->left, rect->top );
|
|
|
|
const BYTE *glyph_ptr = get_pixel_ptr_8( glyph, origin->x, origin->y );
|
|
|
|
int x, y, pos;
|
2011-11-14 13:49:06 +01:00
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = 0, pos = (dib->rect.left + rect->left) & 1; x < rect->right - rect->left; x++, pos++)
|
2011-11-14 13:49:06 +01:00
|
|
|
{
|
|
|
|
/* no antialiasing, glyph should only contain 0 or 16. */
|
|
|
|
if (glyph_ptr[x] >= 16)
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
if (pos & 1)
|
|
|
|
dst_ptr[pos / 2] = text_pixel | (dst_ptr[pos / 2] & 0xf0);
|
2011-11-14 13:49:06 +01:00
|
|
|
else
|
2012-04-27 14:24:43 +02:00
|
|
|
dst_ptr[pos / 2] = (text_pixel << 4) | (dst_ptr[pos / 2] & 0x0f);
|
2011-11-14 13:49:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
dst_ptr += dib->stride;
|
|
|
|
glyph_ptr += glyph->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_1( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
2012-04-27 14:24:43 +02:00
|
|
|
BYTE *dst_ptr = get_pixel_ptr_1( dib, rect->left, rect->top );
|
|
|
|
const BYTE *glyph_ptr = get_pixel_ptr_8( glyph, origin->x, origin->y );
|
|
|
|
int x, y, pos;
|
2011-11-14 13:49:06 +01:00
|
|
|
BYTE text = (text_pixel & 1) ? 0xff : 0;
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
2012-04-27 14:44:53 +02:00
|
|
|
for (x = 0, pos = (dib->rect.left + rect->left) & 7; x < rect->right - rect->left; x++, pos++)
|
2011-11-14 13:49:06 +01:00
|
|
|
{
|
|
|
|
/* no antialiasing, glyph should only contain 0 or 16. */
|
|
|
|
if (glyph_ptr[x] >= 16)
|
2012-04-27 14:24:43 +02:00
|
|
|
dst_ptr[pos / 8] = (dst_ptr[pos / 8] & ~pixel_masks_1[pos % 8]) |
|
|
|
|
(text & pixel_masks_1[pos % 8]);
|
2011-11-14 13:49:06 +01:00
|
|
|
}
|
|
|
|
dst_ptr += dib->stride;
|
|
|
|
glyph_ptr += glyph->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_glyph_null( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
|
|
|
const POINT *origin, DWORD text_pixel, const struct intensity_range *ranges )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-10-17 03:00:53 +02:00
|
|
|
static inline BYTE blend_color_gamma( BYTE dst, BYTE text, BYTE alpha,
|
|
|
|
const struct font_gamma_ramp *gamma_ramp )
|
|
|
|
{
|
|
|
|
if (alpha == 0) return dst;
|
|
|
|
if (alpha == 255) return text;
|
|
|
|
if (dst == text) return dst;
|
|
|
|
|
|
|
|
return gamma_ramp->encode[ blend_color( gamma_ramp->decode[dst],
|
|
|
|
gamma_ramp->decode[text],
|
|
|
|
alpha ) ];
|
|
|
|
}
|
2011-11-14 13:49:06 +01:00
|
|
|
|
2018-10-17 03:00:53 +02:00
|
|
|
static inline DWORD blend_subpixel( BYTE r, BYTE g, BYTE b, DWORD text, DWORD alpha,
|
|
|
|
const struct font_gamma_ramp *gamma_ramp )
|
2012-10-30 14:22:16 +01:00
|
|
|
{
|
2018-10-17 03:00:53 +02:00
|
|
|
if (gamma_ramp != NULL && gamma_ramp->gamma != 1000)
|
|
|
|
{
|
|
|
|
return blend_color_gamma( r, text >> 16, (BYTE)(alpha >> 16), gamma_ramp ) << 16 |
|
|
|
|
blend_color_gamma( g, text >> 8, (BYTE)(alpha >> 8), gamma_ramp ) << 8 |
|
|
|
|
blend_color_gamma( b, text, (BYTE) alpha, gamma_ramp );
|
|
|
|
}
|
2012-10-30 14:22:16 +01:00
|
|
|
return blend_color( r, text >> 16, (BYTE)(alpha >> 16) ) << 16 |
|
|
|
|
blend_color( g, text >> 8, (BYTE)(alpha >> 8) ) << 8 |
|
|
|
|
blend_color( b, text, (BYTE) alpha );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_subpixel_glyph_8888( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
2018-10-17 03:00:53 +02:00
|
|
|
const POINT *origin, DWORD text_pixel,
|
|
|
|
const struct font_gamma_ramp *gamma_ramp )
|
2012-10-30 14:22:16 +01:00
|
|
|
{
|
|
|
|
DWORD *dst_ptr = get_pixel_ptr_32( dib, rect->left, rect->top );
|
|
|
|
const DWORD *glyph_ptr = get_pixel_ptr_32( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] == 0) continue;
|
2018-10-17 03:00:53 +02:00
|
|
|
dst_ptr[x] = blend_subpixel( dst_ptr[x] >> 16, dst_ptr[x] >> 8, dst_ptr[x],
|
|
|
|
text_pixel, glyph_ptr[x], gamma_ramp );
|
2012-10-30 14:22:16 +01:00
|
|
|
}
|
|
|
|
dst_ptr += dib->stride / 4;
|
|
|
|
glyph_ptr += glyph->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_subpixel_glyph_32( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
2018-10-17 03:00:53 +02:00
|
|
|
const POINT *origin, DWORD text_pixel,
|
|
|
|
const struct font_gamma_ramp *gamma_ramp )
|
2012-10-30 14:22:16 +01:00
|
|
|
{
|
|
|
|
DWORD *dst_ptr = get_pixel_ptr_32( dib, rect->left, rect->top );
|
|
|
|
const DWORD *glyph_ptr = get_pixel_ptr_32( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
DWORD text, val;
|
|
|
|
|
|
|
|
text = get_field( text_pixel, dib->red_shift, dib->red_len ) << 16 |
|
|
|
|
get_field( text_pixel, dib->green_shift, dib->green_len ) << 8 |
|
|
|
|
get_field( text_pixel, dib->blue_shift, dib->blue_len );
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] == 0) continue;
|
|
|
|
val = blend_subpixel( get_field(dst_ptr[x], dib->red_shift, dib->red_len),
|
|
|
|
get_field(dst_ptr[x], dib->green_shift, dib->green_len),
|
|
|
|
get_field(dst_ptr[x], dib->blue_shift, dib->blue_len),
|
2018-10-17 03:00:53 +02:00
|
|
|
text, glyph_ptr[x], gamma_ramp );
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_ptr[x] = rgb_to_pixel_masks( dib, val >> 16, val >> 8, val );
|
2012-10-30 14:22:16 +01:00
|
|
|
}
|
|
|
|
dst_ptr += dib->stride / 4;
|
|
|
|
glyph_ptr += glyph->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_subpixel_glyph_24( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
2018-10-17 03:00:53 +02:00
|
|
|
const POINT *origin, DWORD text_pixel,
|
|
|
|
const struct font_gamma_ramp *gamma_ramp )
|
2012-10-30 14:22:16 +01:00
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_24( dib, rect->left, rect->top );
|
|
|
|
const DWORD *glyph_ptr = get_pixel_ptr_32( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
DWORD val;
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] == 0) continue;
|
|
|
|
val = blend_subpixel( dst_ptr[x * 3 + 2], dst_ptr[x * 3 + 1], dst_ptr[x * 3],
|
2018-10-17 03:00:53 +02:00
|
|
|
text_pixel, glyph_ptr[x], gamma_ramp );
|
2012-10-30 14:22:16 +01:00
|
|
|
dst_ptr[x * 3] = val;
|
|
|
|
dst_ptr[x * 3 + 1] = val >> 8;
|
|
|
|
dst_ptr[x * 3 + 2] = val >> 16;
|
|
|
|
}
|
|
|
|
dst_ptr += dib->stride;
|
|
|
|
glyph_ptr += glyph->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_subpixel_glyph_555( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
2018-10-17 03:00:53 +02:00
|
|
|
const POINT *origin, DWORD text_pixel,
|
|
|
|
const struct font_gamma_ramp *gamma_ramp )
|
2012-10-30 14:22:16 +01:00
|
|
|
{
|
|
|
|
WORD *dst_ptr = get_pixel_ptr_16( dib, rect->left, rect->top );
|
|
|
|
const DWORD *glyph_ptr = get_pixel_ptr_32( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
DWORD text, val;
|
|
|
|
|
|
|
|
text = ((text_pixel << 9) & 0xf80000) | ((text_pixel << 4) & 0x070000) |
|
|
|
|
((text_pixel << 6) & 0x00f800) | ((text_pixel << 1) & 0x000700) |
|
|
|
|
((text_pixel << 3) & 0x0000f8) | ((text_pixel >> 2) & 0x000007);
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] == 0) continue;
|
|
|
|
val = blend_subpixel( ((dst_ptr[x] >> 7) & 0xf8) | ((dst_ptr[x] >> 12) & 0x07),
|
|
|
|
((dst_ptr[x] >> 2) & 0xf8) | ((dst_ptr[x] >> 7) & 0x07),
|
|
|
|
((dst_ptr[x] << 3) & 0xf8) | ((dst_ptr[x] >> 2) & 0x07),
|
2018-10-17 03:00:53 +02:00
|
|
|
text, glyph_ptr[x], NULL );
|
2012-10-30 14:22:16 +01:00
|
|
|
dst_ptr[x] = ((val >> 9) & 0x7c00) | ((val >> 6) & 0x03e0) | ((val >> 3) & 0x001f);
|
|
|
|
}
|
|
|
|
dst_ptr += dib->stride / 2;
|
|
|
|
glyph_ptr += glyph->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_subpixel_glyph_16( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
2018-10-17 03:00:53 +02:00
|
|
|
const POINT *origin, DWORD text_pixel,
|
|
|
|
const struct font_gamma_ramp *gamma_ramp )
|
2012-10-30 14:22:16 +01:00
|
|
|
{
|
|
|
|
WORD *dst_ptr = get_pixel_ptr_16( dib, rect->left, rect->top );
|
|
|
|
const DWORD *glyph_ptr = get_pixel_ptr_32( glyph, origin->x, origin->y );
|
|
|
|
int x, y;
|
|
|
|
DWORD text, val;
|
|
|
|
|
|
|
|
text = get_field( text_pixel, dib->red_shift, dib->red_len ) << 16 |
|
|
|
|
get_field( text_pixel, dib->green_shift, dib->green_len ) << 8 |
|
|
|
|
get_field( text_pixel, dib->blue_shift, dib->blue_len );
|
|
|
|
|
|
|
|
for (y = rect->top; y < rect->bottom; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < rect->right - rect->left; x++)
|
|
|
|
{
|
|
|
|
if (glyph_ptr[x] == 0) continue;
|
|
|
|
val = blend_subpixel( get_field(dst_ptr[x], dib->red_shift, dib->red_len),
|
|
|
|
get_field(dst_ptr[x], dib->green_shift, dib->green_len),
|
|
|
|
get_field(dst_ptr[x], dib->blue_shift, dib->blue_len),
|
2018-10-17 03:00:53 +02:00
|
|
|
text, glyph_ptr[x], NULL );
|
2017-03-08 20:57:41 +01:00
|
|
|
dst_ptr[x] = rgb_to_pixel_masks( dib, val >> 16, val >> 8, val );
|
2012-10-30 14:22:16 +01:00
|
|
|
}
|
|
|
|
dst_ptr += dib->stride / 2;
|
|
|
|
glyph_ptr += glyph->stride / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_subpixel_glyph_null( const dib_info *dib, const RECT *rect, const dib_info *glyph,
|
2018-10-17 03:00:53 +02:00
|
|
|
const POINT *origin, DWORD text_pixel,
|
|
|
|
const struct font_gamma_ramp *gamma_ramp )
|
2012-10-30 14:22:16 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
static void create_rop_masks_32(const dib_info *dib, const BYTE *hatch_ptr,
|
|
|
|
const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
DWORD *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
int x, y;
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
for(y = 0; y < 8; y++, hatch_ptr++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
for(x = 0; x < 8; x++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
if(*hatch_ptr & pixel_masks_1[x])
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits[x] = fg->and;
|
|
|
|
xor_bits[x] = fg->xor;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits[x] = bg->and;
|
|
|
|
xor_bits[x] = bg->xor;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits += dib->stride / 4;
|
|
|
|
xor_bits += dib->stride / 4;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
static void create_rop_masks_24(const dib_info *dib, const BYTE *hatch_ptr,
|
|
|
|
const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
DWORD mask_start = 0, mask_offset;
|
|
|
|
BYTE *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
int x, y;
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
for(y = 0; y < 8; y++, hatch_ptr++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
mask_offset = mask_start;
|
2012-05-23 11:24:18 +02:00
|
|
|
for(x = 0; x < 8; x++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
if(*hatch_ptr & pixel_masks_1[x])
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
and_bits[mask_offset] = fg->and & 0xff;
|
|
|
|
xor_bits[mask_offset++] = fg->xor & 0xff;
|
|
|
|
and_bits[mask_offset] = (fg->and >> 8) & 0xff;
|
|
|
|
xor_bits[mask_offset++] = (fg->xor >> 8) & 0xff;
|
|
|
|
and_bits[mask_offset] = (fg->and >> 16) & 0xff;
|
|
|
|
xor_bits[mask_offset++] = (fg->xor >> 16) & 0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
and_bits[mask_offset] = bg->and & 0xff;
|
|
|
|
xor_bits[mask_offset++] = bg->xor & 0xff;
|
|
|
|
and_bits[mask_offset] = (bg->and >> 8) & 0xff;
|
|
|
|
xor_bits[mask_offset++] = (bg->xor >> 8) & 0xff;
|
|
|
|
and_bits[mask_offset] = (bg->and >> 16) & 0xff;
|
|
|
|
xor_bits[mask_offset++] = (bg->xor >> 16) & 0xff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mask_start += dib->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
static void create_rop_masks_16(const dib_info *dib, const BYTE *hatch_ptr,
|
|
|
|
const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
WORD *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
int x, y;
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
for(y = 0; y < 8; y++, hatch_ptr++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
for(x = 0; x < 8; x++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
if(*hatch_ptr & pixel_masks_1[x])
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits[x] = fg->and;
|
|
|
|
xor_bits[x] = fg->xor;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits[x] = bg->and;
|
|
|
|
xor_bits[x] = bg->xor;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits += dib->stride / 2;
|
|
|
|
xor_bits += dib->stride / 2;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
static void create_rop_masks_8(const dib_info *dib, const BYTE *hatch_ptr,
|
|
|
|
const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
BYTE *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
int x, y;
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
for(y = 0; y < 8; y++, hatch_ptr++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
for(x = 0; x < 8; x++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
if(*hatch_ptr & pixel_masks_1[x])
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits[x] = fg->and;
|
|
|
|
xor_bits[x] = fg->xor;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits[x] = bg->and;
|
|
|
|
xor_bits[x] = bg->xor;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits += dib->stride;
|
|
|
|
xor_bits += dib->stride;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
static void create_rop_masks_4(const dib_info *dib, const BYTE *hatch_ptr,
|
|
|
|
const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
DWORD mask_offset;
|
2011-06-17 13:45:36 +02:00
|
|
|
BYTE *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
const rop_mask *rop_mask;
|
|
|
|
int x, y;
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
for(y = 0; y < 8; y++, hatch_ptr++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
for(x = mask_offset = 0; x < 8; x++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
if(*hatch_ptr & pixel_masks_1[x])
|
2011-06-17 13:45:36 +02:00
|
|
|
rop_mask = fg;
|
|
|
|
else
|
|
|
|
rop_mask = bg;
|
|
|
|
|
|
|
|
if(x & 1)
|
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits[mask_offset] |= (rop_mask->and & 0x0f);
|
|
|
|
xor_bits[mask_offset] |= (rop_mask->xor & 0x0f);
|
2011-06-17 13:45:36 +02:00
|
|
|
mask_offset++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
and_bits[mask_offset] = (rop_mask->and << 4) & 0xf0;
|
|
|
|
xor_bits[mask_offset] = (rop_mask->xor << 4) & 0xf0;
|
|
|
|
}
|
|
|
|
}
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits += dib->stride;
|
|
|
|
xor_bits += dib->stride;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
static void create_rop_masks_1(const dib_info *dib, const BYTE *hatch_ptr,
|
|
|
|
const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
BYTE *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
rop_mask rop_mask;
|
2012-05-23 11:24:18 +02:00
|
|
|
int x, y;
|
2011-06-17 13:45:36 +02:00
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
for(y = 0; y < 8; y++, hatch_ptr++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
*and_bits = *xor_bits = 0;
|
|
|
|
for(x = 0; x < 8; x++)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
2012-05-23 11:24:18 +02:00
|
|
|
if(*hatch_ptr & pixel_masks_1[x])
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
rop_mask.and = (fg->and & 1) ? 0xff : 0;
|
|
|
|
rop_mask.xor = (fg->xor & 1) ? 0xff : 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rop_mask.and = (bg->and & 1) ? 0xff : 0;
|
|
|
|
rop_mask.xor = (bg->xor & 1) ? 0xff : 0;
|
|
|
|
}
|
2012-05-23 11:24:18 +02:00
|
|
|
*and_bits |= (rop_mask.and & pixel_masks_1[x]);
|
|
|
|
*xor_bits |= (rop_mask.xor & pixel_masks_1[x]);
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
2012-05-23 11:24:18 +02:00
|
|
|
and_bits += dib->stride;
|
|
|
|
xor_bits += dib->stride;
|
2011-06-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 11:24:18 +02:00
|
|
|
static void create_rop_masks_null(const dib_info *dib, const BYTE *hatch_ptr,
|
|
|
|
const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits)
|
2011-06-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-23 11:14:16 +02:00
|
|
|
static void create_dither_masks_8(const dib_info *dib, int rop2, COLORREF color, rop_mask_bits *bits)
|
|
|
|
{
|
|
|
|
/* mapping between RGB triples and the default color table */
|
|
|
|
static const BYTE mapping[27] =
|
|
|
|
{
|
|
|
|
0, /* 000000 -> 000000 */
|
|
|
|
4, /* 00007f -> 000080 */
|
|
|
|
252, /* 0000ff -> 0000ff */
|
|
|
|
2, /* 007f00 -> 008000 */
|
|
|
|
6, /* 007f7f -> 008080 */
|
|
|
|
224, /* 007fff -> 0080c0 */
|
|
|
|
250, /* 00ff00 -> 00ff00 */
|
|
|
|
184, /* 00ff7f -> 00e080 */
|
|
|
|
254, /* 00ffff -> 00ffff */
|
|
|
|
1, /* 7f0000 -> 800000 */
|
|
|
|
5, /* 7f007f -> 800080 */
|
|
|
|
196, /* 7f00ff -> 8000c0 */
|
|
|
|
3, /* 7f7f00 -> 808000 */
|
|
|
|
248, /* 7f7f7f -> 808080 */
|
|
|
|
228, /* 7f7fff -> 8080c0 */
|
|
|
|
60, /* 7fff00 -> 80e000 */
|
|
|
|
188, /* 7fff7f -> 80e080 */
|
|
|
|
244, /* 7fffff -> 80c0c0 */
|
|
|
|
249, /* ff0000 -> ff0000 */
|
|
|
|
135, /* ff007f -> e00080 */
|
|
|
|
253, /* ff00ff -> ff00ff */
|
|
|
|
39, /* ff7f00 -> e08000 */
|
|
|
|
167, /* ff7f7f -> e08080 */
|
|
|
|
231, /* ff7fff -> e080c0 */
|
|
|
|
251, /* ffff00 -> ffff00 */
|
|
|
|
191, /* ffff7f -> e0e080 */
|
|
|
|
255 /* ffffff -> ffffff */
|
|
|
|
};
|
|
|
|
|
|
|
|
BYTE *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
struct rop_codes codes;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
for (y = 0; y < 8; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 8; x++)
|
|
|
|
{
|
|
|
|
DWORD r = ((GetRValue(color) + 1) / 2 + bayer_8x8[y][x]) / 64;
|
|
|
|
DWORD g = ((GetGValue(color) + 1) / 2 + bayer_8x8[y][x]) / 64;
|
|
|
|
DWORD b = ((GetBValue(color) + 1) / 2 + bayer_8x8[y][x]) / 64;
|
|
|
|
DWORD pixel = mapping[r * 9 + g * 3 + b];
|
|
|
|
and_bits[x] = (pixel & codes.a1) ^ codes.a2;
|
|
|
|
xor_bits[x] = (pixel & codes.x1) ^ codes.x2;
|
|
|
|
}
|
|
|
|
and_bits += dib->stride;
|
|
|
|
xor_bits += dib->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_dither_masks_4(const dib_info *dib, int rop2, COLORREF color, rop_mask_bits *bits)
|
|
|
|
{
|
|
|
|
/* mapping between RGB triples and the default color table */
|
|
|
|
static const BYTE mapping[27] =
|
|
|
|
{
|
|
|
|
0, /* 000000 -> 000000 */
|
|
|
|
4, /* 00007f -> 000080 */
|
|
|
|
12, /* 0000ff -> 0000ff */
|
|
|
|
2, /* 007f00 -> 008000 */
|
|
|
|
6, /* 007f7f -> 008080 */
|
|
|
|
6, /* 007fff -> 008080 */
|
|
|
|
10, /* 00ff00 -> 00ff00 */
|
|
|
|
6, /* 00ff7f -> 008080 */
|
|
|
|
14, /* 00ffff -> 00ffff */
|
|
|
|
1, /* 7f0000 -> 800000 */
|
|
|
|
5, /* 7f007f -> 800080 */
|
|
|
|
5, /* 7f00ff -> 800080 */
|
|
|
|
3, /* 7f7f00 -> 808000 */
|
|
|
|
7, /* 7f7f7f -> 808080 */
|
|
|
|
8, /* 7f7fff -> c0c0c0 */
|
|
|
|
3, /* 7fff00 -> 808000 */
|
|
|
|
8, /* 7fff7f -> c0c0c0 */
|
|
|
|
8, /* 7fffff -> c0c0c0 */
|
|
|
|
9, /* ff0000 -> ff0000 */
|
|
|
|
5, /* ff007f -> 800080 */
|
|
|
|
13, /* ff00ff -> ff00ff */
|
|
|
|
3, /* ff7f00 -> 808000 */
|
|
|
|
8, /* ff7f7f -> c0c0c0 */
|
|
|
|
8, /* ff7fff -> c0c0c0 */
|
|
|
|
11, /* ffff00 -> ffff00 */
|
|
|
|
8, /* ffff7f -> c0c0c0 */
|
|
|
|
15 /* ffffff -> ffffff */
|
|
|
|
};
|
|
|
|
|
|
|
|
BYTE *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
struct rop_codes codes;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
for (y = 0; y < 8; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 8; x++)
|
|
|
|
{
|
|
|
|
DWORD r = ((GetRValue(color) + 1) / 2 + bayer_8x8[y][x]) / 64;
|
|
|
|
DWORD g = ((GetGValue(color) + 1) / 2 + bayer_8x8[y][x]) / 64;
|
|
|
|
DWORD b = ((GetBValue(color) + 1) / 2 + bayer_8x8[y][x]) / 64;
|
|
|
|
DWORD pixel = mapping[r * 9 + g * 3 + b];
|
|
|
|
if (x & 1)
|
|
|
|
{
|
|
|
|
and_bits[x / 2] |= (pixel & codes.a1) ^ codes.a2;
|
|
|
|
xor_bits[x / 2] |= (pixel & codes.x1) ^ codes.x2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
and_bits[x / 2] = ((pixel & codes.a1) ^ codes.a2) << 4;
|
|
|
|
xor_bits[x / 2] = ((pixel & codes.x1) ^ codes.x2) << 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
and_bits += dib->stride;
|
|
|
|
xor_bits += dib->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_dither_masks_1(const dib_info *dib, int rop2, COLORREF color, rop_mask_bits *bits)
|
|
|
|
{
|
|
|
|
BYTE *and_bits = bits->and, *xor_bits = bits->xor;
|
|
|
|
struct rop_codes codes;
|
|
|
|
rop_mask rop_mask;
|
|
|
|
int x, y, grey = (30 * GetRValue(color) + 59 * GetGValue(color) + 11 * GetBValue(color) + 200) / 400;
|
|
|
|
|
|
|
|
/* masks are always 8x8 */
|
|
|
|
assert( dib->width == 8 );
|
|
|
|
assert( dib->height == 8 );
|
|
|
|
|
|
|
|
get_rop_codes( rop2, &codes );
|
|
|
|
|
|
|
|
for (y = 0; y < 8; y++)
|
|
|
|
{
|
|
|
|
*and_bits = *xor_bits = 0;
|
|
|
|
for (x = 0; x < 8; x++)
|
|
|
|
{
|
|
|
|
if (grey + bayer_8x8[y][x] > 63)
|
|
|
|
{
|
|
|
|
rop_mask.and = (0xff & codes.a1) ^ codes.a2;
|
|
|
|
rop_mask.xor = (0xff & codes.x1) ^ codes.x2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rop_mask.and = (0x00 & codes.a1) ^ codes.a2;
|
|
|
|
rop_mask.xor = (0x00 & codes.x1) ^ codes.x2;
|
|
|
|
}
|
|
|
|
*and_bits |= (rop_mask.and & pixel_masks_1[x]);
|
|
|
|
*xor_bits |= (rop_mask.xor & pixel_masks_1[x]);
|
|
|
|
}
|
|
|
|
and_bits += dib->stride;
|
|
|
|
xor_bits += dib->stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_dither_masks_null(const dib_info *dib, int rop2, COLORREF color, rop_mask_bits *bits)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-27 17:13:38 +02:00
|
|
|
static inline void rop_codes_from_stretch_mode( int mode, struct rop_codes *codes )
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case STRETCH_DELETESCANS:
|
|
|
|
get_rop_codes( R2_COPYPEN, codes );
|
|
|
|
break;
|
|
|
|
case STRETCH_ORSCANS:
|
|
|
|
get_rop_codes( R2_MERGEPEN, codes );
|
|
|
|
break;
|
|
|
|
case STRETCH_ANDSCANS:
|
|
|
|
get_rop_codes( R2_MASKPEN, codes );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stretch_row_32(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
DWORD *dst_ptr = get_pixel_ptr_32( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
|
|
|
int width;
|
|
|
|
|
2012-12-03 17:48:16 +01:00
|
|
|
if (mode == STRETCH_DELETESCANS || !keep_dst)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:32:59 +01:00
|
|
|
for (width = params->length; width; width--)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:32:59 +01:00
|
|
|
*dst_ptr = *src_ptr;
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
do_rop_codes_32( dst_ptr, *src_ptr, &codes );
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
2011-09-27 17:13:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stretch_row_24(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_24( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
BYTE *src_ptr = get_pixel_ptr_24( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
|
|
|
int width;
|
|
|
|
|
2012-12-03 17:48:16 +01:00
|
|
|
if (mode == STRETCH_DELETESCANS || !keep_dst)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:32:59 +01:00
|
|
|
for (width = params->length; width; width--)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:32:59 +01:00
|
|
|
dst_ptr[0] = src_ptr[0];
|
|
|
|
dst_ptr[1] = src_ptr[1];
|
|
|
|
dst_ptr[2] = src_ptr[2];
|
|
|
|
dst_ptr += 3 * params->dst_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
src_ptr += 3 * params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
do_rop_codes_8( dst_ptr, *src_ptr, &codes );
|
|
|
|
do_rop_codes_8( dst_ptr + 1, *(src_ptr + 1), &codes );
|
|
|
|
do_rop_codes_8( dst_ptr + 2, *(src_ptr + 2), &codes );
|
|
|
|
dst_ptr += 3 * params->dst_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
src_ptr += 3 * params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
2011-09-27 17:13:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stretch_row_16(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
WORD *dst_ptr = get_pixel_ptr_16( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
WORD *src_ptr = get_pixel_ptr_16( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
|
|
|
int width;
|
|
|
|
|
2012-12-03 17:48:16 +01:00
|
|
|
if (mode == STRETCH_DELETESCANS || !keep_dst)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:32:59 +01:00
|
|
|
for (width = params->length; width; width--)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:32:59 +01:00
|
|
|
*dst_ptr = *src_ptr;
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
do_rop_codes_16( dst_ptr, *src_ptr, &codes );
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
2011-09-27 17:13:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stretch_row_8(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_8( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
BYTE *src_ptr = get_pixel_ptr_8( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
|
|
|
int width;
|
|
|
|
|
2012-12-03 17:48:16 +01:00
|
|
|
if (mode == STRETCH_DELETESCANS || !keep_dst)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:32:59 +01:00
|
|
|
for (width = params->length; width; width--)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:32:59 +01:00
|
|
|
*dst_ptr = *src_ptr;
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct rop_codes codes;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
do_rop_codes_8( dst_ptr, *src_ptr, &codes );
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
2011-09-27 17:13:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stretch_row_4(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_4( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
BYTE *src_ptr = get_pixel_ptr_4( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
int width, dst_x = dst_dib->rect.left + dst_start->x, src_x = src_dib->rect.left + src_start->x;
|
2011-09-27 17:13:38 +02:00
|
|
|
struct rop_codes codes;
|
|
|
|
BYTE src_val;
|
|
|
|
|
2012-12-03 17:48:16 +01:00
|
|
|
if (!keep_dst) mode = STRETCH_DELETESCANS;
|
2011-09-27 17:13:38 +02:00
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
if (src_x & 1) src_val = (*src_ptr & 0x0f) | (*src_ptr << 4);
|
|
|
|
else src_val = (*src_ptr & 0xf0) | (*src_ptr >> 4);
|
|
|
|
|
|
|
|
do_rop_codes_mask_8( dst_ptr, src_val, &codes, (dst_x & 1) ? 0x0f : 0xf0 );
|
|
|
|
|
|
|
|
if ((dst_x & ~1) != ((dst_x + params->dst_inc) & ~1))
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
dst_x += params->dst_inc;
|
|
|
|
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
if ((src_x & ~1) != ((src_x + params->src_inc) & ~1))
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
src_x += params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stretch_row_1(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_1( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
BYTE *src_ptr = get_pixel_ptr_1( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
int width, dst_x = dst_dib->rect.left + dst_start->x, src_x = src_dib->rect.left + src_start->x;
|
2011-09-27 17:13:38 +02:00
|
|
|
struct rop_codes codes;
|
|
|
|
BYTE src_val;
|
|
|
|
|
2012-12-03 17:48:16 +01:00
|
|
|
if (!keep_dst) mode = STRETCH_DELETESCANS;
|
2011-09-27 17:13:38 +02:00
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
src_val = *src_ptr & pixel_masks_1[src_x % 8] ? 0xff : 0;
|
|
|
|
do_rop_codes_mask_8( dst_ptr, src_val, &codes, pixel_masks_1[dst_x % 8] );
|
|
|
|
|
|
|
|
if ((dst_x & ~7) != ((dst_x + params->dst_inc) & ~7))
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
dst_x += params->dst_inc;
|
|
|
|
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
if ((src_x & ~7) != ((src_x + params->src_inc) & ~7))
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
src_x += params->src_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stretch_row_null(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
FIXME("bit count %d\n", dst_dib->bit_count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shrink_row_32(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
DWORD *dst_ptr = get_pixel_ptr_32( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
DWORD *src_ptr = get_pixel_ptr_32( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
|
|
|
int width;
|
|
|
|
|
2012-12-03 17:35:56 +01:00
|
|
|
if (mode == STRETCH_DELETESCANS)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:35:56 +01:00
|
|
|
for (width = params->length; width; width--)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:35:56 +01:00
|
|
|
*dst_ptr = *src_ptr;
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct rop_codes codes;
|
|
|
|
DWORD init_val = (mode == STRETCH_ANDSCANS) ? ~0u : 0u;
|
|
|
|
BOOL new_pix = TRUE;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
if (new_pix && !keep_dst) *dst_ptr = init_val;
|
|
|
|
do_rop_codes_32( dst_ptr, *src_ptr, &codes );
|
|
|
|
new_pix = FALSE;
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
new_pix = TRUE;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
2011-09-27 17:13:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shrink_row_24(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_24( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
BYTE *src_ptr = get_pixel_ptr_24( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
|
|
|
int width;
|
|
|
|
|
2012-12-03 17:35:56 +01:00
|
|
|
if (mode == STRETCH_DELETESCANS)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:35:56 +01:00
|
|
|
for (width = params->length; width; width--)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:35:56 +01:00
|
|
|
dst_ptr[0] = src_ptr[0];
|
|
|
|
dst_ptr[1] = src_ptr[1];
|
|
|
|
dst_ptr[2] = src_ptr[2];
|
|
|
|
src_ptr += 3 * params->src_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
dst_ptr += 3 * params->dst_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct rop_codes codes;
|
2015-03-04 07:43:14 +01:00
|
|
|
BYTE init_val = (mode == STRETCH_ANDSCANS) ? 0xff : 0;
|
2012-12-03 17:35:56 +01:00
|
|
|
BOOL new_pix = TRUE;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
if (new_pix && !keep_dst) memset( dst_ptr, init_val, 3 );
|
|
|
|
do_rop_codes_8( dst_ptr, *src_ptr, &codes );
|
|
|
|
do_rop_codes_8( dst_ptr + 1, *(src_ptr + 1), &codes );
|
|
|
|
do_rop_codes_8( dst_ptr + 2, *(src_ptr + 2), &codes );
|
|
|
|
new_pix = FALSE;
|
|
|
|
src_ptr += 3 * params->src_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
dst_ptr += 3 * params->dst_inc;
|
|
|
|
new_pix = TRUE;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
2011-09-27 17:13:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shrink_row_16(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
WORD *dst_ptr = get_pixel_ptr_16( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
WORD *src_ptr = get_pixel_ptr_16( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
|
|
|
int width;
|
|
|
|
|
2012-12-03 17:35:56 +01:00
|
|
|
if (mode == STRETCH_DELETESCANS)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:35:56 +01:00
|
|
|
for (width = params->length; width; width--)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:35:56 +01:00
|
|
|
*dst_ptr = *src_ptr;
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct rop_codes codes;
|
2015-03-04 07:43:14 +01:00
|
|
|
WORD init_val = (mode == STRETCH_ANDSCANS) ? 0xffff : 0;
|
2012-12-03 17:35:56 +01:00
|
|
|
BOOL new_pix = TRUE;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
if (new_pix && !keep_dst) *dst_ptr = init_val;
|
|
|
|
do_rop_codes_16( dst_ptr, *src_ptr, &codes );
|
|
|
|
new_pix = FALSE;
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
new_pix = TRUE;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
2011-09-27 17:13:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shrink_row_8(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_8( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
BYTE *src_ptr = get_pixel_ptr_8( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
|
|
|
int width;
|
|
|
|
|
2012-12-03 17:35:56 +01:00
|
|
|
if (mode == STRETCH_DELETESCANS)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:35:56 +01:00
|
|
|
for (width = params->length; width; width--)
|
2011-09-27 17:13:38 +02:00
|
|
|
{
|
2012-12-03 17:35:56 +01:00
|
|
|
*dst_ptr = *src_ptr;
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct rop_codes codes;
|
2015-03-04 07:43:14 +01:00
|
|
|
BYTE init_val = (mode == STRETCH_ANDSCANS) ? 0xff : 0;
|
2012-12-03 17:35:56 +01:00
|
|
|
BOOL new_pix = TRUE;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
if (new_pix && !keep_dst) *dst_ptr = init_val;
|
|
|
|
do_rop_codes_8( dst_ptr, *src_ptr, &codes );
|
|
|
|
new_pix = FALSE;
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
new_pix = TRUE;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
2011-09-27 17:13:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shrink_row_4(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
2012-04-23 14:58:12 +02:00
|
|
|
BYTE *dst_ptr = get_pixel_ptr_4( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
BYTE *src_ptr = get_pixel_ptr_4( src_dib, src_start->x, src_start->y );
|
2011-09-27 17:13:38 +02:00
|
|
|
int err = params->err_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
int width, dst_x = dst_dib->rect.left + dst_start->x, src_x = src_dib->rect.left + src_start->x;
|
2011-09-27 17:13:38 +02:00
|
|
|
struct rop_codes codes;
|
2015-03-04 07:43:14 +01:00
|
|
|
BYTE src_val, init_val = (mode == STRETCH_ANDSCANS) ? 0xff : 0;
|
2011-09-27 17:13:38 +02:00
|
|
|
BOOL new_pix = TRUE;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
2012-04-23 14:58:12 +02:00
|
|
|
if (new_pix && !keep_dst) do_rop_mask_8( dst_ptr, 0, init_val, (dst_x & 1) ? 0x0f : 0xf0 );
|
2011-09-27 17:13:38 +02:00
|
|
|
|
|
|
|
if (src_x & 1) src_val = (*src_ptr & 0x0f) | (*src_ptr << 4);
|
|
|
|
else src_val = (*src_ptr & 0xf0) | (*src_ptr >> 4);
|
|
|
|
|
2012-04-23 14:58:12 +02:00
|
|
|
do_rop_codes_mask_8( dst_ptr, src_val, &codes, (dst_x & 1) ? 0x0f : 0xf0 );
|
2011-09-27 17:13:38 +02:00
|
|
|
new_pix = FALSE;
|
|
|
|
|
|
|
|
if ((src_x & ~1) != ((src_x + params->src_inc) & ~1))
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
src_x += params->src_inc;
|
|
|
|
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
if ((dst_x & ~1) != ((dst_x + params->dst_inc) & ~1))
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
dst_x += params->dst_inc;
|
|
|
|
new_pix = TRUE;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shrink_row_1(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
BYTE *dst_ptr = get_pixel_ptr_1( dst_dib, dst_start->x, dst_start->y );
|
|
|
|
BYTE *src_ptr = get_pixel_ptr_1( src_dib, src_start->x, src_start->y );
|
|
|
|
int err = params->err_start;
|
2012-04-27 14:44:53 +02:00
|
|
|
int width, dst_x = dst_dib->rect.left + dst_start->x, src_x = src_dib->rect.left + src_start->x;
|
2011-09-27 17:13:38 +02:00
|
|
|
struct rop_codes codes;
|
2015-03-04 07:43:14 +01:00
|
|
|
BYTE src_val, init_val = (mode == STRETCH_ANDSCANS) ? 0xff : 0;
|
2011-09-27 17:13:38 +02:00
|
|
|
BOOL new_pix = TRUE;
|
|
|
|
|
|
|
|
rop_codes_from_stretch_mode( mode, &codes );
|
|
|
|
for (width = params->length; width; width--)
|
|
|
|
{
|
|
|
|
if (new_pix && !keep_dst) do_rop_mask_8( dst_ptr, 0, init_val, pixel_masks_1[dst_x % 8] );
|
|
|
|
src_val = *src_ptr & pixel_masks_1[src_x % 8] ? 0xff : 0;
|
|
|
|
do_rop_codes_mask_8( dst_ptr, src_val, &codes, pixel_masks_1[dst_x % 8] );
|
|
|
|
new_pix = FALSE;
|
|
|
|
|
|
|
|
if ((src_x & ~7) != ((src_x + params->src_inc) & ~7))
|
|
|
|
src_ptr += params->src_inc;
|
|
|
|
src_x += params->src_inc;
|
|
|
|
|
|
|
|
if (err > 0)
|
|
|
|
{
|
|
|
|
if ((dst_x & ~7) != ((dst_x + params->dst_inc) & ~7))
|
|
|
|
dst_ptr += params->dst_inc;
|
|
|
|
dst_x += params->dst_inc;
|
|
|
|
new_pix = TRUE;
|
|
|
|
err += params->err_add_1;
|
|
|
|
}
|
|
|
|
else err += params->err_add_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shrink_row_null(const dib_info *dst_dib, const POINT *dst_start,
|
|
|
|
const dib_info *src_dib, const POINT *src_start,
|
|
|
|
const struct stretch_params *params, int mode,
|
|
|
|
BOOL keep_dst)
|
|
|
|
{
|
|
|
|
FIXME("bit count %d\n", dst_dib->bit_count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-05 14:23:20 +02:00
|
|
|
const primitive_funcs funcs_8888 =
|
|
|
|
{
|
2011-04-07 14:46:11 +02:00
|
|
|
solid_rects_32,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_32,
|
2011-05-12 13:46:50 +02:00
|
|
|
pattern_rects_32,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_32,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_8888,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_8888,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_32,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_8888,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_8888,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_32,
|
2011-05-27 14:41:32 +02:00
|
|
|
colorref_to_pixel_888,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_888,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_8888,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_32,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_null,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_32,
|
|
|
|
shrink_row_32
|
2011-04-05 14:23:20 +02:00
|
|
|
};
|
|
|
|
|
2011-04-05 14:26:08 +02:00
|
|
|
const primitive_funcs funcs_32 =
|
|
|
|
{
|
2011-04-07 14:46:11 +02:00
|
|
|
solid_rects_32,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_32,
|
2011-05-12 13:46:50 +02:00
|
|
|
pattern_rects_32,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_32,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_32,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_32,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_32,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_32,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_32,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_32,
|
2011-05-27 14:41:32 +02:00
|
|
|
colorref_to_pixel_masks,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_masks,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_32,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_32,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_null,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_32,
|
|
|
|
shrink_row_32
|
2011-04-05 14:26:08 +02:00
|
|
|
};
|
|
|
|
|
2011-06-01 10:41:39 +02:00
|
|
|
const primitive_funcs funcs_24 =
|
|
|
|
{
|
|
|
|
solid_rects_24,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_24,
|
2011-06-01 10:41:39 +02:00
|
|
|
pattern_rects_24,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_24,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_24,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_24,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_24,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_24,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_24,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_24,
|
2011-06-01 10:41:39 +02:00
|
|
|
colorref_to_pixel_888,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_888,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_24,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_24,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_null,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_24,
|
|
|
|
shrink_row_24
|
2011-06-01 10:41:39 +02:00
|
|
|
};
|
|
|
|
|
2011-05-27 14:10:29 +02:00
|
|
|
const primitive_funcs funcs_555 =
|
|
|
|
{
|
|
|
|
solid_rects_16,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_16,
|
2011-05-27 14:10:29 +02:00
|
|
|
pattern_rects_16,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_16,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_555,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_555,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_16,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_555,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_555,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_16,
|
2011-05-27 14:41:32 +02:00
|
|
|
colorref_to_pixel_555,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_555,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_555,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_16,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_null,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_16,
|
|
|
|
shrink_row_16
|
2011-05-27 14:10:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const primitive_funcs funcs_16 =
|
|
|
|
{
|
|
|
|
solid_rects_16,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_16,
|
2011-05-27 14:10:29 +02:00
|
|
|
pattern_rects_16,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_16,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_16,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_16,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_16,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_16,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_16,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_16,
|
2011-05-27 14:41:32 +02:00
|
|
|
colorref_to_pixel_masks,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_masks,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_16,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_16,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_null,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_16,
|
|
|
|
shrink_row_16
|
2011-05-27 14:10:29 +02:00
|
|
|
};
|
|
|
|
|
2011-05-27 15:26:02 +02:00
|
|
|
const primitive_funcs funcs_8 =
|
|
|
|
{
|
|
|
|
solid_rects_8,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_8,
|
2011-05-27 15:26:02 +02:00
|
|
|
pattern_rects_8,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_8,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_8,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_8,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_8,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_8,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_null,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_8,
|
2011-05-27 15:26:02 +02:00
|
|
|
colorref_to_pixel_colortable,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_colortable,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_8,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_8,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_8,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_8,
|
|
|
|
shrink_row_8
|
2011-05-27 15:26:02 +02:00
|
|
|
};
|
|
|
|
|
2011-05-31 11:02:03 +02:00
|
|
|
const primitive_funcs funcs_4 =
|
|
|
|
{
|
|
|
|
solid_rects_4,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_4,
|
2011-05-31 11:02:03 +02:00
|
|
|
pattern_rects_4,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_4,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_4,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_4,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_4,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_4,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_null,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_4,
|
2011-05-31 11:02:03 +02:00
|
|
|
colorref_to_pixel_colortable,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_colortable,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_4,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_4,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_4,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_4,
|
|
|
|
shrink_row_4
|
2011-05-31 11:02:03 +02:00
|
|
|
};
|
|
|
|
|
2011-06-15 14:43:49 +02:00
|
|
|
const primitive_funcs funcs_1 =
|
|
|
|
{
|
|
|
|
solid_rects_1,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_1,
|
2011-06-15 14:43:49 +02:00
|
|
|
pattern_rects_1,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_1,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_1,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_1,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_null,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_1,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_null,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_1,
|
2011-06-15 14:43:49 +02:00
|
|
|
colorref_to_pixel_colortable,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_colortable,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_1,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_1,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_1,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_1,
|
|
|
|
shrink_row_1
|
2011-06-15 14:43:49 +02:00
|
|
|
};
|
|
|
|
|
2011-04-05 14:23:20 +02:00
|
|
|
const primitive_funcs funcs_null =
|
|
|
|
{
|
2011-04-07 14:46:11 +02:00
|
|
|
solid_rects_null,
|
2011-11-21 11:12:52 +01:00
|
|
|
solid_line_null,
|
2011-05-12 13:46:50 +02:00
|
|
|
pattern_rects_null,
|
2011-08-02 15:11:08 +02:00
|
|
|
copy_rect_null,
|
2011-10-14 12:30:28 +02:00
|
|
|
blend_rect_null,
|
2011-11-28 13:21:52 +01:00
|
|
|
gradient_rect_null,
|
2016-07-13 11:02:28 +02:00
|
|
|
mask_rect_null,
|
2011-11-14 13:49:06 +01:00
|
|
|
draw_glyph_null,
|
2012-10-30 14:22:16 +01:00
|
|
|
draw_subpixel_glyph_null,
|
2011-10-19 13:41:57 +02:00
|
|
|
get_pixel_null,
|
2011-05-27 14:41:32 +02:00
|
|
|
colorref_to_pixel_null,
|
2011-10-19 13:41:54 +02:00
|
|
|
pixel_to_colorref_null,
|
2011-06-17 13:45:36 +02:00
|
|
|
convert_to_null,
|
2011-09-27 17:13:38 +02:00
|
|
|
create_rop_masks_null,
|
2012-05-23 11:14:16 +02:00
|
|
|
create_dither_masks_null,
|
2011-09-27 17:13:38 +02:00
|
|
|
stretch_row_null,
|
|
|
|
shrink_row_null
|
2011-04-05 14:23:20 +02:00
|
|
|
};
|