2011-07-01 05:23:36 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-09-14 00:30:16 +04:00
|
|
|
* Color Conversion Routines
|
2011-07-01 05:23:36 +04:00
|
|
|
*
|
|
|
|
* Copyright 2010 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
2012-11-22 05:21:08 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2011-12-30 19:00:03 +04:00
|
|
|
#include <freerdp/api.h>
|
2011-07-01 05:23:36 +04:00
|
|
|
#include <freerdp/freerdp.h>
|
2014-07-03 00:30:04 +04:00
|
|
|
#include <freerdp/primitives.h>
|
2011-10-03 04:28:20 +04:00
|
|
|
#include <freerdp/codec/color.h>
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2012-11-22 06:22:06 +04:00
|
|
|
int freerdp_get_pixel(BYTE* data, int x, int y, int width, int height, int bpp)
|
2011-09-29 08:33:16 +04:00
|
|
|
{
|
|
|
|
int start;
|
|
|
|
int shift;
|
2012-11-22 06:22:06 +04:00
|
|
|
UINT16* src16;
|
|
|
|
UINT32* src32;
|
2011-09-29 08:33:16 +04:00
|
|
|
int red, green, blue;
|
|
|
|
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
width = (width + 7) / 8;
|
|
|
|
start = (y * width) + x / 8;
|
|
|
|
shift = x % 8;
|
|
|
|
return (data[start] & (0x80 >> shift)) != 0;
|
|
|
|
case 8:
|
|
|
|
return data[y * width + x];
|
|
|
|
case 15:
|
|
|
|
case 16:
|
2012-10-09 11:01:37 +04:00
|
|
|
src16 = (UINT16*) data;
|
2011-09-29 08:33:16 +04:00
|
|
|
return src16[y * width + x];
|
|
|
|
case 24:
|
|
|
|
data += y * width * 3;
|
|
|
|
data += x * 3;
|
|
|
|
red = data[0];
|
|
|
|
green = data[1];
|
|
|
|
blue = data[2];
|
|
|
|
return RGB24(red, green, blue);
|
|
|
|
case 32:
|
2012-10-09 11:26:39 +04:00
|
|
|
src32 = (UINT32*) data;
|
2011-09-29 08:33:16 +04:00
|
|
|
return src32[y * width + x];
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
void freerdp_set_pixel(BYTE* data, int x, int y, int width, int height, int bpp, int pixel)
|
2011-09-29 08:33:16 +04:00
|
|
|
{
|
|
|
|
int start;
|
|
|
|
int shift;
|
|
|
|
int *dst32;
|
|
|
|
|
|
|
|
if (bpp == 1)
|
|
|
|
{
|
|
|
|
width = (width + 7) / 8;
|
|
|
|
start = (y * width) + x / 8;
|
|
|
|
shift = x % 8;
|
|
|
|
if (pixel)
|
|
|
|
data[start] = data[start] | (0x80 >> shift);
|
|
|
|
else
|
|
|
|
data[start] = data[start] & ~(0x80 >> shift);
|
|
|
|
}
|
|
|
|
else if (bpp == 32)
|
|
|
|
{
|
|
|
|
dst32 = (int*) data;
|
|
|
|
dst32[y * width + x] = pixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
static INLINE void freerdp_color_split_rgb(UINT32* color, int bpp, BYTE* red, BYTE* green, BYTE* blue, BYTE* alpha, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
*red = *green = *blue = 0;
|
2012-01-16 20:40:18 +04:00
|
|
|
*alpha = (clrconv->alpha) ? 0xFF : 0x00;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2011-12-30 19:00:03 +04:00
|
|
|
switch (bpp)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
if (clrconv->alpha)
|
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
GetARGB32(*alpha, *red, *green, *blue, *color);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
GetRGB32(*red, *green, *blue, *color);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 24:
|
2011-12-30 19:00:03 +04:00
|
|
|
GetRGB24(*red, *green, *blue, *color);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 16:
|
2011-12-30 19:00:03 +04:00
|
|
|
GetRGB16(*red, *green, *blue, *color);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 15:
|
2011-12-30 19:00:03 +04:00
|
|
|
GetRGB15(*red, *green, *blue, *color);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 8:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color &= 0xFF;
|
|
|
|
*red = clrconv->palette->entries[*color].red;
|
|
|
|
*green = clrconv->palette->entries[*color].green;
|
|
|
|
*blue = clrconv->palette->entries[*color].blue;
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 1:
|
2011-12-30 19:00:03 +04:00
|
|
|
if (*color != 0)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
*red = 0xFF;
|
|
|
|
*green = 0xFF;
|
|
|
|
*blue = 0xFF;
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-12-30 19:00:03 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
static INLINE void freerdp_color_split_bgr(UINT32* color, int bpp, BYTE* red, BYTE* green, BYTE* blue, BYTE* alpha, HCLRCONV clrconv)
|
2011-12-30 19:00:03 +04:00
|
|
|
{
|
|
|
|
*red = *green = *blue = 0;
|
2012-01-16 20:40:18 +04:00
|
|
|
*alpha = (clrconv->alpha) ? 0xFF : 0x00;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
|
|
|
switch (bpp)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
case 32:
|
2011-12-30 19:00:03 +04:00
|
|
|
if (clrconv->alpha)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
GetABGR32(*alpha, *red, *green, *blue, *color);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
GetBGR32(*red, *green, *blue, *color);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
|
|
|
case 24:
|
|
|
|
GetBGR24(*red, *green, *blue, *color);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
GetBGR16(*red, *green, *blue, *color);
|
|
|
|
break;
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 15:
|
2011-12-30 19:00:03 +04:00
|
|
|
GetBGR15(*red, *green, *blue, *color);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 8:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color &= 0xFF;
|
|
|
|
*red = clrconv->palette->entries[*color].red;
|
|
|
|
*green = clrconv->palette->entries[*color].green;
|
|
|
|
*blue = clrconv->palette->entries[*color].blue;
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 1:
|
2011-12-30 19:00:03 +04:00
|
|
|
if (*color != 0)
|
|
|
|
{
|
|
|
|
*red = 0xFF;
|
|
|
|
*green = 0xFF;
|
|
|
|
*blue = 0xFF;
|
|
|
|
}
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
static INLINE void freerdp_color_make_rgb(UINT32* color, int bpp, BYTE* red, BYTE* green, BYTE* blue, BYTE* alpha, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
switch (bpp)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
case 32:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = ARGB32(*alpha, *red, *green, *blue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
*color = RGB24(*red, *green, *blue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
if (clrconv->rgb555)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = RGB15(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = RGB16(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 15:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = RGB15(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 8:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = RGB24(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 1:
|
2011-12-30 19:00:03 +04:00
|
|
|
if ((*red != 0) || (*green != 0) || (*blue != 0))
|
|
|
|
*color = 1;
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-12-30 19:00:03 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
static INLINE void freerdp_color_make_bgr(UINT32* color, int bpp, BYTE* red, BYTE* green, BYTE* blue, BYTE* alpha, HCLRCONV clrconv)
|
2011-12-30 19:00:03 +04:00
|
|
|
{
|
|
|
|
switch (bpp)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
case 32:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = ABGR32(*alpha, *red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 24:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = BGR24(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 16:
|
2011-12-30 19:00:03 +04:00
|
|
|
if (clrconv->rgb555)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = BGR15(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = BGR16(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 15:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = BGR15(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 8:
|
2011-12-30 19:00:03 +04:00
|
|
|
*color = BGR24(*red, *green, *blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
case 1:
|
2011-12-30 19:00:03 +04:00
|
|
|
if ((*red != 0) || (*green != 0) || (*blue != 0))
|
|
|
|
*color = 1;
|
2011-07-01 05:23:36 +04:00
|
|
|
break;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-12-30 19:00:03 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 freerdp_color_convert_rgb(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-12-30 19:00:03 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red = 0;
|
|
|
|
BYTE green = 0;
|
|
|
|
BYTE blue = 0;
|
|
|
|
BYTE alpha = 0xFF;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 dstColor = 0;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
|
|
|
freerdp_color_split_rgb(&srcColor, srcBpp, &red, &green, &blue, &alpha, clrconv);
|
|
|
|
freerdp_color_make_rgb(&dstColor, dstBpp, &red, &green, &blue, &alpha, clrconv);
|
|
|
|
|
|
|
|
return dstColor;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 freerdp_color_convert_bgr(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-12-30 19:00:03 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red = 0;
|
|
|
|
BYTE green = 0;
|
|
|
|
BYTE blue = 0;
|
|
|
|
BYTE alpha = 0xFF;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 dstColor = 0;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
|
|
|
freerdp_color_split_bgr(&srcColor, srcBpp, &red, &green, &blue, &alpha, clrconv);
|
|
|
|
freerdp_color_make_bgr(&dstColor, dstBpp, &red, &green, &blue, &alpha, clrconv);
|
|
|
|
|
|
|
|
return dstColor;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 freerdp_color_convert_rgb_bgr(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-12-30 19:00:03 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red = 0;
|
|
|
|
BYTE green = 0;
|
|
|
|
BYTE blue = 0;
|
|
|
|
BYTE alpha = 0xFF;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 dstColor = 0;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
|
|
|
freerdp_color_split_rgb(&srcColor, srcBpp, &red, &green, &blue, &alpha, clrconv);
|
|
|
|
freerdp_color_make_bgr(&dstColor, dstBpp, &red, &green, &blue, &alpha, clrconv);
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
return dstColor;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 freerdp_color_convert_bgr_rgb(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red = 0;
|
|
|
|
BYTE green = 0;
|
|
|
|
BYTE blue = 0;
|
|
|
|
BYTE alpha = 0xFF;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 dstColor = 0;
|
2011-12-30 19:00:03 +04:00
|
|
|
|
|
|
|
freerdp_color_split_bgr(&srcColor, srcBpp, &red, &green, &blue, &alpha, clrconv);
|
|
|
|
freerdp_color_make_rgb(&dstColor, dstBpp, &red, &green, &blue, &alpha, clrconv);
|
|
|
|
|
|
|
|
return dstColor;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 freerdp_color_convert_var(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2012-01-10 03:45:36 +04:00
|
|
|
{
|
|
|
|
if (clrconv->invert)
|
|
|
|
return freerdp_color_convert_var_bgr(srcColor, srcBpp, dstBpp, clrconv);
|
|
|
|
else
|
|
|
|
return freerdp_color_convert_var_rgb(srcColor, srcBpp, dstBpp, clrconv);
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 freerdp_color_convert_var_rgb(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-12-30 19:00:03 +04:00
|
|
|
{
|
2013-02-04 00:22:16 +04:00
|
|
|
if (srcBpp == 8)
|
|
|
|
{
|
|
|
|
BYTE alpha = 0xFF;
|
|
|
|
UINT32 dstColor = 0;
|
|
|
|
PALETTE_ENTRY* entry = &clrconv->palette->entries[srcColor & 0xFF];
|
|
|
|
|
|
|
|
freerdp_color_make_bgr(&dstColor, dstBpp, &entry->red, &entry->green, &entry->blue, &alpha, clrconv);
|
|
|
|
|
|
|
|
return dstColor;
|
|
|
|
}
|
|
|
|
|
2011-12-30 19:00:03 +04:00
|
|
|
if (srcBpp > 16)
|
2012-05-17 22:55:51 +04:00
|
|
|
return freerdp_color_convert_bgr_rgb(srcColor, srcBpp, dstBpp, clrconv);
|
2011-12-30 19:00:03 +04:00
|
|
|
else
|
2012-03-03 02:49:52 +04:00
|
|
|
return freerdp_color_convert_rgb(srcColor, srcBpp, dstBpp, clrconv);
|
2011-12-30 19:00:03 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 freerdp_color_convert_var_bgr(UINT32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2013-02-04 00:16:37 +04:00
|
|
|
if (srcBpp == 8)
|
|
|
|
{
|
|
|
|
BYTE alpha = 0xFF;
|
|
|
|
UINT32 dstColor = 0;
|
|
|
|
PALETTE_ENTRY* entry = &clrconv->palette->entries[srcColor & 0xFF];
|
|
|
|
|
|
|
|
freerdp_color_make_rgb(&dstColor, dstBpp, &entry->red, &entry->green, &entry->blue, &alpha, clrconv);
|
|
|
|
|
|
|
|
return dstColor;
|
|
|
|
}
|
|
|
|
|
2011-12-30 19:00:03 +04:00
|
|
|
if (srcBpp > 16)
|
2012-05-17 22:55:51 +04:00
|
|
|
return freerdp_color_convert_bgr(srcColor, srcBpp, dstBpp, clrconv);
|
2011-07-01 05:23:36 +04:00
|
|
|
else
|
2012-03-03 02:49:52 +04:00
|
|
|
return freerdp_color_convert_rgb_bgr(srcColor, srcBpp, dstBpp, clrconv);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
UINT32 freerdp_convert_gdi_order_color(UINT32 color, int bpp, UINT32 format, BYTE* palette)
|
2014-08-07 01:58:58 +04:00
|
|
|
{
|
2014-09-18 02:30:09 +04:00
|
|
|
UINT32 r = 0;
|
|
|
|
UINT32 g = 0;
|
|
|
|
UINT32 b = 0;
|
2014-08-07 01:58:58 +04:00
|
|
|
|
|
|
|
switch (bpp)
|
|
|
|
{
|
2014-09-16 00:28:53 +04:00
|
|
|
case 32:
|
|
|
|
GetRGB32(r, g, b, color);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
GetRGB32(r, g, b, color);
|
|
|
|
break;
|
|
|
|
|
2014-08-07 01:58:58 +04:00
|
|
|
case 16:
|
|
|
|
color = (color & (UINT32) 0xFF00) | ((color >> 16) & (UINT32) 0xFF);
|
|
|
|
GetRGB16(r, g, b, color);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
color = (color & (UINT32) 0xFF00) | ((color >> 16) & (UINT32) 0xFF);
|
|
|
|
GetRGB15(r, g, b, color);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
color = (color >> 16) & (UINT32) 0xFF;
|
2014-09-18 02:30:09 +04:00
|
|
|
if (palette)
|
|
|
|
{
|
|
|
|
r = palette[(color * 4) + 2];
|
|
|
|
g = palette[(color * 4) + 1];
|
|
|
|
b = palette[(color * 4) + 0];
|
|
|
|
}
|
2014-08-07 01:58:58 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
r = g = b = 0;
|
|
|
|
if (color != 0)
|
|
|
|
r = g = b = 0xFF;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return color;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-09-16 00:28:53 +04:00
|
|
|
if (FREERDP_PIXEL_FORMAT_TYPE(format) == FREERDP_PIXEL_FORMAT_TYPE_ABGR)
|
|
|
|
return BGR32(r, g, b);
|
|
|
|
|
2014-08-07 01:58:58 +04:00
|
|
|
return RGB32(r, g, b);
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_image_convert_8bpp(BYTE* srcData, BYTE* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
int i;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red;
|
|
|
|
BYTE green;
|
|
|
|
BYTE blue;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 pixel;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE *src8;
|
|
|
|
UINT16 *dst16;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 *dst32;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
if (dstBpp == 8)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
CopyMemory(dstData, srcData, width * height);
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 15 || (dstBpp == 16 && clrconv->rgb555))
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 2, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dst16 = (UINT16*) dstData;
|
2011-12-12 18:49:44 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
for (i = width * height; i > 0; i--)
|
|
|
|
{
|
|
|
|
pixel = *srcData;
|
|
|
|
srcData++;
|
|
|
|
red = clrconv->palette->entries[pixel].red;
|
|
|
|
green = clrconv->palette->entries[pixel].green;
|
|
|
|
blue = clrconv->palette->entries[pixel].blue;
|
2011-12-22 02:58:15 +04:00
|
|
|
pixel = (clrconv->invert) ? BGR15(red, green, blue) : RGB15(red, green, blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
*dst16 = pixel;
|
|
|
|
dst16++;
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 16)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 2, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dst16 = (UINT16*) dstData;
|
2011-12-12 18:49:44 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
for (i = width * height; i > 0; i--)
|
|
|
|
{
|
|
|
|
pixel = *srcData;
|
|
|
|
srcData++;
|
|
|
|
red = clrconv->palette->entries[pixel].red;
|
|
|
|
green = clrconv->palette->entries[pixel].green;
|
|
|
|
blue = clrconv->palette->entries[pixel].blue;
|
2011-12-22 02:58:15 +04:00
|
|
|
pixel = (clrconv->invert) ? BGR16(red, green, blue) : RGB16(red, green, blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
*dst16 = pixel;
|
|
|
|
dst16++;
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 32)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 4, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2011-12-12 18:49:44 +04:00
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
src8 = (BYTE*) srcData;
|
2012-10-09 11:26:39 +04:00
|
|
|
dst32 = (UINT32*) dstData;
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
for (i = width * height; i > 0; i--)
|
|
|
|
{
|
|
|
|
pixel = *src8;
|
|
|
|
src8++;
|
|
|
|
red = clrconv->palette->entries[pixel].red;
|
|
|
|
green = clrconv->palette->entries[pixel].green;
|
|
|
|
blue = clrconv->palette->entries[pixel].blue;
|
2012-10-11 02:07:56 +04:00
|
|
|
if (clrconv->alpha)
|
|
|
|
{
|
2014-08-07 01:58:58 +04:00
|
|
|
pixel = (clrconv->invert) ? ABGR32(0xFF, red, green, blue) : ARGB32(0xFF, red, green, blue);
|
2012-10-11 02:07:56 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-07 01:58:58 +04:00
|
|
|
pixel = (clrconv->invert) ? BGR32(red, green, blue) : RGB32(red, green, blue);
|
2012-10-11 02:07:56 +04:00
|
|
|
}
|
2011-07-01 05:23:36 +04:00
|
|
|
*dst32 = pixel;
|
|
|
|
dst32++;
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return srcData;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_image_convert_15bpp(BYTE* srcData, BYTE* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
int i;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red;
|
|
|
|
BYTE green;
|
|
|
|
BYTE blue;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 pixel;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 *src16;
|
|
|
|
UINT16 *dst16;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 *dst32;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
if (dstBpp == 15 || (dstBpp == 16 && clrconv->rgb555))
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 2, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
CopyMemory(dstData, srcData, width * height * 2);
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 32)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 4, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
src16 = (UINT16*) srcData;
|
|
|
|
dst32 = (UINT32*) dstData;
|
2011-12-12 18:49:44 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
for (i = width * height; i > 0; i--)
|
|
|
|
{
|
|
|
|
pixel = *src16;
|
|
|
|
src16++;
|
2011-10-25 06:12:57 +04:00
|
|
|
GetBGR15(red, green, blue, pixel);
|
2012-10-11 02:07:56 +04:00
|
|
|
if (clrconv->alpha)
|
|
|
|
{
|
|
|
|
pixel = (clrconv->invert) ? ARGB32(0xFF, red, green, blue) : ABGR32(0xFF, red, green, blue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pixel = (clrconv->invert) ? RGB32(red, green, blue) : BGR32(red, green, blue);
|
|
|
|
}
|
2011-07-01 05:23:36 +04:00
|
|
|
*dst32 = pixel;
|
|
|
|
dst32++;
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 16)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 2, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
src16 = (UINT16*) srcData;
|
|
|
|
dst16 = (UINT16*) dstData;
|
2011-12-12 18:49:44 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
for (i = width * height; i > 0; i--)
|
|
|
|
{
|
|
|
|
pixel = *src16;
|
|
|
|
src16++;
|
|
|
|
GetRGB_555(red, green, blue, pixel);
|
|
|
|
RGB_555_565(red, green, blue);
|
2011-12-22 02:58:15 +04:00
|
|
|
pixel = (clrconv->invert) ? BGR565(red, green, blue) : RGB565(red, green, blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
*dst16 = pixel;
|
|
|
|
dst16++;
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return srcData;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_image_convert_16bpp(BYTE* srcData, BYTE* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
if (srcBpp == 15)
|
2011-09-14 03:03:06 +04:00
|
|
|
return freerdp_image_convert_15bpp(srcData, dstData, width, height, srcBpp, dstBpp, clrconv);
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
if (dstBpp == 16)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 2, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2011-12-30 23:23:47 +04:00
|
|
|
if (clrconv->rgb555)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
int i;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red, green, blue;
|
|
|
|
UINT16* src16 = (UINT16 *) srcData;
|
|
|
|
UINT16* dst16 = (UINT16 *) dstData;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
for (i = width * height; i > 0; i--)
|
|
|
|
{
|
|
|
|
GetRGB_565(red, green, blue, (*src16));
|
|
|
|
RGB_565_555(red, green, blue);
|
2011-12-22 02:58:15 +04:00
|
|
|
(*dst16) = (clrconv->invert) ? BGR555(red, green, blue) : RGB555(red, green, blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
src16++;
|
|
|
|
dst16++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
CopyMemory(dstData, srcData, width * height * 2);
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 24)
|
|
|
|
{
|
|
|
|
int i;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE *dst8;
|
|
|
|
UINT16 *src16;
|
|
|
|
BYTE red, green, blue;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 3, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
dst8 = (BYTE*) dstData;
|
|
|
|
src16 = (UINT16*) srcData;
|
2011-12-30 23:23:47 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
for (i = width * height; i > 0; i--)
|
|
|
|
{
|
|
|
|
GetBGR16(red, green, blue, *src16);
|
|
|
|
src16++;
|
|
|
|
|
|
|
|
if (clrconv->invert)
|
|
|
|
{
|
|
|
|
*dst8++ = blue;
|
|
|
|
*dst8++ = green;
|
|
|
|
*dst8++ = red;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*dst8++ = red;
|
|
|
|
*dst8++ = green;
|
|
|
|
*dst8++ = blue;
|
|
|
|
}
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 32)
|
|
|
|
{
|
2014-07-03 00:30:04 +04:00
|
|
|
primitives_t* prims;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2014-07-08 20:18:41 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = _aligned_malloc(width * height * sizeof(UINT32), 16);
|
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2013-05-17 03:56:39 +04:00
|
|
|
|
2014-07-03 00:30:04 +04:00
|
|
|
prims = primitives_get();
|
|
|
|
prims->RGB565ToARGB_16u32u_C3C4(
|
|
|
|
(const UINT16*) srcData, width * sizeof(UINT16),
|
|
|
|
(UINT32*) dstData, width * sizeof(UINT32),
|
|
|
|
width, height, clrconv->alpha, clrconv->invert);
|
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return srcData;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_image_convert_24bpp(BYTE* srcData, BYTE* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (dstBpp == 32)
|
|
|
|
{
|
2014-08-14 01:31:15 +04:00
|
|
|
UINT32 pixel, alpha_mask, temp;
|
|
|
|
UINT32* srcp;
|
|
|
|
UINT32* dstp;
|
2014-07-08 23:07:19 +04:00
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 4, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2011-12-12 18:49:44 +04:00
|
|
|
|
2014-08-14 01:31:15 +04:00
|
|
|
alpha_mask = clrconv->alpha ? 0xFF000000 : 0;
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2014-08-14 01:31:15 +04:00
|
|
|
srcp = (UINT32*) srcData;
|
|
|
|
dstp = (UINT32*) dstData;
|
|
|
|
|
|
|
|
if (clrconv->invert)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2014-08-14 01:31:15 +04:00
|
|
|
/* Each iteration handles four pixels using 32-bit load and
|
|
|
|
store operations. */
|
|
|
|
for (i = ((width * height) / 4); i > 0; i--)
|
|
|
|
{
|
|
|
|
temp = 0;
|
|
|
|
|
|
|
|
pixel = temp;
|
|
|
|
temp = *srcp++;
|
|
|
|
pixel |= temp & 0x00FFFFFF;
|
|
|
|
temp = temp >> 24;
|
|
|
|
*dstp++ = alpha_mask | RGB32_to_BGR32(pixel);
|
|
|
|
|
|
|
|
pixel = temp;
|
|
|
|
temp = *srcp++;
|
|
|
|
pixel |= (temp & 0x0000FFFF) << 8;
|
|
|
|
temp = temp >> 16;
|
|
|
|
*dstp++ = alpha_mask | RGB32_to_BGR32(pixel);
|
|
|
|
|
|
|
|
pixel = temp;
|
|
|
|
temp = *srcp++;
|
|
|
|
pixel |= (temp & 0x000000FF) << 16;
|
|
|
|
temp = temp >> 8;
|
|
|
|
*dstp++ = alpha_mask | RGB32_to_BGR32(pixel);
|
|
|
|
|
|
|
|
*dstp++ = alpha_mask | RGB32_to_BGR32(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle any remainder. */
|
|
|
|
for (i = (width * height) % 4; i > 0; i--)
|
|
|
|
{
|
|
|
|
pixel = ABGR32(alpha_mask, srcData[2], srcData[1], srcData[0]);
|
|
|
|
*dstp++ = pixel;
|
|
|
|
srcData += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = ((width * height) / 4); i > 0; i--)
|
|
|
|
{
|
|
|
|
temp = 0;
|
|
|
|
|
|
|
|
pixel = temp;
|
|
|
|
temp = *srcp++;
|
|
|
|
pixel |= temp & 0x00FFFFFF;
|
|
|
|
temp = temp >> 24;
|
|
|
|
*dstp++ = alpha_mask | pixel;
|
|
|
|
|
|
|
|
pixel = temp;
|
|
|
|
temp = *srcp++;
|
|
|
|
pixel |= (temp & 0x0000FFFF) << 8;
|
|
|
|
temp = temp >> 16;
|
|
|
|
*dstp++ = alpha_mask | pixel;
|
|
|
|
|
|
|
|
pixel = temp;
|
|
|
|
temp = *srcp++;
|
|
|
|
pixel |= (temp & 0x000000FF) << 16;
|
|
|
|
temp = temp >> 8;
|
|
|
|
*dstp++ = alpha_mask | pixel;
|
|
|
|
|
|
|
|
*dstp++ = alpha_mask | temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = (width * height) % 4; i > 0; i--)
|
|
|
|
{
|
|
|
|
pixel = ARGB32(alpha_mask, srcData[2], srcData[1], srcData[0]);
|
|
|
|
*dstp++ = pixel;
|
|
|
|
srcData += 3;
|
|
|
|
}
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return srcData;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_image_convert_32bpp(BYTE* srcData, BYTE* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
if (dstBpp == 16)
|
|
|
|
{
|
|
|
|
int index;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 *dst16;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 *src32;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red, green, blue;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 2, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
dst16 = (UINT16*) dstData;
|
2012-10-09 11:26:39 +04:00
|
|
|
src32 = (UINT32*) srcData;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
|
|
|
for (index = 0; index < width * height; index++)
|
|
|
|
{
|
|
|
|
GetBGR32(blue, green, red, *src32);
|
2011-12-22 02:58:15 +04:00
|
|
|
*dst16 = (clrconv->invert) ? BGR16(red, green, blue) : RGB16(red, green, blue);
|
2011-07-01 05:23:36 +04:00
|
|
|
src32++;
|
|
|
|
dst16++;
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 24)
|
|
|
|
{
|
|
|
|
int index;
|
2014-07-08 23:07:19 +04:00
|
|
|
BYTE* dstp;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE red, green, blue;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 3, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2011-11-24 05:15:14 +04:00
|
|
|
dstp = dstData;
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
for (index = 0; index < width * height; index++)
|
|
|
|
{
|
|
|
|
red = *(srcData++);
|
|
|
|
green = *(srcData++);
|
|
|
|
blue = *(srcData++);
|
|
|
|
|
|
|
|
if (clrconv->invert)
|
|
|
|
{
|
2011-11-24 05:15:14 +04:00
|
|
|
*dstp++ = blue;
|
|
|
|
*dstp++ = green;
|
|
|
|
*dstp++ = red;
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-24 05:15:14 +04:00
|
|
|
*dstp++ = red;
|
|
|
|
*dstp++ = green;
|
|
|
|
*dstp++ = blue;
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
srcData++;
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
else if (dstBpp == 32)
|
|
|
|
{
|
2014-08-07 01:58:58 +04:00
|
|
|
int i;
|
|
|
|
UINT32 pixel;
|
|
|
|
UINT32 alpha_mask;
|
|
|
|
UINT32* srcp;
|
|
|
|
UINT32* dstp;
|
|
|
|
BYTE red, green, blue;
|
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 4, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
2014-08-07 01:58:58 +04:00
|
|
|
alpha_mask = clrconv->alpha ? 0xFF000000 : 0;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2014-08-07 01:58:58 +04:00
|
|
|
srcp = (UINT32*) srcData;
|
|
|
|
dstp = (UINT32*) dstData;
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2014-08-07 01:58:58 +04:00
|
|
|
if (clrconv->invert)
|
|
|
|
{
|
|
|
|
for (i = width * height; i > 0; i--)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2014-08-07 01:58:58 +04:00
|
|
|
pixel = *srcp;
|
|
|
|
srcp++;
|
|
|
|
GetRGB32(red, green, blue, pixel);
|
|
|
|
pixel = alpha_mask | BGR32(red, green, blue);
|
|
|
|
*dstp = pixel;
|
|
|
|
dstp++;
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-07 01:58:58 +04:00
|
|
|
for (i = width * height; i > 0; i--)
|
|
|
|
{
|
|
|
|
pixel = *srcp;
|
|
|
|
srcp++;
|
|
|
|
GetRGB32(red, green, blue, pixel);
|
|
|
|
pixel = alpha_mask | RGB32(red, green, blue);
|
|
|
|
*dstp = pixel;
|
|
|
|
dstp++;
|
|
|
|
}
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
2011-12-12 18:49:44 +04:00
|
|
|
|
2011-07-01 05:23:36 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return srcData;
|
|
|
|
}
|
|
|
|
|
2011-09-14 03:03:06 +04:00
|
|
|
p_freerdp_image_convert freerdp_image_convert_[5] =
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
NULL,
|
2011-09-14 03:03:06 +04:00
|
|
|
freerdp_image_convert_8bpp,
|
|
|
|
freerdp_image_convert_16bpp,
|
|
|
|
freerdp_image_convert_24bpp,
|
|
|
|
freerdp_image_convert_32bpp
|
2011-07-01 05:23:36 +04:00
|
|
|
};
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_image_convert(BYTE* srcData, BYTE* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-09-14 03:03:06 +04:00
|
|
|
p_freerdp_image_convert _p_freerdp_image_convert = freerdp_image_convert_[IBPP(srcBpp)];
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2011-09-14 03:03:06 +04:00
|
|
|
if (_p_freerdp_image_convert != NULL)
|
|
|
|
return _p_freerdp_image_convert(srcData, dstData, width, height, srcBpp, dstBpp, clrconv);
|
2011-07-01 05:23:36 +04:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-04 01:19:25 +04:00
|
|
|
void freerdp_bitmap_flip(BYTE * src, BYTE * dst, int scanLineSz, int height)
|
2011-12-12 17:41:31 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE * bottomLine = dst + (scanLineSz * (height - 1));
|
|
|
|
BYTE * topLine = src;
|
2011-12-12 17:41:31 +04:00
|
|
|
|
|
|
|
/* Special processing if called for flip-in-place. */
|
|
|
|
if (src == dst)
|
|
|
|
{
|
|
|
|
/* Allocate a scanline buffer.
|
2012-10-09 07:21:26 +04:00
|
|
|
* (FIXME: malloc / xfree below should be replaced by "get/put
|
2011-12-12 17:41:31 +04:00
|
|
|
* scanline buffer from a pool/Q of fixed buffers" to reuse
|
|
|
|
* fixed size buffers (of max scanline size (or adaptative?) )
|
|
|
|
* -- would be much faster).
|
|
|
|
*/
|
2014-07-08 23:07:19 +04:00
|
|
|
BYTE* tmpBfr = _aligned_malloc(scanLineSz, 16);
|
2011-12-12 17:41:31 +04:00
|
|
|
int half = height / 2;
|
|
|
|
/* Flip buffer in place by line permutations through the temp
|
|
|
|
* scan line buffer.
|
2011-12-12 18:49:44 +04:00
|
|
|
* Note that if height has an odd number of line, we don't need
|
2011-12-12 17:41:31 +04:00
|
|
|
* to move the center scanline anyway.
|
|
|
|
* Also note that in place flipping takes three memcpy() calls
|
|
|
|
* to process two scanlines while src to distinct dest would
|
|
|
|
* only requires two memcpy() calls for two scanlines.
|
|
|
|
*/
|
|
|
|
height--;
|
|
|
|
for (i = 0; i < half ; i++)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
CopyMemory(tmpBfr, topLine, scanLineSz);
|
|
|
|
CopyMemory(topLine, bottomLine, scanLineSz);
|
|
|
|
CopyMemory(bottomLine, tmpBfr, scanLineSz);
|
2011-12-12 17:41:31 +04:00
|
|
|
topLine += scanLineSz;
|
|
|
|
bottomLine -= scanLineSz;
|
|
|
|
height--;
|
|
|
|
}
|
2014-07-08 23:07:19 +04:00
|
|
|
_aligned_free(tmpBfr);
|
2011-12-12 17:41:31 +04:00
|
|
|
}
|
|
|
|
/* Flip from source buffer to destination buffer. */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
CopyMemory(bottomLine, topLine, scanLineSz);
|
2011-12-12 17:41:31 +04:00
|
|
|
topLine += scanLineSz;
|
|
|
|
bottomLine -= scanLineSz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_image_flip(BYTE* srcData, BYTE* dstData, int width, int height, int bpp)
|
2011-08-22 06:30:49 +04:00
|
|
|
{
|
|
|
|
int scanline;
|
|
|
|
|
2012-05-18 21:43:51 +04:00
|
|
|
scanline = width * ((bpp + 7) / 8);
|
2011-08-22 06:30:49 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (!dstData)
|
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * ((bpp + 7) / 8), 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
2011-08-22 06:30:49 +04:00
|
|
|
|
2011-12-12 17:41:31 +04:00
|
|
|
freerdp_bitmap_flip(srcData, dstData, scanline, height);
|
2014-07-08 23:07:19 +04:00
|
|
|
|
2011-08-22 06:30:49 +04:00
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_icon_convert(BYTE* srcData, BYTE* dstData, BYTE* mask, int width, int height, int bpp, HCLRCONV clrconv)
|
2011-08-22 06:30:49 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* data;
|
|
|
|
BYTE bmask;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32* icon;
|
2012-05-22 00:01:24 +04:00
|
|
|
int x, y, bit;
|
|
|
|
int maskIndex;
|
|
|
|
|
2012-05-18 21:43:51 +04:00
|
|
|
if (bpp == 16)
|
|
|
|
{
|
|
|
|
/* Server sends 16 bpp field, but data is usually 15-bit 555 */
|
|
|
|
bpp = 15;
|
|
|
|
}
|
|
|
|
|
2011-10-05 05:29:01 +04:00
|
|
|
data = freerdp_image_flip(srcData, dstData, width, height, bpp);
|
2011-09-14 03:03:06 +04:00
|
|
|
dstData = freerdp_image_convert(data, NULL, width, height, bpp, 32, clrconv);
|
2014-07-08 23:07:19 +04:00
|
|
|
_aligned_free(data);
|
2011-08-22 06:30:49 +04:00
|
|
|
|
2012-05-18 21:43:51 +04:00
|
|
|
/* Read the AND alpha plane */
|
2011-08-22 06:30:49 +04:00
|
|
|
if (bpp < 32)
|
|
|
|
{
|
2012-05-18 21:43:51 +04:00
|
|
|
maskIndex = 0;
|
2012-10-09 11:26:39 +04:00
|
|
|
icon = (UINT32*) dstData;
|
2012-05-18 21:43:51 +04:00
|
|
|
|
2011-08-22 06:30:49 +04:00
|
|
|
for (y = 0; y < height; y++)
|
|
|
|
{
|
2012-05-18 21:43:51 +04:00
|
|
|
for (x = 0; x < width-7; x+=8)
|
2011-08-22 06:30:49 +04:00
|
|
|
{
|
2012-05-18 21:43:51 +04:00
|
|
|
bmask = mask[maskIndex++];
|
|
|
|
|
|
|
|
for (bit = 0; bit < 8; bit++)
|
|
|
|
if ((bmask & (0x80 >> bit)) == 0)
|
2013-08-30 16:47:00 +04:00
|
|
|
{
|
|
|
|
UINT32 *tmp = (icon + (height - y - 1) * width + x + bit);
|
|
|
|
if (tmp)
|
|
|
|
*tmp |= 0xFF000000;
|
|
|
|
}
|
2012-05-18 21:43:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((width % 8) != 0)
|
|
|
|
{
|
|
|
|
bmask = mask[maskIndex++];
|
|
|
|
|
|
|
|
for (bit = 0; bit < width % 8; bit++)
|
|
|
|
if ((bmask & (0x80 >> bit)) == 0)
|
2013-08-30 16:47:00 +04:00
|
|
|
{
|
|
|
|
UINT32 *tmp = (icon + (height - y - 1) * width + x + bit);
|
|
|
|
if (tmp)
|
|
|
|
*tmp |= 0xFF000000;
|
|
|
|
}
|
2011-08-22 06:30:49 +04:00
|
|
|
}
|
2012-05-18 21:43:51 +04:00
|
|
|
|
|
|
|
/* Skip padding */
|
|
|
|
if ((width % 32) != 0)
|
|
|
|
maskIndex += (32 - (width % 32)) / 8;
|
2011-08-22 06:30:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* freerdp_glyph_convert(int width, int height, BYTE* data)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
int x, y;
|
2014-07-08 23:07:19 +04:00
|
|
|
BYTE* srcp;
|
|
|
|
BYTE* dstp;
|
|
|
|
BYTE* dstData;
|
2011-07-01 05:23:36 +04:00
|
|
|
int scanline;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* converts a 1-bit-per-pixel glyph to a one-byte-per-pixel glyph:
|
|
|
|
* this approach uses a little more memory, but provides faster
|
|
|
|
* means of accessing individual pixels in blitting operations
|
|
|
|
*/
|
|
|
|
|
|
|
|
scanline = (width + 7) / 8;
|
2014-07-08 23:07:19 +04:00
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ZeroMemory(dstData, width * height);
|
2011-07-01 05:23:36 +04:00
|
|
|
dstp = dstData;
|
|
|
|
|
|
|
|
for (y = 0; y < height; y++)
|
|
|
|
{
|
|
|
|
srcp = data + (y * scanline);
|
|
|
|
|
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
{
|
|
|
|
if ((*srcp & (0x80 >> (x % 8))) != 0)
|
|
|
|
*dstp = 0xFF;
|
|
|
|
dstp++;
|
|
|
|
|
|
|
|
if (((x + 1) % 8 == 0) && x != 0)
|
|
|
|
srcp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
BYTE* freerdp_mono_image_convert(BYTE* srcData, int width, int height, int srcBpp, int dstBpp, UINT32 bgcolor, UINT32 fgcolor, HCLRCONV clrconv)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
int index;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16* dst16;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32* dst32;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE* dstData;
|
|
|
|
BYTE bitMask;
|
2011-07-01 05:23:36 +04:00
|
|
|
int bitIndex;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE redBg, greenBg, blueBg;
|
|
|
|
BYTE redFg, greenFg, blueFg;
|
2014-08-07 01:58:58 +04:00
|
|
|
|
|
|
|
GetRGB32(redBg, greenBg, blueBg, bgcolor);
|
|
|
|
GetRGB32(redFg, greenFg, blueFg, fgcolor);
|
2011-07-01 05:23:36 +04:00
|
|
|
|
2011-12-30 23:23:47 +04:00
|
|
|
if (dstBpp == 16)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 2, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
dst16 = (UINT16*) dstData;
|
2011-12-30 23:23:47 +04:00
|
|
|
|
2014-08-14 21:09:12 +04:00
|
|
|
if (clrconv->rgb555)
|
|
|
|
{
|
|
|
|
bgcolor = clrconv->invert ? BGR15(redBg, greenBg, blueBg) : RGB15(redBg, greenBg, blueBg);
|
|
|
|
fgcolor = clrconv->invert ? BGR15(redFg, greenFg, blueFg) : RGB15(redFg, greenFg, blueFg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bgcolor = clrconv->invert ? BGR16(redBg, greenBg, blueBg) : RGB16(redBg, greenBg, blueBg);
|
|
|
|
fgcolor = clrconv->invert ? BGR16(redFg, greenFg, blueFg) : RGB16(redFg, greenFg, blueFg);
|
|
|
|
}
|
|
|
|
|
2012-01-16 20:40:18 +04:00
|
|
|
for (index = height; index > 0; index--)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
/* each bit encodes a pixel */
|
|
|
|
bitMask = *srcData;
|
2011-12-30 23:23:47 +04:00
|
|
|
for (bitIndex = 7; bitIndex >= 0; bitIndex--)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2011-12-30 23:23:47 +04:00
|
|
|
if ((bitMask >> bitIndex) & 0x01)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
*dst16 = bgcolor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*dst16 = fgcolor;
|
|
|
|
}
|
|
|
|
dst16++;
|
|
|
|
}
|
|
|
|
srcData++;
|
|
|
|
}
|
|
|
|
return dstData;
|
|
|
|
}
|
2011-12-30 23:23:47 +04:00
|
|
|
else if (dstBpp == 32)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
dstData = (BYTE*) _aligned_malloc(width * height * 4, 16);
|
|
|
|
|
|
|
|
if (!dstData)
|
|
|
|
return NULL;
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
dst32 = (UINT32*) dstData;
|
2011-12-30 23:23:47 +04:00
|
|
|
|
|
|
|
for (index = height; index > 0; index--)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
|
|
|
/* each bit encodes a pixel */
|
|
|
|
bitMask = *srcData;
|
2011-12-30 23:23:47 +04:00
|
|
|
|
|
|
|
for (bitIndex = 7; bitIndex >= 0; bitIndex--)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2012-01-16 20:40:18 +04:00
|
|
|
if ((bitMask >> bitIndex) & 0x01)
|
2011-07-01 05:23:36 +04:00
|
|
|
{
|
2014-08-07 01:58:58 +04:00
|
|
|
if (clrconv->alpha)
|
|
|
|
{
|
|
|
|
*dst32 = (clrconv->invert) ? ABGR32(0xFF, redBg, greenBg, blueBg) : ARGB32(0xFF, redBg, greenBg, blueBg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*dst32 = (clrconv->invert) ? BGR32(redBg, greenBg, blueBg) : RGB32(redBg, greenBg, blueBg);
|
|
|
|
}
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-07 01:58:58 +04:00
|
|
|
if (clrconv->alpha)
|
|
|
|
{
|
|
|
|
*dst32 = (clrconv->invert) ? ABGR32(0xFF, redFg, greenFg, blueFg) : ARGB32(0xFF, redFg, greenFg, blueFg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*dst32 = (clrconv->invert) ? BGR32(redFg, greenFg, blueFg) : RGB32(redFg, greenFg, blueFg);
|
|
|
|
}
|
2011-07-01 05:23:36 +04:00
|
|
|
}
|
|
|
|
dst32++;
|
|
|
|
}
|
|
|
|
srcData++;
|
|
|
|
}
|
|
|
|
return dstData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return srcData;
|
|
|
|
}
|
2011-09-29 08:33:16 +04:00
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
void freerdp_alpha_cursor_convert(BYTE* alphaData, BYTE* xorMask, BYTE* andMask, int width, int height, int bpp, HCLRCONV clrconv)
|
2011-09-29 08:33:16 +04:00
|
|
|
{
|
2014-10-22 04:46:15 +04:00
|
|
|
UINT32 xorPixel;
|
|
|
|
UINT32 andPixel;
|
|
|
|
UINT32 x, y, jj;
|
2011-09-29 08:33:16 +04:00
|
|
|
|
2014-10-22 04:46:15 +04:00
|
|
|
for (y = 0; y < height; y++)
|
2011-09-29 08:33:16 +04:00
|
|
|
{
|
2014-10-22 04:46:15 +04:00
|
|
|
jj = (bpp == 1) ? y : (height - 1) - y;
|
|
|
|
|
|
|
|
for (x = 0; x < width; x++)
|
2011-09-29 08:33:16 +04:00
|
|
|
{
|
2014-10-22 04:46:15 +04:00
|
|
|
xorPixel = freerdp_get_pixel(xorMask, x, jj, width, height, bpp);
|
|
|
|
xorPixel = freerdp_color_convert_rgb(xorPixel, bpp, 32, clrconv);
|
|
|
|
andPixel = freerdp_get_pixel(andMask, x, jj, width, height, 1);
|
2011-09-29 08:33:16 +04:00
|
|
|
|
2014-10-22 04:46:15 +04:00
|
|
|
if (andPixel)
|
2011-09-29 08:33:16 +04:00
|
|
|
{
|
2014-10-22 04:46:15 +04:00
|
|
|
if ((xorPixel & 0xFFFFFF) == 0xFFFFFF)
|
2011-09-29 08:33:16 +04:00
|
|
|
{
|
|
|
|
/* use pattern (not solid black) for xor area */
|
2014-10-22 04:46:15 +04:00
|
|
|
xorPixel = (x & 1) == (y & 1);
|
|
|
|
xorPixel = xorPixel ? 0xFFFFFF : 0;
|
|
|
|
xorPixel |= 0xFF000000;
|
2011-09-29 08:33:16 +04:00
|
|
|
}
|
2014-10-22 04:46:15 +04:00
|
|
|
else if (xorPixel == 0xFF000000)
|
2011-09-29 08:33:16 +04:00
|
|
|
{
|
2014-10-22 04:46:15 +04:00
|
|
|
xorPixel = 0;
|
2011-09-29 08:33:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:46:15 +04:00
|
|
|
freerdp_set_pixel(alphaData, x, y, width, height, 32, xorPixel);
|
2011-09-29 08:33:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:46:15 +04:00
|
|
|
/**
|
|
|
|
* Drawing Monochrome Pointers:
|
|
|
|
* http://msdn.microsoft.com/en-us/library/windows/hardware/ff556143/
|
|
|
|
*
|
|
|
|
* Drawing Color Pointers:
|
|
|
|
* http://msdn.microsoft.com/en-us/library/windows/hardware/ff556138/
|
|
|
|
*/
|
|
|
|
|
|
|
|
int freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat, int nDstStep, int nXDst, int nYDst,
|
|
|
|
int nWidth, int nHeight, BYTE* xorMask, BYTE* andMask, UINT32 xorBpp, BYTE* palette)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
BOOL vFlip;
|
|
|
|
BOOL invert;
|
|
|
|
int srcFlip;
|
|
|
|
int dstFlip;
|
|
|
|
int nDstPad;
|
|
|
|
int xorStep;
|
|
|
|
int andStep;
|
|
|
|
UINT32 xorBit;
|
|
|
|
UINT32 andBit;
|
|
|
|
BYTE* xorBits;
|
|
|
|
BYTE* andBits;
|
|
|
|
UINT32 xorPixel;
|
|
|
|
UINT32 andPixel;
|
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
|
|
|
|
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
|
|
|
dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat);
|
|
|
|
|
|
|
|
if (nDstStep < 0)
|
|
|
|
nDstStep = dstBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
nDstPad = (nDstStep - (nWidth * dstBytesPerPixel));
|
|
|
|
|
|
|
|
srcFlip = (xorBpp == 1) ? FREERDP_PIXEL_FLIP_NONE : FREERDP_PIXEL_FLIP_VERTICAL;
|
|
|
|
|
|
|
|
vFlip = (srcFlip != dstFlip) ? TRUE : FALSE;
|
|
|
|
invert = (FREERDP_PIXEL_FORMAT_IS_ABGR(DstFormat)) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
andStep = (nWidth + 7) / 8;
|
|
|
|
andStep += (andStep % 2);
|
|
|
|
|
|
|
|
if (dstBytesPerPixel == 4)
|
|
|
|
{
|
|
|
|
UINT32* pDstPixel;
|
|
|
|
|
|
|
|
if (xorBpp == 1)
|
|
|
|
{
|
|
|
|
xorStep = (nWidth + 7) / 8;
|
|
|
|
xorStep += (xorStep % 2);
|
|
|
|
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
xorBit = andBit = 0x80;
|
|
|
|
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
xorBits = &xorMask[xorStep * y];
|
|
|
|
andBits = &andMask[andStep * y];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xorBits = &xorMask[xorStep * (nHeight - y - 1)];
|
|
|
|
andBits = &andMask[andStep * (nHeight - y - 1)];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
xorPixel = (*xorBits & xorBit) ? 1 : 0;
|
|
|
|
if (!(xorBit >>= 1)) { xorBits++; xorBit = 0x80; }
|
|
|
|
|
|
|
|
andPixel = (*andBits & andBit) ? 1 : 0;
|
|
|
|
if (!(andBit >>= 1)) { andBits++; andBit = 0x80; }
|
|
|
|
|
|
|
|
if (!andPixel && !xorPixel)
|
|
|
|
*pDstPixel++ = 0xFF000000; /* black */
|
|
|
|
else if (!andPixel && xorPixel)
|
|
|
|
*pDstPixel++ = 0xFFFFFFFF; /* white */
|
|
|
|
else if (andPixel && !xorPixel)
|
|
|
|
*pDstPixel++ = 0x00000000; /* transparent */
|
|
|
|
else if (andPixel && xorPixel)
|
|
|
|
*pDstPixel++ = 0xFF000000; /* inverted (set as black) */
|
|
|
|
}
|
|
|
|
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (xorBpp == 32)
|
|
|
|
{
|
|
|
|
xorStep = nWidth * 4;
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
andBit = 0x80;
|
|
|
|
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
andBits = &andMask[andStep * y];
|
|
|
|
xorBits = &xorMask[xorStep * y];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
andBits = &andMask[andStep * (nHeight - y - 1)];
|
|
|
|
xorBits = &xorMask[xorStep * (nHeight - y - 1)];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
xorPixel = *((UINT32*) xorBits);
|
|
|
|
xorBits += 4;
|
|
|
|
|
|
|
|
andPixel = (*andBits & andBit) ? 1 : 0;
|
|
|
|
if (!(andBit >>= 1)) { andBits++; andBit = 0x80; }
|
|
|
|
|
|
|
|
xorPixel |= 0xFF000000;
|
|
|
|
|
|
|
|
if (andPixel)
|
|
|
|
{
|
|
|
|
if ((~xorPixel) & 0xFFFFFF) /* black */
|
|
|
|
*pDstPixel++ = 0x00000000; /* transparent */
|
|
|
|
else if (xorPixel & 0xFFFFFF) /* white */
|
|
|
|
*pDstPixel++ = 0xFF000000; /* inverted (set as black) */
|
|
|
|
else
|
|
|
|
*pDstPixel++ = xorPixel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*pDstPixel++ = xorPixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "freerdp_image_copy_from_pointer_data: failed to convert from %d bpp to %d bpp\n",
|
|
|
|
xorBpp, dstBitsPerPixel);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
void freerdp_image_swap_color_order(BYTE* data, int width, int height)
|
2011-09-30 06:31:13 +04:00
|
|
|
{
|
|
|
|
int x, y;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32* pixel;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE a, r, g, b;
|
2011-09-30 06:31:13 +04:00
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
pixel = (UINT32*) data;
|
2011-09-30 06:31:13 +04:00
|
|
|
|
|
|
|
for (y = 0; y < height; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
{
|
|
|
|
GetARGB32(a, r, g, b, *pixel);
|
|
|
|
*pixel = ABGR32(a, r, g, b);
|
|
|
|
pixel++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-02 03:42:20 +04:00
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
HCLRCONV freerdp_clrconv_new(UINT32 flags)
|
2012-02-02 03:42:20 +04:00
|
|
|
{
|
2012-11-22 05:21:08 +04:00
|
|
|
HCLRCONV clrconv;
|
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
clrconv = (CLRCONV*) calloc(1, sizeof(CLRCONV));
|
|
|
|
|
|
|
|
if (!clrconv)
|
|
|
|
return NULL;
|
2012-02-02 03:42:20 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
clrconv->alpha = (flags & CLRCONV_ALPHA) ? TRUE : FALSE;
|
|
|
|
clrconv->invert = (flags & CLRCONV_INVERT) ? TRUE : FALSE;
|
|
|
|
clrconv->rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
clrconv->palette = (rdpPalette*) calloc(1, sizeof(rdpPalette));
|
|
|
|
|
|
|
|
if (!clrconv->palette)
|
|
|
|
return NULL;
|
2012-02-02 03:42:20 +04:00
|
|
|
|
|
|
|
return clrconv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void freerdp_clrconv_free(HCLRCONV clrconv)
|
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (clrconv)
|
2012-02-02 03:42:20 +04:00
|
|
|
{
|
2014-07-08 23:07:19 +04:00
|
|
|
if (clrconv->palette)
|
2012-10-09 07:21:26 +04:00
|
|
|
free(clrconv->palette);
|
2012-02-02 03:42:20 +04:00
|
|
|
|
2012-10-09 07:21:26 +04:00
|
|
|
free(clrconv);
|
2012-02-02 03:42:20 +04:00
|
|
|
}
|
|
|
|
}
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
int freerdp_image8_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
|
|
|
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette)
|
|
|
|
{
|
|
|
|
BYTE* pe;
|
|
|
|
int x, y;
|
|
|
|
int srcFlip;
|
|
|
|
int dstFlip;
|
|
|
|
int nSrcPad;
|
|
|
|
int nDstPad;
|
|
|
|
int srcBitsPerPixel;
|
|
|
|
int srcBytesPerPixel;
|
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
|
|
|
BOOL vFlip = FALSE;
|
|
|
|
BOOL invert = FALSE;
|
|
|
|
|
|
|
|
if (!palette)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(SrcFormat);
|
|
|
|
srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(SrcFormat) / 8);
|
|
|
|
srcFlip = FREERDP_PIXEL_FORMAT_FLIP(SrcFormat);
|
|
|
|
|
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
|
|
|
dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat);
|
|
|
|
|
|
|
|
if (nSrcStep < 0)
|
|
|
|
nSrcStep = srcBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
if (nDstStep < 0)
|
|
|
|
nDstStep = dstBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel));
|
|
|
|
nDstPad = (nDstStep - (nWidth * dstBytesPerPixel));
|
|
|
|
|
|
|
|
if (srcFlip != dstFlip)
|
|
|
|
vFlip = TRUE;
|
|
|
|
|
|
|
|
invert = FREERDP_PIXEL_FORMAT_IS_ABGR(DstFormat) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (dstBytesPerPixel == 4)
|
|
|
|
{
|
|
|
|
if ((dstBitsPerPixel == 32) || (dstBitsPerPixel == 24))
|
|
|
|
{
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
UINT32* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = RGB32(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = RGB32(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = BGR32(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = BGR32(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 3)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 2)
|
|
|
|
{
|
|
|
|
if (dstBitsPerPixel == 16)
|
|
|
|
{
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = RGB16(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = RGB16(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = BGR16(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = BGR16(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (dstBitsPerPixel == 15)
|
|
|
|
{
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = RGB15(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = RGB15(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = BGR15(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pe = &palette[*pSrcPixel * 4];
|
|
|
|
*pDstPixel++ = BGR15(pe[2], pe[1], pe[0]);
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 1)
|
|
|
|
{
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
BYTE* pDstPixel;
|
|
|
|
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + nXDst];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth);
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcStep];
|
|
|
|
pDstPixel = &pDstPixel[nDstStep];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + nXSrc];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + nXDst];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth);
|
|
|
|
pSrcPixel = &pSrcPixel[-nSrcStep];
|
|
|
|
pDstPixel = &pDstPixel[nDstStep];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
int freerdp_image15_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-06-13 16:36:09 +04:00
|
|
|
int x, y;
|
2014-06-18 00:15:30 +04:00
|
|
|
int srcFlip;
|
|
|
|
int dstFlip;
|
2014-09-12 04:12:32 +04:00
|
|
|
int nSrcPad;
|
|
|
|
int nDstPad;
|
2014-09-17 20:17:41 +04:00
|
|
|
BYTE r, g, b;
|
2014-03-01 06:51:29 +04:00
|
|
|
int srcBitsPerPixel;
|
|
|
|
int srcBytesPerPixel;
|
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
2014-09-15 22:59:45 +04:00
|
|
|
int srcType, dstType;
|
2014-06-18 00:15:30 +04:00
|
|
|
BOOL vFlip = FALSE;
|
2014-09-15 22:59:45 +04:00
|
|
|
BOOL invert = FALSE;
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-15 22:59:45 +04:00
|
|
|
srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(SrcFormat);
|
|
|
|
srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(SrcFormat) / 8);
|
|
|
|
srcFlip = FREERDP_PIXEL_FORMAT_FLIP(SrcFormat);
|
|
|
|
srcType = FREERDP_PIXEL_FORMAT_TYPE(SrcFormat);
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-15 22:59:45 +04:00
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
|
|
|
dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat);
|
|
|
|
dstType = FREERDP_PIXEL_FORMAT_TYPE(DstFormat);
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
if (nSrcStep < 0)
|
|
|
|
nSrcStep = srcBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
if (nDstStep < 0)
|
|
|
|
nDstStep = dstBytesPerPixel * nWidth;
|
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel));
|
|
|
|
nDstPad = (nDstStep - (nWidth * dstBytesPerPixel));
|
|
|
|
|
2014-06-18 00:15:30 +04:00
|
|
|
if (srcFlip != dstFlip)
|
|
|
|
vFlip = TRUE;
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-15 22:59:45 +04:00
|
|
|
if (srcType != dstType)
|
|
|
|
invert = TRUE;
|
2014-06-13 00:13:12 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (dstBytesPerPixel == 4)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
if ((dstBitsPerPixel == 32) || (dstBitsPerPixel == 24))
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
UINT16* pSrcPixel;
|
|
|
|
UINT32* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!vFlip)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-06-13 05:02:25 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-06-13 05:02:25 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ARGB32(0xFF, r, g, b);
|
2014-03-01 06:51:29 +04:00
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-06-13 05:02:25 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-15 22:59:45 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ARGB32(0xFF, r, g, b);
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-15 22:59:45 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-06-13 05:02:25 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-06-18 00:15:30 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-06-18 00:15:30 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ABGR32(0xFF, r, g, b);
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-06-18 00:15:30 +04:00
|
|
|
}
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-06-18 00:15:30 +04:00
|
|
|
}
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-06-13 05:02:25 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-06-18 00:15:30 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ABGR32(0xFF, r, g, b);
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-06-18 00:15:30 +04:00
|
|
|
}
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-18 02:43:42 +04:00
|
|
|
|
|
|
|
return 1;
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 2)
|
|
|
|
{
|
|
|
|
if (dstBitsPerPixel == 16)
|
|
|
|
{
|
|
|
|
UINT16* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!vFlip)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-06-13 05:02:25 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-06-13 05:02:25 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = RGB16(r, g, b);
|
2014-03-01 06:51:29 +04:00
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-06-13 05:02:25 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-06-13 05:02:25 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = RGB16(r, g, b);
|
2014-03-01 06:51:29 +04:00
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!vFlip)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-06-13 05:02:25 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-06-13 05:02:25 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = BGR16(r, g, b);
|
2014-03-01 06:51:29 +04:00
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
|
|
|
}
|
2014-09-12 04:12:32 +04:00
|
|
|
else
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-06-13 05:02:25 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-06-13 05:02:25 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-03-01 06:51:29 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = BGR16(r, g, b);
|
2014-03-01 06:51:29 +04:00
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
2014-09-12 04:12:32 +04:00
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
|
|
|
|
return 1;
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else if (dstBitsPerPixel == 15)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
UINT16* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
2014-03-01 06:51:29 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!invert)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = RGB15(r, g, b);
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = RGB15(r, g, b);
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!vFlip)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = BGR15(r, g, b);
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB15(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = BGR15(r, g, b);
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
return 1;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
int freerdp_image16_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette)
|
2014-09-17 20:17:41 +04:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int srcFlip;
|
|
|
|
int dstFlip;
|
|
|
|
int nSrcPad;
|
|
|
|
int nDstPad;
|
|
|
|
BYTE r, g, b;
|
|
|
|
int srcBitsPerPixel;
|
|
|
|
int srcBytesPerPixel;
|
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
|
|
|
int srcType, dstType;
|
|
|
|
BOOL vFlip = FALSE;
|
|
|
|
BOOL invert = FALSE;
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(SrcFormat);
|
|
|
|
srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(SrcFormat) / 8);
|
|
|
|
srcFlip = FREERDP_PIXEL_FORMAT_FLIP(SrcFormat);
|
|
|
|
srcType = FREERDP_PIXEL_FORMAT_TYPE(SrcFormat);
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
|
|
|
dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat);
|
|
|
|
dstType = FREERDP_PIXEL_FORMAT_TYPE(DstFormat);
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
if (nSrcStep < 0)
|
|
|
|
nSrcStep = srcBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
if (nDstStep < 0)
|
|
|
|
nDstStep = dstBytesPerPixel * nWidth;
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel));
|
|
|
|
nDstPad = (nDstStep - (nWidth * dstBytesPerPixel));
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (srcFlip != dstFlip)
|
|
|
|
vFlip = TRUE;
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (srcType != dstType)
|
|
|
|
invert = TRUE;
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (dstBytesPerPixel == 4)
|
|
|
|
{
|
|
|
|
if ((dstBitsPerPixel == 32) || (dstBitsPerPixel == 24))
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
UINT16* pSrcPixel;
|
|
|
|
UINT32* pDstPixel;
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!invert)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!vFlip)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ARGB32(0xFF, r, g, b);
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ARGB32(0xFF, r, g, b);
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!vFlip)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ABGR32(0xFF, r, g, b);
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-15 22:59:45 +04:00
|
|
|
}
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-12 04:12:32 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ABGR32(0xFF, r, g, b);
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 2)
|
|
|
|
{
|
|
|
|
if (dstBitsPerPixel == 16)
|
|
|
|
{
|
|
|
|
UINT16* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth * 2);
|
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcStep];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstStep];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-15 22:59:45 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth * 2);
|
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-nSrcStep];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstStep];
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!vFlip)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = BGR16(r, g, b);
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = BGR16(r, g, b);
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (dstBitsPerPixel == 15)
|
|
|
|
{
|
|
|
|
UINT16* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = RGB15(r, g, b);
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
else
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = RGB15(r, g, b);
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
for (x = 0; x < nWidth; x++)
|
2014-09-17 03:12:26 +04:00
|
|
|
{
|
2014-09-17 20:17:41 +04:00
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = BGR15(r, g, b);
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = (UINT16*) &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 2)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
GetRGB16(r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = BGR15(r, g, b);
|
2014-09-17 03:12:26 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
pSrcPixel = (UINT16*) &((BYTE*) pSrcPixel)[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
2014-09-17 03:12:26 +04:00
|
|
|
}
|
|
|
|
}
|
2014-09-12 04:12:32 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2014-09-12 04:12:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
2014-06-13 16:36:09 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
int freerdp_image24_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette)
|
2014-09-17 20:17:41 +04:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int srcFlip;
|
|
|
|
int dstFlip;
|
|
|
|
int nSrcPad;
|
|
|
|
int nDstPad;
|
|
|
|
int srcBitsPerPixel;
|
|
|
|
int srcBytesPerPixel;
|
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
|
|
|
int srcType, dstType;
|
|
|
|
BOOL vFlip = FALSE;
|
|
|
|
BOOL invert = FALSE;
|
|
|
|
|
|
|
|
srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(SrcFormat);
|
|
|
|
srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(SrcFormat) / 8);
|
|
|
|
srcFlip = FREERDP_PIXEL_FORMAT_FLIP(SrcFormat);
|
|
|
|
srcType = FREERDP_PIXEL_FORMAT_TYPE(SrcFormat);
|
|
|
|
|
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
|
|
|
dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat);
|
|
|
|
dstType = FREERDP_PIXEL_FORMAT_TYPE(DstFormat);
|
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
if (nSrcStep < 0)
|
|
|
|
nSrcStep = srcBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
if (nDstStep < 0)
|
|
|
|
nDstStep = dstBytesPerPixel * nWidth;
|
|
|
|
|
2014-10-15 04:59:22 +04:00
|
|
|
nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel));
|
|
|
|
nDstPad = (nDstStep - (nWidth * dstBytesPerPixel));
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
if (srcFlip != dstFlip)
|
|
|
|
vFlip = TRUE;
|
|
|
|
|
|
|
|
if (srcType != dstType)
|
|
|
|
invert = TRUE;
|
|
|
|
|
|
|
|
if (dstBytesPerPixel == 4)
|
|
|
|
{
|
|
|
|
if ((dstBitsPerPixel == 32) || (dstBitsPerPixel == 24))
|
|
|
|
{
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
BYTE* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = *pSrcPixel++;
|
|
|
|
*pDstPixel++ = *pSrcPixel++;
|
|
|
|
*pDstPixel++ = *pSrcPixel++;
|
|
|
|
*pDstPixel++ = 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = *pSrcPixel++;
|
|
|
|
*pDstPixel++ = *pSrcPixel++;
|
|
|
|
*pDstPixel++ = *pSrcPixel++;
|
|
|
|
*pDstPixel++ = 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pDstPixel[0] = pSrcPixel[2];
|
|
|
|
pDstPixel[1] = pSrcPixel[1];
|
|
|
|
pDstPixel[2] = pSrcPixel[0];
|
|
|
|
pDstPixel[3] = 0xFF;
|
|
|
|
|
|
|
|
pSrcPixel += 4;
|
|
|
|
pDstPixel += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pDstPixel[0] = pSrcPixel[2];
|
|
|
|
pDstPixel[1] = pSrcPixel[1];
|
|
|
|
pDstPixel[2] = pSrcPixel[0];
|
|
|
|
pDstPixel[3] = 0xFF;
|
|
|
|
|
|
|
|
pSrcPixel += 4;
|
|
|
|
pDstPixel += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 3)
|
|
|
|
{
|
2014-10-13 20:29:06 +04:00
|
|
|
BYTE* pSrcPixel;
|
|
|
|
BYTE* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 3)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth * 3);
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcStep];
|
|
|
|
pDstPixel = &pDstPixel[nDstStep];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 3)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth * 3);
|
|
|
|
pSrcPixel = &pSrcPixel[-nSrcStep];
|
|
|
|
pDstPixel = &pDstPixel[nDstStep];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 3)];
|
2014-09-17 20:17:41 +04:00
|
|
|
|
2014-10-13 20:29:06 +04:00
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pDstPixel[0] = pSrcPixel[2];
|
|
|
|
pDstPixel[1] = pSrcPixel[1];
|
|
|
|
pDstPixel[2] = pSrcPixel[0];
|
|
|
|
|
|
|
|
pSrcPixel += 3;
|
|
|
|
pDstPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 3)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pDstPixel[0] = pSrcPixel[2];
|
|
|
|
pDstPixel[1] = pSrcPixel[1];
|
|
|
|
pDstPixel[2] = pSrcPixel[0];
|
|
|
|
|
|
|
|
pSrcPixel += 3;
|
|
|
|
pDstPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 2)
|
|
|
|
{
|
|
|
|
if (dstBitsPerPixel == 16)
|
|
|
|
{
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = RGB16(pSrcPixel[2], pSrcPixel[1], pSrcPixel[0]);
|
|
|
|
pSrcPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = &((UINT16*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = RGB16(pSrcPixel[2], pSrcPixel[1], pSrcPixel[0]);
|
|
|
|
pSrcPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = &((UINT16*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = RGB16(pSrcPixel[0], pSrcPixel[1], pSrcPixel[2]);
|
|
|
|
pSrcPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = &((UINT16*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = RGB16(pSrcPixel[0], pSrcPixel[1], pSrcPixel[2]);
|
|
|
|
pSrcPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = &((UINT16*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (dstBitsPerPixel == 15)
|
|
|
|
{
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = RGB15(pSrcPixel[2], pSrcPixel[1], pSrcPixel[0]);
|
|
|
|
pSrcPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = &((UINT16*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = RGB15(pSrcPixel[2], pSrcPixel[1], pSrcPixel[0]);
|
|
|
|
pSrcPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = &((UINT16*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = RGB15(pSrcPixel[0], pSrcPixel[1], pSrcPixel[2]);
|
|
|
|
pSrcPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = &((UINT16*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 3)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = RGB15(pSrcPixel[0], pSrcPixel[1], pSrcPixel[2]);
|
|
|
|
pSrcPixel += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = &((UINT16*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_image32_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette)
|
2014-09-17 20:17:41 +04:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int srcFlip;
|
|
|
|
int dstFlip;
|
|
|
|
int nSrcPad;
|
|
|
|
int nDstPad;
|
|
|
|
BYTE a, r, g, b;
|
|
|
|
int srcBitsPerPixel;
|
|
|
|
int srcBytesPerPixel;
|
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
|
|
|
int srcType, dstType;
|
|
|
|
BOOL vFlip = FALSE;
|
|
|
|
BOOL invert = FALSE;
|
|
|
|
|
|
|
|
srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(SrcFormat);
|
|
|
|
srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(SrcFormat) / 8);
|
|
|
|
srcFlip = FREERDP_PIXEL_FORMAT_FLIP(SrcFormat);
|
|
|
|
srcType = FREERDP_PIXEL_FORMAT_TYPE(SrcFormat);
|
|
|
|
|
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
|
|
|
dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat);
|
|
|
|
dstType = FREERDP_PIXEL_FORMAT_TYPE(DstFormat);
|
|
|
|
|
2014-09-18 02:30:09 +04:00
|
|
|
if (nSrcStep < 0)
|
|
|
|
nSrcStep = srcBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
if (nDstStep < 0)
|
|
|
|
nDstStep = dstBytesPerPixel * nWidth;
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel));
|
|
|
|
nDstPad = (nDstStep - (nWidth * dstBytesPerPixel));
|
|
|
|
|
|
|
|
if (srcFlip != dstFlip)
|
|
|
|
vFlip = TRUE;
|
|
|
|
|
|
|
|
if (srcType != dstType)
|
|
|
|
invert = TRUE;
|
|
|
|
|
|
|
|
if (srcBitsPerPixel == 24)
|
|
|
|
{
|
|
|
|
if (dstBytesPerPixel == 4) /* srcBytesPerPixel == dstBytesPerPixel */
|
|
|
|
{
|
|
|
|
if (dstBitsPerPixel == 32)
|
|
|
|
{
|
|
|
|
UINT32* pSrcPixel;
|
|
|
|
UINT32* pDstPixel;
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = (UINT32*) &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
*pDstPixel++ = *pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
GetARGB32(a, r, g, b, *pSrcPixel);
|
|
|
|
*pDstPixel = ABGR32(a, r, g, b);
|
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT32*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (dstBitsPerPixel == 24) /* srcBitsPerPixel == dstBitsPerPixel */
|
|
|
|
{
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
BYTE* pDstPixel;
|
|
|
|
|
|
|
|
if (!invert)
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
MoveMemory(pDstPixel, pSrcPixel, nWidth * 4);
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcStep];
|
|
|
|
pDstPixel = &pDstPixel[nDstStep];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
MoveMemory(pDstPixel, pSrcPixel, nWidth * 4);
|
|
|
|
pSrcPixel = &pSrcPixel[-nSrcStep];
|
|
|
|
pDstPixel = &pDstPixel[nDstStep];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!vFlip)
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pDstPixel[0] = pSrcPixel[2];
|
|
|
|
pDstPixel[1] = pSrcPixel[1];
|
|
|
|
pDstPixel[2] = pSrcPixel[0];
|
|
|
|
pDstPixel[3] = 0xFF;
|
|
|
|
|
|
|
|
pSrcPixel += 4;
|
|
|
|
pDstPixel += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSrcPixel = &pSrcData[((nYSrc + nHeight - 1) * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
pDstPixel[0] = pSrcPixel[2];
|
|
|
|
pDstPixel[1] = pSrcPixel[1];
|
|
|
|
pDstPixel[2] = pSrcPixel[0];
|
|
|
|
pDstPixel[3] = 0xFF;
|
|
|
|
|
|
|
|
pSrcPixel += 4;
|
|
|
|
pDstPixel += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[-((nSrcStep - nSrcPad) + nSrcStep)];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 3)
|
|
|
|
{
|
|
|
|
UINT32* pSrcPixel;
|
|
|
|
BYTE* pDstPixel;
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = (BYTE*) &pDstData[(nYDst * nDstStep) + (nXDst * 3)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
GetRGB32(r, g, b, *pSrcPixel);
|
|
|
|
|
|
|
|
*pDstPixel++ = r;
|
|
|
|
*pDstPixel++ = g;
|
|
|
|
*pDstPixel++ = b;
|
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &((BYTE*) pSrcPixel)[nSrcStep];
|
|
|
|
pDstPixel = (BYTE*) &((BYTE*) pDstPixel)[nDstStep];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 2)
|
|
|
|
{
|
|
|
|
if (dstBitsPerPixel == 16)
|
|
|
|
{
|
|
|
|
UINT32* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
GetRGB32(r, g, b, *pSrcPixel);
|
|
|
|
RGB_888_565(r, g, b);
|
|
|
|
*pDstPixel = RGB565(r, g, b);
|
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (dstBitsPerPixel == 15)
|
|
|
|
{
|
|
|
|
UINT32* pSrcPixel;
|
|
|
|
UINT16* pDstPixel;
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = (UINT16*) &pDstData[(nYDst * nDstStep) + (nXDst * 2)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
GetRGB32(r, g, b, *pSrcPixel);
|
|
|
|
RGB_888_555(r, g, b);
|
|
|
|
*pDstPixel = RGB555(r, g, b);
|
|
|
|
|
|
|
|
pSrcPixel++;
|
|
|
|
pDstPixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = (UINT32*) &((BYTE*) pSrcPixel)[nSrcPad];
|
|
|
|
pDstPixel = (UINT16*) &((BYTE*) pDstPixel)[nDstPad];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
return -1;
|
2014-03-01 06:51:29 +04:00
|
|
|
}
|
2014-06-13 16:36:09 +04:00
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
int freerdp_image_copy(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette)
|
2014-09-17 20:17:41 +04:00
|
|
|
{
|
|
|
|
int status = -1;
|
|
|
|
int srcBitsPerPixel;
|
|
|
|
int srcBytesPerPixel;
|
|
|
|
|
|
|
|
srcBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(SrcFormat);
|
|
|
|
srcBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(SrcFormat) / 8);
|
|
|
|
|
|
|
|
if (srcBytesPerPixel == 4)
|
|
|
|
{
|
|
|
|
status = freerdp_image32_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
else if (srcBytesPerPixel == 3)
|
|
|
|
{
|
|
|
|
status = freerdp_image24_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
else if (srcBytesPerPixel == 2)
|
|
|
|
{
|
|
|
|
if (srcBitsPerPixel == 16)
|
|
|
|
{
|
|
|
|
status = freerdp_image16_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
else if (srcBitsPerPixel == 15)
|
|
|
|
{
|
|
|
|
status = freerdp_image15_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
|
2014-09-18 02:30:09 +04:00
|
|
|
nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
|
2014-09-17 20:17:41 +04:00
|
|
|
}
|
|
|
|
}
|
2014-09-18 02:30:09 +04:00
|
|
|
else if (srcBytesPerPixel == 1)
|
|
|
|
{
|
|
|
|
status = freerdp_image8_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
|
|
|
|
nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
|
|
|
|
}
|
2014-09-17 20:17:41 +04:00
|
|
|
|
|
|
|
if (status < 0)
|
|
|
|
{
|
2014-09-18 02:30:09 +04:00
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
|
|
|
|
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
|
|
|
|
2014-09-17 20:17:41 +04:00
|
|
|
fprintf(stderr, "freerdp_image_copy failure: src: %d/%d dst: %d/%d\n",
|
|
|
|
srcBitsPerPixel, srcBytesPerPixel, dstBitsPerPixel, dstBytesPerPixel);
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2014-09-17 01:41:24 +04:00
|
|
|
int freerdp_image_move(BYTE* pData, DWORD Format, int nStep, int nXDst, int nYDst, int nWidth, int nHeight, int nXSrc, int nYSrc)
|
|
|
|
{
|
|
|
|
int y;
|
|
|
|
BOOL overlap;
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
BYTE* pDstPixel;
|
2014-09-18 02:43:42 +04:00
|
|
|
int bytesPerPixel;
|
|
|
|
|
|
|
|
bytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(Format) / 8);
|
|
|
|
|
|
|
|
if (nStep < 0)
|
|
|
|
nStep = nWidth * bytesPerPixel;
|
2014-09-17 01:41:24 +04:00
|
|
|
|
|
|
|
overlap = (((nXDst + nWidth) > nXSrc) && (nXDst < (nXSrc + nWidth)) &&
|
|
|
|
((nYDst + nHeight) > nYSrc) && (nYDst < (nYSrc + nHeight))) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (!overlap)
|
|
|
|
{
|
2014-09-18 02:43:42 +04:00
|
|
|
pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * bytesPerPixel)];
|
|
|
|
pDstPixel = &pData[(nYDst * nStep) + (nXDst * bytesPerPixel)];
|
2014-09-17 01:41:24 +04:00
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
2014-09-18 02:43:42 +04:00
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel);
|
2014-09-17 01:41:24 +04:00
|
|
|
pSrcPixel += nStep;
|
|
|
|
pDstPixel += nStep;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nYSrc < nYDst)
|
|
|
|
{
|
|
|
|
/* copy down */
|
|
|
|
|
2014-09-18 02:43:42 +04:00
|
|
|
pSrcPixel = &pData[((nYSrc + nHeight - 1) * nStep) + (nXSrc * bytesPerPixel)];
|
|
|
|
pDstPixel = &pData[((nYDst + nHeight - 1) * nStep) + (nXDst * bytesPerPixel)];
|
2014-09-17 01:41:24 +04:00
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
2014-09-18 02:43:42 +04:00
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel);
|
2014-09-17 01:41:24 +04:00
|
|
|
pSrcPixel -= nStep;
|
|
|
|
pDstPixel -= nStep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nYSrc > nYDst)
|
|
|
|
{
|
|
|
|
/* copy up */
|
|
|
|
|
2014-09-18 02:43:42 +04:00
|
|
|
pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * bytesPerPixel)];
|
|
|
|
pDstPixel = &pData[(nYDst * nStep) + (nXDst * bytesPerPixel)];
|
2014-09-17 01:41:24 +04:00
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
2014-09-18 02:43:42 +04:00
|
|
|
CopyMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel);
|
2014-09-17 01:41:24 +04:00
|
|
|
pSrcPixel += nStep;
|
|
|
|
pDstPixel += nStep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nXSrc > nXDst)
|
|
|
|
{
|
|
|
|
/* copy left */
|
|
|
|
|
2014-09-18 02:43:42 +04:00
|
|
|
pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * bytesPerPixel)];
|
|
|
|
pDstPixel = &pData[(nYDst * nStep) + (nXDst * bytesPerPixel)];
|
2014-09-17 01:41:24 +04:00
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
2014-09-18 02:43:42 +04:00
|
|
|
MoveMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel);
|
2014-09-17 01:41:24 +04:00
|
|
|
pSrcPixel += nStep;
|
|
|
|
pDstPixel += nStep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* copy right */
|
|
|
|
|
2014-09-18 02:43:42 +04:00
|
|
|
pSrcPixel = &pData[(nYSrc * nStep) + (nXSrc * bytesPerPixel)];
|
|
|
|
pDstPixel = &pData[(nYDst * nStep) + (nXDst * bytesPerPixel)];
|
2014-09-17 01:41:24 +04:00
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
2014-09-18 02:43:42 +04:00
|
|
|
MoveMemory(pDstPixel, pSrcPixel, nWidth * bytesPerPixel);
|
2014-09-17 01:41:24 +04:00
|
|
|
pSrcPixel += nStep;
|
|
|
|
pDstPixel += nStep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-13 16:36:09 +04:00
|
|
|
void* freerdp_image_memset32(UINT32* ptr, UINT32 fill, size_t length)
|
|
|
|
{
|
|
|
|
while (length--)
|
|
|
|
{
|
|
|
|
*ptr++ = fill;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (void*) ptr;
|
|
|
|
}
|
|
|
|
|
2014-09-15 22:59:45 +04:00
|
|
|
int freerdp_image_fill(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
2014-06-13 16:36:09 +04:00
|
|
|
int nWidth, int nHeight, UINT32 color)
|
|
|
|
{
|
|
|
|
int y;
|
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
|
|
|
|
2014-09-15 22:59:45 +04:00
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
2014-06-13 16:36:09 +04:00
|
|
|
|
|
|
|
if (dstBytesPerPixel == 4)
|
|
|
|
{
|
|
|
|
UINT32* pDstPixel;
|
|
|
|
|
|
|
|
if (nDstStep < 0)
|
|
|
|
nDstStep = dstBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
pDstPixel = (UINT32*) &pDstData[((nYDst + y) * nDstStep) + (nXDst * dstBytesPerPixel)];
|
|
|
|
freerdp_image_memset32(pDstPixel, color, nWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 3)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (dstBytesPerPixel == 2)
|
|
|
|
{
|
|
|
|
if (dstBitsPerPixel == 16)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (dstBitsPerPixel == 15)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-15 04:08:38 +04:00
|
|
|
int freerdp_image_copy_from_retina(BYTE* pDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst,
|
|
|
|
int nWidth, int nHeight, BYTE* pSrcData, int nSrcStep, int nXSrc, int nYSrc)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int nSrcPad;
|
|
|
|
int nDstPad;
|
|
|
|
int srcBitsPerPixel;
|
|
|
|
int srcBytesPerPixel;
|
|
|
|
int dstBitsPerPixel;
|
|
|
|
int dstBytesPerPixel;
|
|
|
|
|
|
|
|
srcBitsPerPixel = 24;
|
|
|
|
srcBytesPerPixel = 8;
|
|
|
|
|
|
|
|
if (nSrcStep < 0)
|
|
|
|
nSrcStep = srcBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
|
|
|
|
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
|
|
|
|
|
|
|
|
if (nDstStep < 0)
|
|
|
|
nDstStep = dstBytesPerPixel * nWidth;
|
|
|
|
|
|
|
|
nSrcPad = (nSrcStep - (nWidth * srcBytesPerPixel));
|
|
|
|
nDstPad = (nDstStep - (nWidth * dstBytesPerPixel));
|
|
|
|
|
|
|
|
if (dstBytesPerPixel == 4)
|
|
|
|
{
|
|
|
|
UINT32 R, G, B;
|
|
|
|
BYTE* pSrcPixel;
|
|
|
|
BYTE* pDstPixel;
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
|
|
|
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
|
|
|
|
|
|
|
for (y = 0; y < nHeight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < nWidth; x++)
|
|
|
|
{
|
|
|
|
/* simple box filter scaling, could be improved with better algorithm */
|
|
|
|
|
|
|
|
B = pSrcPixel[0] + pSrcPixel[4] + pSrcPixel[nSrcStep + 0] + pSrcPixel[nSrcStep + 4];
|
|
|
|
G = pSrcPixel[1] + pSrcPixel[5] + pSrcPixel[nSrcStep + 1] + pSrcPixel[nSrcStep + 5];
|
|
|
|
R = pSrcPixel[2] + pSrcPixel[6] + pSrcPixel[nSrcStep + 2] + pSrcPixel[nSrcStep + 6];
|
|
|
|
pSrcPixel += 8;
|
|
|
|
|
|
|
|
*pDstPixel++ = (BYTE) (B >> 2);
|
|
|
|
*pDstPixel++ = (BYTE) (G >> 2);
|
|
|
|
*pDstPixel++ = (BYTE) (R >> 2);
|
|
|
|
*pDstPixel++ = 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSrcPixel = &pSrcPixel[nSrcPad + nSrcStep];
|
|
|
|
pDstPixel = &pDstPixel[nDstPad];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|