Refactored color.h

* Remove implementations from header
* Rename functions to be FreeRDP specific
* Add deprecation define for old names
* Fixed missing includes
This commit is contained in:
akallabeth 2022-04-28 05:43:31 +02:00 committed by akallabeth
parent d3e1810473
commit fb90ac280a
53 changed files with 985 additions and 922 deletions

View File

@ -1156,7 +1156,7 @@ BOOL mf_Pointer_New(rdpContext *context, rdpPointer *pointer)
isPlanar:NO isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:0 bitmapFormat:0
bytesPerRow:rect.size.width * GetBytesPerPixel(format) bytesPerRow:rect.size.width * FreeRDPGetBytesPerPixel(format)
bitsPerPixel:0]; bitsPerPixel:0];
mrdpCursor->bmiRep = bmiRep; mrdpCursor->bmiRep = bmiRep;
/* create an image using above representation */ /* create an image using above representation */
@ -1242,7 +1242,7 @@ CGContextRef mac_create_bitmap_context(rdpContext *context)
{ {
CGContextRef bitmap_context; CGContextRef bitmap_context;
rdpGdi *gdi = context->gdi; rdpGdi *gdi = context->gdi;
UINT32 bpp = GetBytesPerPixel(gdi->dstFormat); UINT32 bpp = FreeRDPGetBytesPerPixel(gdi->dstFormat);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
if (bpp == 2) if (bpp == 2)

View File

@ -80,7 +80,7 @@ static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor, COLORREF* col
if (format) if (format)
*format = SrcFormat; *format = SrcFormat;
switch (GetBitsPerPixel(gdi->dstFormat)) switch (FreeRDPGetBitsPerPixel(gdi->dstFormat))
{ {
case 32: case 32:
DstFormat = PIXEL_FORMAT_ABGR32; DstFormat = PIXEL_FORMAT_ABGR32;

View File

@ -50,7 +50,7 @@ HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height, UINT32 srcFor
bmi.bmiHeader.biWidth = width; bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = negHeight; bmi.bmiHeader.biHeight = negHeight;
bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = GetBitsPerPixel(dstFormat); bmi.bmiHeader.biBitCount = FreeRDPGetBitsPerPixel(dstFormat);
bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biCompression = BI_RGB;
bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&cdata, NULL, 0); bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&cdata, NULL, 0);

View File

@ -34,6 +34,7 @@
#include "xf_disp.h" #include "xf_disp.h"
#include "xf_monitor.h" #include "xf_monitor.h"
#include <freerdp/log.h>
#define TAG CLIENT_TAG("x11disp") #define TAG CLIENT_TAG("x11disp")
#define RESIZE_MIN_DELAY 200 /* minimum delay in ms between two resizes */ #define RESIZE_MIN_DELAY 200 /* minimum delay in ms between two resizes */

View File

@ -30,6 +30,7 @@
#include "resource/minimize.xbm" #include "resource/minimize.xbm"
#include "resource/restore.xbm" #include "resource/restore.xbm"
#include <freerdp/log.h>
#define TAG CLIENT_TAG("x11") #define TAG CLIENT_TAG("x11")
#define FLOATBAR_HEIGHT 26 #define FLOATBAR_HEIGHT 26

View File

@ -1078,7 +1078,7 @@ static BOOL xf_gdi_surface_bits(rdpContext* context, const SURFACE_BITS_COMMAND*
case RDP_CODEC_ID_NONE: case RDP_CODEC_ID_NONE:
pSrcData = cmd->bmp.bitmapData; pSrcData = cmd->bmp.bitmapData;
format = gdi_get_pixel_format(cmd->bmp.bpp); format = gdi_get_pixel_format(cmd->bmp.bpp);
size = cmd->bmp.width * cmd->bmp.height * GetBytesPerPixel(format) * 1ULL; size = cmd->bmp.width * cmd->bmp.height * FreeRDPGetBytesPerPixel(format) * 1ULL;
if (size > cmd->bmp.bitmapDataLength) if (size > cmd->bmp.bitmapDataLength)
{ {
WLog_ERR(TAG, "Short nocodec message: got %" PRIu32 " bytes, require %" PRIuz, WLog_ERR(TAG, "Short nocodec message: got %" PRIu32 " bytes, require %" PRIuz,

View File

@ -302,7 +302,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
goto out_free; goto out_free;
} }
surface->gdi.scanline = surface->gdi.width * GetBytesPerPixel(surface->gdi.format); surface->gdi.scanline = surface->gdi.width * FreeRDPGetBytesPerPixel(surface->gdi.format);
surface->gdi.scanline = x11_pad_scanline(surface->gdi.scanline, xfc->scanline_pad); surface->gdi.scanline = x11_pad_scanline(surface->gdi.scanline, xfc->scanline_pad);
size = surface->gdi.scanline * surface->gdi.height * 1ULL; size = surface->gdi.scanline * surface->gdi.height * 1ULL;
surface->gdi.data = (BYTE*)_aligned_malloc(size, 16); surface->gdi.data = (BYTE*)_aligned_malloc(size, 16);
@ -325,7 +325,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
else else
{ {
UINT32 width = surface->gdi.width; UINT32 width = surface->gdi.width;
UINT32 bytes = GetBytesPerPixel(gdi->dstFormat); UINT32 bytes = FreeRDPGetBytesPerPixel(gdi->dstFormat);
surface->stageScanline = width * bytes; surface->stageScanline = width * bytes;
surface->stageScanline = x11_pad_scanline(surface->stageScanline, xfc->scanline_pad); surface->stageScanline = x11_pad_scanline(surface->stageScanline, xfc->scanline_pad);
size = surface->stageScanline * surface->gdi.height * 1ULL; size = surface->stageScanline * surface->gdi.height * 1ULL;

View File

@ -84,7 +84,7 @@ BOOL xf_decode_color(xfContext* xfc, const UINT32 srcColor, XColor* color)
return FALSE; return FALSE;
} }
SplitColor(srcColor, SrcFormat, &r, &g, &b, &a, &gdi->palette); FreeRDPSplitColor(srcColor, SrcFormat, &r, &g, &b, &a, &gdi->palette);
color->blue = (unsigned short)(b << 8); color->blue = (unsigned short)(b << 8);
color->green = (unsigned short)(g << 8); color->green = (unsigned short)(g << 8);
color->red = (unsigned short)(r << 8); color->red = (unsigned short)(r << 8);
@ -111,7 +111,7 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
gdi = context->gdi; gdi = context->gdi;
xf_lock_x11(xfc); xf_lock_x11(xfc);
depth = GetBitsPerPixel(bitmap->format); depth = FreeRDPGetBitsPerPixel(bitmap->format);
xbitmap->pixmap = xbitmap->pixmap =
XCreatePixmap(xfc->display, xfc->drawable, bitmap->width, bitmap->height, xfc->depth); XCreatePixmap(xfc->display, xfc->drawable, bitmap->width, bitmap->height, xfc->depth);
@ -310,7 +310,7 @@ static BOOL _xf_Pointer_GetCursorForCurrentScale(rdpContext* context, const rdpP
ci.height = yTargetSize; ci.height = yTargetSize;
ci.xhot = pointer->xPos * xscale; ci.xhot = pointer->xPos * xscale;
ci.yhot = pointer->yPos * yscale; ci.yhot = pointer->yPos * yscale;
size = ci.height * ci.width * GetBytesPerPixel(CursorFormat) * 1ULL; size = ci.height * ci.width * FreeRDPGetBytesPerPixel(CursorFormat) * 1ULL;
tmp = _aligned_malloc(size, 16); tmp = _aligned_malloc(size, 16);
if (!tmp) if (!tmp)
@ -399,7 +399,7 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
xpointer->nCursors = 0; xpointer->nCursors = 0;
xpointer->mCursors = 0; xpointer->mCursors = 0;
size = pointer->height * pointer->width * GetBytesPerPixel(CursorFormat) * 1ULL; size = pointer->height * pointer->width * FreeRDPGetBytesPerPixel(CursorFormat) * 1ULL;
if (!(xpointer->cursorPixels = (XcursorPixel*)_aligned_malloc(size, 16))) if (!(xpointer->cursorPixels = (XcursorPixel*)_aligned_malloc(size, 16)))
return FALSE; return FALSE;

View File

@ -32,6 +32,7 @@
#include "xf_window.h" #include "xf_window.h"
#include "xf_rail.h" #include "xf_rail.h"
#include <freerdp/log.h>
#define TAG CLIENT_TAG("x11") #define TAG CLIENT_TAG("x11")
static const char* error_code_names[] = { "RAIL_EXEC_S_OK", static const char* error_code_names[] = { "RAIL_EXEC_S_OK",
@ -634,7 +635,7 @@ static BOOL convert_rail_icon(const ICON_INFO* iconInfo, xfRailIcon* railIcon)
for (i = 2; i < nelements; i++) for (i = 2; i < nelements; i++)
{ {
pixels[i] = ReadColor(nextPixel, PIXEL_FORMAT_BGRA32); pixels[i] = FreeRDPReadColor(nextPixel, PIXEL_FORMAT_BGRA32);
nextPixel += 4; nextPixel += 4;
} }

View File

@ -24,6 +24,7 @@
#include "xf_video.h" #include "xf_video.h"
#include <freerdp/log.h>
#define TAG CLIENT_TAG("video") #define TAG CLIENT_TAG("video")
typedef struct typedef struct

View File

@ -176,7 +176,7 @@ static void ios_create_bitmap_context(mfInfo *mfi)
rdpGdi *gdi = mfi->instance->context->gdi; rdpGdi *gdi = mfi->instance->context->gdi;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
if (GetBytesPerPixel(gdi->dstFormat) == 2) if (FreeRDPGetBytesPerPixel(gdi->dstFormat) == 2)
mfi->bitmap_context = CGBitmapContextCreate( mfi->bitmap_context = CGBitmapContextCreate(
gdi->primary_buffer, gdi->width, gdi->height, 5, gdi->stride, colorSpace, gdi->primary_buffer, gdi->width, gdi->height, 5, gdi->stride, colorSpace,
kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst); kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst);

View File

@ -23,9 +23,6 @@
#define FREERDP_CODEC_COLOR_H #define FREERDP_CODEC_COLOR_H
#include <freerdp/api.h> #include <freerdp/api.h>
#include <winpr/wlog.h>
#include <freerdp/log.h>
#define CTAG FREERDP_TAG("codec.color")
#define FREERDP_PIXEL_FORMAT_TYPE_A 0 #define FREERDP_PIXEL_FORMAT_TYPE_A 0
#define FREERDP_PIXEL_FORMAT_TYPE_ARGB 1 #define FREERDP_PIXEL_FORMAT_TYPE_ARGB 1
@ -50,8 +47,8 @@
* The format naming scheme is based on byte position in memory. * The format naming scheme is based on byte position in memory.
* RGBA for example names a byte array with red on positon 0, green on 1 etc. * RGBA for example names a byte array with red on positon 0, green on 1 etc.
* *
* To read and write the appropriate format from / to memory use ReadColor and * To read and write the appropriate format from / to memory use FreeRDPReadColor and
* WriteColor. * FreeRDPWriteColor.
* *
* The single pixel manipulation functions use an intermediate integer representation * The single pixel manipulation functions use an intermediate integer representation
* that must not be interpreted outside the functions as it is platform dependent. * that must not be interpreted outside the functions as it is platform dependent.
@ -122,83 +119,10 @@ extern "C"
* *
* @return A string representation of format * @return A string representation of format
*/ */
static const char* FreeRDPGetColorFormatName(UINT32 format) #if defined(WITH_FREERDP_DEPRECATED)
{ #define GetColorFormatName(...) FreeRDPGetColorFormatName(__VA_ARGS__)
switch (format) #endif
{ FREERDP_API const char* FreeRDPGetColorFormatName(UINT32 format);
/* 32bpp formats */
case PIXEL_FORMAT_ARGB32:
return "PIXEL_FORMAT_ARGB32";
case PIXEL_FORMAT_XRGB32:
return "PIXEL_FORMAT_XRGB32";
case PIXEL_FORMAT_ABGR32:
return "PIXEL_FORMAT_ABGR32";
case PIXEL_FORMAT_XBGR32:
return "PIXEL_FORMAT_XBGR32";
case PIXEL_FORMAT_BGRA32:
return "PIXEL_FORMAT_BGRA32";
case PIXEL_FORMAT_BGRX32:
return "PIXEL_FORMAT_BGRX32";
case PIXEL_FORMAT_RGBA32:
return "PIXEL_FORMAT_RGBA32";
case PIXEL_FORMAT_RGBX32:
return "PIXEL_FORMAT_RGBX32";
case PIXEL_FORMAT_BGRX32_DEPTH30:
return "PIXEL_FORMAT_BGRX32_DEPTH30";
case PIXEL_FORMAT_RGBX32_DEPTH30:
return "PIXEL_FORMAT_RGBX32_DEPTH30";
/* 24bpp formats */
case PIXEL_FORMAT_RGB24:
return "PIXEL_FORMAT_RGB24";
case PIXEL_FORMAT_BGR24:
return "PIXEL_FORMAT_BGR24";
/* 16bpp formats */
case PIXEL_FORMAT_RGB16:
return "PIXEL_FORMAT_RGB16";
case PIXEL_FORMAT_BGR16:
return "PIXEL_FORMAT_BGR16";
case PIXEL_FORMAT_ARGB15:
return "PIXEL_FORMAT_ARGB15";
case PIXEL_FORMAT_RGB15:
return "PIXEL_FORMAT_RGB15";
case PIXEL_FORMAT_ABGR15:
return "PIXEL_FORMAT_ABGR15";
case PIXEL_FORMAT_BGR15:
return "PIXEL_FORMAT_BGR15";
/* 8bpp formats */
case PIXEL_FORMAT_RGB8:
return "PIXEL_FORMAT_RGB8";
/* 4 bpp formats */
case PIXEL_FORMAT_A4:
return "PIXEL_FORMAT_A4";
/* 1bpp formats */
case PIXEL_FORMAT_MONO:
return "PIXEL_FORMAT_MONO";
default:
return "UNKNOWN";
}
}
/*** /***
* *
@ -213,388 +137,11 @@ extern "C"
* @param _a alpha color value * @param _a alpha color value
* @param palette pallete to use (only used for 8 bit color!) * @param palette pallete to use (only used for 8 bit color!)
*/ */
static INLINE void SplitColor(UINT32 color, UINT32 format, BYTE* _r, BYTE* _g, BYTE* _b, #if defined(WITH_FREERDP_DEPRECATED)
BYTE* _a, const gdiPalette* palette) #define SplitColor(...) FreeRDPSplitColor(__VA_ARGS__)
{ #endif
UINT32 tmp; FREERDP_API void FreeRDPSplitColor(UINT32 color, UINT32 format, BYTE* _r, BYTE* _g, BYTE* _b,
BYTE* _a, const gdiPalette* palette);
switch (format)
{
/* 32bpp formats */
case PIXEL_FORMAT_ARGB32:
if (_a)
*_a = (BYTE)(color >> 24);
if (_r)
*_r = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_b)
*_b = (BYTE)color;
break;
case PIXEL_FORMAT_XRGB32:
if (_r)
*_r = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_b)
*_b = (BYTE)color;
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_ABGR32:
if (_a)
*_a = (BYTE)(color >> 24);
if (_b)
*_b = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_r)
*_r = (BYTE)color;
break;
case PIXEL_FORMAT_XBGR32:
if (_b)
*_b = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_r)
*_r = (BYTE)color;
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_RGBA32:
if (_r)
*_r = (BYTE)(color >> 24);
if (_g)
*_g = (BYTE)(color >> 16);
if (_b)
*_b = (BYTE)(color >> 8);
if (_a)
*_a = (BYTE)color;
break;
case PIXEL_FORMAT_RGBX32:
if (_r)
*_r = (BYTE)(color >> 24);
if (_g)
*_g = (BYTE)(color >> 16);
if (_b)
*_b = (BYTE)(color >> 8);
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_BGRA32:
if (_b)
*_b = (BYTE)(color >> 24);
if (_g)
*_g = (BYTE)(color >> 16);
if (_r)
*_r = (BYTE)(color >> 8);
if (_a)
*_a = (BYTE)color;
break;
case PIXEL_FORMAT_BGRX32:
if (_b)
*_b = (BYTE)(color >> 24);
if (_g)
*_g = (BYTE)(color >> 16);
if (_r)
*_r = (BYTE)(color >> 8);
if (_a)
*_a = 0xFF;
break;
/* 24bpp formats */
case PIXEL_FORMAT_RGB24:
if (_r)
*_r = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_b)
*_b = (BYTE)color;
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_BGR24:
if (_b)
*_b = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_r)
*_r = (BYTE)color;
if (_a)
*_a = 0xFF;
break;
/* 16bpp formats */
case PIXEL_FORMAT_RGB16:
if (_r)
{
const UINT32 c = (color >> 11) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x3F;
const UINT32 val = (c << 2) + c / 4 / 2;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_BGR16:
if (_r)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x3F;
const UINT32 val = (c << 2) + c / 4 / 2;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color >> 11) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_ARGB15:
if (_r)
{
const UINT32 c = (color >> 10) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = color & 0x8000 ? 0xFF : 0x00;
break;
case PIXEL_FORMAT_ABGR15:
if (_r)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color >> 10) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = color & 0x8000 ? 0xFF : 0x00;
break;
/* 15bpp formats */
case PIXEL_FORMAT_RGB15:
if (_r)
{
const UINT32 c = (color >> 10) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_BGR15:
if (_r)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color >> 10) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = 0xFF;
break;
/* 8bpp formats */
case PIXEL_FORMAT_RGB8:
if (color <= 0xFF)
{
tmp = palette->palette[color];
SplitColor(tmp, palette->format, _r, _g, _b, _a, NULL);
}
else
{
if (_r)
*_r = 0x00;
if (_g)
*_g = 0x00;
if (_b)
*_b = 0x00;
if (_a)
*_a = 0x00;
}
break;
/* 1bpp formats */
case PIXEL_FORMAT_MONO:
if (_r)
*_r = (color) ? 0xFF : 0x00;
if (_g)
*_g = (color) ? 0xFF : 0x00;
if (_b)
*_b = (color) ? 0xFF : 0x00;
if (_a)
*_a = (color) ? 0xFF : 0x00;
break;
/* 4 bpp formats */
case PIXEL_FORMAT_A4:
default:
if (_r)
*_r = 0x00;
if (_g)
*_g = 0x00;
if (_b)
*_b = 0x00;
if (_a)
*_a = 0x00;
WLog_ERR(CTAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
break;
}
}
/*** /***
* *
@ -609,95 +156,10 @@ extern "C"
* @return The pixel color in the desired format. Value is in internal * @return The pixel color in the desired format. Value is in internal
* representation. * representation.
*/ */
static INLINE UINT32 FreeRDPGetColor(UINT32 format, BYTE r, BYTE g, BYTE b, BYTE a) #if defined(WITH_FREERDP_DEPRECATED)
{ #define GetColor(...) FreeRDPGetColor(__VA_ARGS__)
UINT32 _r = r; #endif
UINT32 _g = g; FREERDP_API UINT32 FreeRDPGetColor(UINT32 format, BYTE r, BYTE g, BYTE b, BYTE a);
UINT32 _b = b;
UINT32 _a = a;
UINT32 t;
switch (format)
{
/* 32bpp formats */
case PIXEL_FORMAT_ARGB32:
return (_a << 24) | (_r << 16) | (_g << 8) | _b;
case PIXEL_FORMAT_XRGB32:
return (_r << 16) | (_g << 8) | _b;
case PIXEL_FORMAT_ABGR32:
return (_a << 24) | (_b << 16) | (_g << 8) | _r;
case PIXEL_FORMAT_XBGR32:
return (_b << 16) | (_g << 8) | _r;
case PIXEL_FORMAT_RGBA32:
return (_r << 24) | (_g << 16) | (_b << 8) | _a;
case PIXEL_FORMAT_RGBX32:
return (_r << 24) | (_g << 16) | (_b << 8) | _a;
case PIXEL_FORMAT_BGRA32:
return (_b << 24) | (_g << 16) | (_r << 8) | _a;
case PIXEL_FORMAT_BGRX32:
return (_b << 24) | (_g << 16) | (_r << 8) | _a;
case PIXEL_FORMAT_RGBX32_DEPTH30:
// TODO: Not tested
t = (_r << 22) | (_g << 12) | (_b << 2);
// NOTE: Swapping byte-order because WriteColor written UINT32 in big-endian
return ((t & 0xff) << 24) | (((t >> 8) & 0xff) << 16) | (((t >> 16) & 0xff) << 8) | (t >> 24);
case PIXEL_FORMAT_BGRX32_DEPTH30:
// NOTE: Swapping b and r channel (unknown reason)
t = (_r << 22) | (_g << 12) | (_b << 2);
// NOTE: Swapping byte-order because WriteColor written UINT32 in big-endian
return ((t & 0xff) << 24) | (((t >> 8) & 0xff) << 16) | (((t >> 16) & 0xff) << 8) | (t >> 24);
/* 24bpp formats */
case PIXEL_FORMAT_RGB24:
return (_r << 16) | (_g << 8) | _b;
case PIXEL_FORMAT_BGR24:
return (_b << 16) | (_g << 8) | _r;
/* 16bpp formats */
case PIXEL_FORMAT_RGB16:
return (((_r >> 3) & 0x1F) << 11) | (((_g >> 2) & 0x3F) << 5) | ((_b >> 3) & 0x1F);
case PIXEL_FORMAT_BGR16:
return (((_b >> 3) & 0x1F) << 11) | (((_g >> 2) & 0x3F) << 5) | ((_r >> 3) & 0x1F);
case PIXEL_FORMAT_ARGB15:
return (((_r >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_b >> 3) & 0x1F) |
(_a ? 0x8000 : 0x0000);
case PIXEL_FORMAT_ABGR15:
return (((_b >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_r >> 3) & 0x1F) |
(_a ? 0x8000 : 0x0000);
/* 15bpp formats */
case PIXEL_FORMAT_RGB15:
return (((_r >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_b >> 3) & 0x1F);
case PIXEL_FORMAT_BGR15:
return (((_b >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_r >> 3) & 0x1F);
/* 8bpp formats */
case PIXEL_FORMAT_RGB8:
/* 4 bpp formats */
case PIXEL_FORMAT_A4:
/* 1bpp formats */
case PIXEL_FORMAT_MONO:
default:
WLog_ERR(CTAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
return 0;
}
}
/*** /***
* *
@ -707,7 +169,10 @@ extern "C"
* *
* @return The number of bits the format requires per pixel. * @return The number of bits the format requires per pixel.
*/ */
static INLINE UINT32 GetBitsPerPixel(UINT32 format) #if defined(WITH_FREERDP_DEPRECATED)
#define GetBitsPerPixel(...) FreeRDPGetBitsPerPixel(__VA_ARGS__)
#endif
static INLINE UINT32 FreeRDPGetBitsPerPixel(UINT32 format)
{ {
return (((format) >> 24) & 0x3F); return (((format) >> 24) & 0x3F);
} }
@ -717,7 +182,10 @@ extern "C"
* *
* @return TRUE if the format has an alpha channel, FALSE otherwise. * @return TRUE if the format has an alpha channel, FALSE otherwise.
*/ */
static INLINE BOOL ColorHasAlpha(UINT32 format) #if defined(WITH_FREERDP_DEPRECATED)
#define ColorHasAlpha(...) FreeRDPColorHasAlpha(__VA_ARGS__)
#endif
static INLINE BOOL FreeRDPColorHasAlpha(UINT32 format)
{ {
UINT32 alpha = (((format) >> 12) & 0x0F); UINT32 alpha = (((format) >> 12) & 0x0F);
@ -736,47 +204,10 @@ extern "C"
* *
* @return The pixel color in internal representation * @return The pixel color in internal representation
*/ */
static INLINE UINT32 ReadColor(const BYTE* src, UINT32 format) #if defined(WITH_FREERDP_DEPRECATED)
{ #define ReadColor(...) FreeRDPReadColor(__VA_ARGS__)
UINT32 color; #endif
FREERDP_API UINT32 FreeRDPReadColor(const BYTE* src, UINT32 format);
switch (GetBitsPerPixel(format))
{
case 32:
color = ((UINT32)src[0] << 24) | ((UINT32)src[1] << 16) | ((UINT32)src[2] << 8) |
src[3];
break;
case 24:
color = ((UINT32)src[0] << 16) | ((UINT32)src[1] << 8) | src[2];
break;
case 16:
color = ((UINT32)src[1] << 8) | src[0];
break;
case 15:
color = ((UINT32)src[1] << 8) | src[0];
if (!ColorHasAlpha(format))
color = color & 0x7FFF;
break;
case 8:
case 4:
case 1:
color = *src;
break;
default:
WLog_ERR(CTAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
color = 0;
break;
}
return color;
}
/*** /***
* *
@ -788,68 +219,12 @@ extern "C"
* *
* @return TRUE if successful, FALSE otherwise * @return TRUE if successful, FALSE otherwise
*/ */
static INLINE BOOL WriteColor(BYTE* dst, UINT32 format, UINT32 color) #if defined(WITH_FREERDP_DEPRECATED)
{ #define WriteColor(...) FreeRDPWriteColor(__VA_ARGS__)
switch (GetBitsPerPixel(format)) #define WriteColorIgnoreAlpha(...) FreeRDPWriteColorIgnoreAlpha(__VA_ARGS__)
{ #endif
case 32: FREERDP_API BOOL FreeRDPWriteColor(BYTE* dst, UINT32 format, UINT32 color);
dst[0] = (BYTE)(color >> 24); FREERDP_API BOOL FreeRDPWriteColorIgnoreAlpha(BYTE* dst, UINT32 format, UINT32 color);
dst[1] = (BYTE)(color >> 16);
dst[2] = (BYTE)(color >> 8);
dst[3] = (BYTE)color;
break;
case 24:
dst[0] = (BYTE)(color >> 16);
dst[1] = (BYTE)(color >> 8);
dst[2] = (BYTE)color;
break;
case 16:
dst[1] = (BYTE)(color >> 8);
dst[0] = (BYTE)color;
break;
case 15:
if (!ColorHasAlpha(format))
color = color & 0x7FFF;
dst[1] = (BYTE)(color >> 8);
dst[0] = (BYTE)color;
break;
case 8:
dst[0] = (BYTE)color;
break;
default:
WLog_ERR(CTAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
return FALSE;
}
return TRUE;
}
static INLINE BOOL WriteColorIgnoreAlpha(BYTE* dst, UINT32 format, UINT32 color)
{
switch (format)
{
case PIXEL_FORMAT_ABGR32:
case PIXEL_FORMAT_ARGB32:
{
const UINT32 tmp = ((UINT32)dst[0] << 24ULL) | (color & 0x00FFFFFFULL);
return WriteColor(dst, format, tmp);
}
case PIXEL_FORMAT_BGRA32:
case PIXEL_FORMAT_RGBA32:
{
const UINT32 tmp = ((UINT32)dst[3]) | (color & 0xFFFFFF00ULL);
return WriteColor(dst, format, tmp);
}
default:
return WriteColor(dst, format, color);
}
}
/*** /***
* *
@ -863,6 +238,9 @@ extern "C"
* *
* @return The converted pixel color in dstFormat representation * @return The converted pixel color in dstFormat representation
*/ */
#if defined(WITH_FREERDP_DEPRECATED)
#define ConvertColor(...) FreeRDPConvertColor(__VA_ARGS__)
#endif
static INLINE UINT32 FreeRDPConvertColor(UINT32 color, UINT32 srcFormat, UINT32 dstFormat, static INLINE UINT32 FreeRDPConvertColor(UINT32 color, UINT32 srcFormat, UINT32 dstFormat,
const gdiPalette* palette) const gdiPalette* palette)
{ {
@ -870,7 +248,7 @@ extern "C"
BYTE g = 0; BYTE g = 0;
BYTE b = 0; BYTE b = 0;
BYTE a = 0; BYTE a = 0;
SplitColor(color, srcFormat, &r, &g, &b, &a, palette); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, &a, palette);
return FreeRDPGetColor(dstFormat, r, g, b, a); return FreeRDPGetColor(dstFormat, r, g, b, a);
} }
@ -882,9 +260,12 @@ extern "C"
* *
* @return The number of bytes the format requires per pixel. * @return The number of bytes the format requires per pixel.
*/ */
static INLINE UINT32 GetBytesPerPixel(UINT32 format) #if defined(WITH_FREERDP_DEPRECATED)
#define GetBytesPerPixel(...) FreeRDPGetBytesPerPixel(__VA_ARGS__)
#endif
static INLINE UINT32 FreeRDPGetBytesPerPixel(UINT32 format)
{ {
return (GetBitsPerPixel(format) + 7) / 8; return (FreeRDPGetBitsPerPixel(format) + 7) / 8;
} }
/*** /***
@ -1039,12 +420,6 @@ extern "C"
UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
UINT32 color); UINT32 color);
#if !defined(__APPLE__)
#define GetColorFormatName FreeRDPGetColorFormatName
#define GetColor FreeRDPGetColor
#define ConvertColor FreeRDPConvertColor
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -230,11 +230,11 @@ static BOOL clear_decompress_subcode_rlex(wStream* s, UINT32 bitmapDataByteCount
for (i = 0; i < runLengthFactor; i++) for (i = 0; i < runLengthFactor; i++)
{ {
BYTE* pTmpData = BYTE* pTmpData = &pDstData[(nXDstRel + x) * FreeRDPGetBytesPerPixel(DstFormat) +
&pDstData[(nXDstRel + x) * GetBytesPerPixel(DstFormat) + (nYDstRel + y) * nDstStep]; (nYDstRel + y) * nDstStep];
if ((nXDstRel + x < nDstWidth) && (nYDstRel + y < nDstHeight)) if ((nXDstRel + x < nDstWidth) && (nYDstRel + y < nDstHeight))
WriteColor(pTmpData, DstFormat, color); FreeRDPWriteColor(pTmpData, DstFormat, color);
if (++x >= width) if (++x >= width)
{ {
@ -255,8 +255,8 @@ static BOOL clear_decompress_subcode_rlex(wStream* s, UINT32 bitmapDataByteCount
for (i = 0; i <= suiteDepth; i++) for (i = 0; i <= suiteDepth; i++)
{ {
BYTE* pTmpData = BYTE* pTmpData = &pDstData[(nXDstRel + x) * FreeRDPGetBytesPerPixel(DstFormat) +
&pDstData[(nXDstRel + x) * GetBytesPerPixel(DstFormat) + (nYDstRel + y) * nDstStep]; (nYDstRel + y) * nDstStep];
UINT32 ccolor = palette[suiteIndex]; UINT32 ccolor = palette[suiteIndex];
if (suiteIndex > 127) if (suiteIndex > 127)
@ -268,7 +268,7 @@ static BOOL clear_decompress_subcode_rlex(wStream* s, UINT32 bitmapDataByteCount
suiteIndex++; suiteIndex++;
if ((nXDstRel + x < nDstWidth) && (nYDstRel + y < nDstHeight)) if ((nXDstRel + x < nDstWidth) && (nYDstRel + y < nDstHeight))
WriteColor(pTmpData, DstFormat, ccolor); FreeRDPWriteColor(pTmpData, DstFormat, ccolor);
if (++x >= width) if (++x >= width)
{ {
@ -296,7 +296,7 @@ static BOOL clear_resize_buffer(CLEAR_CONTEXT* clear, UINT32 width, UINT32 heigh
if (!clear) if (!clear)
return FALSE; return FALSE;
size = ((width + 16) * (height + 16) * GetBytesPerPixel(clear->format)); size = ((width + 16) * (height + 16) * FreeRDPGetBytesPerPixel(clear->format));
if (size > clear->TempSize) if (size > clear->TempSize)
{ {
@ -385,14 +385,14 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear, wStream* s,
for (i = 0; i < runLengthFactor; i++) for (i = 0; i < runLengthFactor; i++)
{ {
WriteColor(dstBuffer, clear->format, color); FreeRDPWriteColor(dstBuffer, clear->format, color);
dstBuffer += GetBytesPerPixel(clear->format); dstBuffer += FreeRDPGetBytesPerPixel(clear->format);
} }
pixelIndex += runLengthFactor; pixelIndex += runLengthFactor;
} }
nSrcStep = nWidth * GetBytesPerPixel(clear->format); nSrcStep = nWidth * FreeRDPGetBytesPerPixel(clear->format);
if (pixelIndex != pixelCount) if (pixelIndex != pixelCount)
{ {
@ -465,7 +465,7 @@ static BOOL clear_decompress_subcodecs_data(CLEAR_CONTEXT* clear, wStream* s,
{ {
case 0: /* Uncompressed */ case 0: /* Uncompressed */
{ {
UINT32 nSrcStep = width * GetBytesPerPixel(PIXEL_FORMAT_BGR24); UINT32 nSrcStep = width * FreeRDPGetBytesPerPixel(PIXEL_FORMAT_BGR24);
UINT32 nSrcSize = nSrcStep * height; UINT32 nSrcSize = nSrcStep * height;
if (bitmapDataByteCount != nSrcSize) if (bitmapDataByteCount != nSrcSize)
@ -514,7 +514,7 @@ static BOOL resize_vbar_entry(CLEAR_CONTEXT* clear, CLEAR_VBAR_ENTRY* vBarEntry)
{ {
if (vBarEntry->count > vBarEntry->size) if (vBarEntry->count > vBarEntry->size)
{ {
const UINT32 bpp = GetBytesPerPixel(clear->format); const UINT32 bpp = FreeRDPGetBytesPerPixel(clear->format);
const UINT32 oldPos = vBarEntry->size * bpp; const UINT32 oldPos = vBarEntry->size * bpp;
const UINT32 diffSize = (vBarEntry->count - vBarEntry->size) * bpp; const UINT32 diffSize = (vBarEntry->count - vBarEntry->size) * bpp;
BYTE* tmp; BYTE* tmp;
@ -679,14 +679,15 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear, wStream* s, UINT32
for (y = 0; y < vBarShortPixelCount; y++) for (y = 0; y < vBarShortPixelCount; y++)
{ {
BYTE r, g, b; BYTE r, g, b;
BYTE* dstBuffer = &vBarShortEntry->pixels[y * GetBytesPerPixel(clear->format)]; BYTE* dstBuffer =
&vBarShortEntry->pixels[y * FreeRDPGetBytesPerPixel(clear->format)];
UINT32 color; UINT32 color;
Stream_Read_UINT8(s, b); Stream_Read_UINT8(s, b);
Stream_Read_UINT8(s, g); Stream_Read_UINT8(s, g);
Stream_Read_UINT8(s, r); Stream_Read_UINT8(s, r);
color = FreeRDPGetColor(clear->format, r, g, b, 0xFF); color = FreeRDPGetColor(clear->format, r, g, b, 0xFF);
if (!WriteColor(dstBuffer, clear->format, color)) if (!FreeRDPWriteColor(dstBuffer, clear->format, color))
return FALSE; return FALSE;
} }
@ -748,8 +749,8 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear, wStream* s, UINT32
while (count--) while (count--)
{ {
WriteColor(dstBuffer, clear->format, colorBkg); FreeRDPWriteColor(dstBuffer, clear->format, colorBkg);
dstBuffer += GetBytesPerPixel(clear->format); dstBuffer += FreeRDPGetBytesPerPixel(clear->format);
} }
/* /*
@ -764,18 +765,19 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear, wStream* s, UINT32
if (count > 0) if (count > 0)
pSrcPixel = pSrcPixel =
&vBarShortEntry->pixels[(y - vBarYOn) * GetBytesPerPixel(clear->format)]; &vBarShortEntry
->pixels[(y - vBarYOn) * FreeRDPGetBytesPerPixel(clear->format)];
for (x = 0; x < count; x++) for (x = 0; x < count; x++)
{ {
UINT32 color; UINT32 color;
color = color = FreeRDPReadColor(&pSrcPixel[x * FreeRDPGetBytesPerPixel(clear->format)],
ReadColor(&pSrcPixel[x * GetBytesPerPixel(clear->format)], clear->format); clear->format);
if (!WriteColor(dstBuffer, clear->format, color)) if (!FreeRDPWriteColor(dstBuffer, clear->format, color))
return FALSE; return FALSE;
dstBuffer += GetBytesPerPixel(clear->format); dstBuffer += FreeRDPGetBytesPerPixel(clear->format);
} }
/* if (y >= (vBarYOn + vBarShortPixelCount)), use colorBkg */ /* if (y >= (vBarYOn + vBarShortPixelCount)), use colorBkg */
@ -784,10 +786,10 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear, wStream* s, UINT32
while (count--) while (count--)
{ {
if (!WriteColor(dstBuffer, clear->format, colorBkg)) if (!FreeRDPWriteColor(dstBuffer, clear->format, colorBkg))
return FALSE; return FALSE;
dstBuffer += GetBytesPerPixel(clear->format); dstBuffer += FreeRDPGetBytesPerPixel(clear->format);
} }
vBarEntry->count = vBarPixelCount; vBarEntry->count = vBarPixelCount;
@ -817,15 +819,16 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear, wStream* s, UINT32
for (y = 0; y < count; y++) for (y = 0; y < count; y++)
{ {
BYTE* pDstPixel8 = &pDstData[((nYDstRel + y) * nDstStep) + BYTE* pDstPixel8 =
((nXDstRel + i) * GetBytesPerPixel(DstFormat))]; &pDstData[((nYDstRel + y) * nDstStep) +
UINT32 color = ReadColor(cpSrcPixel, clear->format); ((nXDstRel + i) * FreeRDPGetBytesPerPixel(DstFormat))];
UINT32 color = FreeRDPReadColor(cpSrcPixel, clear->format);
color = FreeRDPConvertColor(color, clear->format, DstFormat, NULL); color = FreeRDPConvertColor(color, clear->format, DstFormat, NULL);
if (!WriteColor(pDstPixel8, DstFormat, color)) if (!FreeRDPWriteColor(pDstPixel8, DstFormat, color))
return FALSE; return FALSE;
cpSrcPixel += GetBytesPerPixel(clear->format); cpSrcPixel += FreeRDPGetBytesPerPixel(clear->format);
} }
} }
} }
@ -899,14 +902,14 @@ static BOOL clear_decompress_glyph_data(CLEAR_CONTEXT* clear, wStream* s, UINT32
return FALSE; return FALSE;
} }
nSrcStep = nWidth * GetBytesPerPixel(clear->format); nSrcStep = nWidth * FreeRDPGetBytesPerPixel(clear->format);
return convert_color(pDstData, nDstStep, DstFormat, nXDst, nYDst, nWidth, nHeight, return convert_color(pDstData, nDstStep, DstFormat, nXDst, nYDst, nWidth, nHeight,
glyphData, nSrcStep, clear->format, nDstWidth, nDstHeight, palette); glyphData, nSrcStep, clear->format, nDstWidth, nDstHeight, palette);
} }
if (glyphFlags & CLEARCODEC_FLAG_GLYPH_INDEX) if (glyphFlags & CLEARCODEC_FLAG_GLYPH_INDEX)
{ {
const UINT32 bpp = GetBytesPerPixel(clear->format); const UINT32 bpp = FreeRDPGetBytesPerPixel(clear->format);
CLEAR_GLYPH_ENTRY* glyphEntry = &(clear->GlyphCache[glyphIndex]); CLEAR_GLYPH_ENTRY* glyphEntry = &(clear->GlyphCache[glyphIndex]);
glyphEntry->count = nWidth * nHeight; glyphEntry->count = nWidth * nHeight;

View File

@ -89,7 +89,7 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* pDstData, UINT32 DstFormat, UINT32
UINT32 x, y; UINT32 x, y;
BOOL vFlip; BOOL vFlip;
UINT32 monoStep; UINT32 monoStep;
const UINT32 dstBytesPerPixel = GetBytesPerPixel(DstFormat); const UINT32 dstBytesPerPixel = FreeRDPGetBytesPerPixel(DstFormat);
if (!pDstData || !pSrcData || !palette) if (!pDstData || !pSrcData || !palette)
return FALSE; return FALSE;
@ -113,7 +113,7 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* pDstData, UINT32 DstFormat, UINT32
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
{ {
BYTE* pDstPixel = &pDstLine[((nXDst + x) * GetBytesPerPixel(DstFormat))]; BYTE* pDstPixel = &pDstLine[((nXDst + x) * FreeRDPGetBytesPerPixel(DstFormat))];
BOOL monoPixel = (*monoBits & monoBit) ? TRUE : FALSE; BOOL monoPixel = (*monoBits & monoBit) ? TRUE : FALSE;
if (!(monoBit >>= 1)) if (!(monoBit >>= 1))
@ -123,9 +123,9 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* pDstData, UINT32 DstFormat, UINT32
} }
if (monoPixel) if (monoPixel)
WriteColor(pDstPixel, DstFormat, backColor); FreeRDPWriteColor(pDstPixel, DstFormat, backColor);
else else
WriteColor(pDstPixel, DstFormat, foreColor); FreeRDPWriteColor(pDstPixel, DstFormat, foreColor);
} }
} }
@ -173,7 +173,7 @@ static void fill_gdi_palette_for_icon(const BYTE* colorTable, UINT16 cbColorTabl
for (i = 0; i < cbColorTable / 4; i++) for (i = 0; i < cbColorTable / 4; i++)
{ {
palette->palette[i] = ReadColor(&colorTable[4 * i], palette->format); palette->palette[i] = FreeRDPReadColor(&colorTable[4 * i], palette->format);
} }
} }
@ -240,7 +240,7 @@ BOOL freerdp_image_copy_from_icon_data(BYTE* pDstData, UINT32 DstFormat, UINT32
} }
/* Ensure we have enough source data bytes for image copy. */ /* Ensure we have enough source data bytes for image copy. */
if (cbBitsColor < nWidth * nHeight * GetBytesPerPixel(format)) if (cbBitsColor < nWidth * nHeight * FreeRDPGetBytesPerPixel(format))
return FALSE; return FALSE;
fill_gdi_palette_for_icon(colorTable, cbColorTable, &palette); fill_gdi_palette_for_icon(colorTable, cbColorTable, &palette);
@ -249,7 +249,7 @@ BOOL freerdp_image_copy_from_icon_data(BYTE* pDstData, UINT32 DstFormat, UINT32
return FALSE; return FALSE;
/* apply alpha mask */ /* apply alpha mask */
if (ColorHasAlpha(DstFormat) && cbBitsMask) if (FreeRDPColorHasAlpha(DstFormat) && cbBitsMask)
{ {
BYTE nextBit; BYTE nextBit;
const BYTE* maskByte; const BYTE* maskByte;
@ -257,7 +257,7 @@ BOOL freerdp_image_copy_from_icon_data(BYTE* pDstData, UINT32 DstFormat, UINT32
UINT32 stride; UINT32 stride;
BYTE r, g, b; BYTE r, g, b;
BYTE* dstBuf = pDstData; BYTE* dstBuf = pDstData;
UINT32 dstBpp = GetBytesPerPixel(DstFormat); UINT32 dstBpp = FreeRDPGetBytesPerPixel(DstFormat);
/* /*
* Each byte encodes 8 adjacent pixels (with LSB padding as needed). * Each byte encodes 8 adjacent pixels (with LSB padding as needed).
@ -277,10 +277,10 @@ BOOL freerdp_image_copy_from_icon_data(BYTE* pDstData, UINT32 DstFormat, UINT32
BYTE alpha = (*maskByte & nextBit) ? 0x00 : 0xFF; BYTE alpha = (*maskByte & nextBit) ? 0x00 : 0xFF;
/* read color back, add alpha and write it back */ /* read color back, add alpha and write it back */
color = ReadColor(dstBuf, DstFormat); color = FreeRDPReadColor(dstBuf, DstFormat);
SplitColor(color, DstFormat, &r, &g, &b, NULL, &palette); FreeRDPSplitColor(color, DstFormat, &r, &g, &b, NULL, &palette);
color = FreeRDPGetColor(DstFormat, r, g, b, alpha); color = FreeRDPGetColor(DstFormat, r, g, b, alpha);
WriteColor(dstBuf, DstFormat, color); FreeRDPWriteColor(dstBuf, DstFormat, color);
nextBit >>= 1; nextBit >>= 1;
dstBuf += dstBpp; dstBuf += dstBpp;
@ -335,7 +335,7 @@ static BOOL freerdp_image_copy_from_pointer_data_1bpp(BYTE* pDstData, UINT32 Dst
const BYTE* andBits; const BYTE* andBits;
const BYTE* xorBits; const BYTE* xorBits;
BYTE* pDstPixel = BYTE* pDstPixel =
&pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(DstFormat))]; &pDstData[((nYDst + y) * nDstStep) + (nXDst * FreeRDPGetBytesPerPixel(DstFormat))];
xorBit = andBit = 0x80; xorBit = andBit = 0x80;
if (!vFlip) if (!vFlip)
@ -377,8 +377,8 @@ static BOOL freerdp_image_copy_from_pointer_data_1bpp(BYTE* pDstData, UINT32 Dst
else if (andPixel && xorPixel) else if (andPixel && xorPixel)
color = freerdp_image_inverted_pointer_color(x, y, DstFormat); /* inverted */ color = freerdp_image_inverted_pointer_color(x, y, DstFormat); /* inverted */
WriteColor(pDstPixel, DstFormat, color); FreeRDPWriteColor(pDstPixel, DstFormat, color);
pDstPixel += GetBytesPerPixel(DstFormat); pDstPixel += FreeRDPGetBytesPerPixel(DstFormat);
} }
} }
@ -401,7 +401,7 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp(BYTE* pDstData, UINT32 Dst
UINT32 andPixel; UINT32 andPixel;
UINT32 dstBitsPerPixel; UINT32 dstBitsPerPixel;
UINT32 xorBytesPerPixel; UINT32 xorBytesPerPixel;
dstBitsPerPixel = GetBitsPerPixel(DstFormat); dstBitsPerPixel = FreeRDPGetBitsPerPixel(DstFormat);
vFlip = (xorBpp == 1) ? FALSE : TRUE; vFlip = (xorBpp == 1) ? FALSE : TRUE;
andStep = (nWidth + 7) / 8; andStep = (nWidth + 7) / 8;
@ -435,7 +435,7 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp(BYTE* pDstData, UINT32 Dst
const BYTE* xorBits; const BYTE* xorBits;
const BYTE* andBits = NULL; const BYTE* andBits = NULL;
BYTE* pDstPixel = BYTE* pDstPixel =
&pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(DstFormat))]; &pDstData[((nYDst + y) * nDstStep) + (nXDst * FreeRDPGetBytesPerPixel(DstFormat))];
andBit = 0x80; andBit = 0x80;
if (!vFlip) if (!vFlip)
@ -461,12 +461,12 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp(BYTE* pDstData, UINT32 Dst
if (xorBpp == 32) if (xorBpp == 32)
{ {
pixelFormat = PIXEL_FORMAT_BGRA32; pixelFormat = PIXEL_FORMAT_BGRA32;
xorPixel = ReadColor(xorBits, pixelFormat); xorPixel = FreeRDPReadColor(xorBits, pixelFormat);
} }
else if (xorBpp == 16) else if (xorBpp == 16)
{ {
pixelFormat = PIXEL_FORMAT_RGB15; pixelFormat = PIXEL_FORMAT_RGB15;
xorPixel = ReadColor(xorBits, pixelFormat); xorPixel = FreeRDPReadColor(xorBits, pixelFormat);
} }
else if (xorBpp == 8) else if (xorBpp == 8)
{ {
@ -476,7 +476,7 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp(BYTE* pDstData, UINT32 Dst
else else
{ {
pixelFormat = PIXEL_FORMAT_BGR24; pixelFormat = PIXEL_FORMAT_BGR24;
xorPixel = ReadColor(xorBits, pixelFormat); xorPixel = FreeRDPReadColor(xorBits, pixelFormat);
} }
xorPixel = FreeRDPConvertColor(xorPixel, pixelFormat, PIXEL_FORMAT_ARGB32, palette); xorPixel = FreeRDPConvertColor(xorPixel, pixelFormat, PIXEL_FORMAT_ARGB32, palette);
@ -503,8 +503,8 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp(BYTE* pDstData, UINT32 Dst
} }
color = FreeRDPConvertColor(xorPixel, PIXEL_FORMAT_ARGB32, DstFormat, palette); color = FreeRDPConvertColor(xorPixel, PIXEL_FORMAT_ARGB32, DstFormat, palette);
WriteColor(pDstPixel, DstFormat, color); FreeRDPWriteColor(pDstPixel, DstFormat, color);
pDstPixel += GetBytesPerPixel(DstFormat); pDstPixel += FreeRDPGetBytesPerPixel(DstFormat);
} }
} }
@ -528,8 +528,8 @@ BOOL freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat, UINT
UINT32 y; UINT32 y;
UINT32 dstBitsPerPixel; UINT32 dstBitsPerPixel;
UINT32 dstBytesPerPixel; UINT32 dstBytesPerPixel;
dstBitsPerPixel = GetBitsPerPixel(DstFormat); dstBitsPerPixel = FreeRDPGetBitsPerPixel(DstFormat);
dstBytesPerPixel = GetBytesPerPixel(DstFormat); dstBytesPerPixel = FreeRDPGetBytesPerPixel(DstFormat);
if (nDstStep <= 0) if (nDstStep <= 0)
nDstStep = dstBytesPerPixel * nWidth; nDstStep = dstBytesPerPixel * nWidth;
@ -588,8 +588,8 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32
DWORD SrcFormat, UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc, DWORD SrcFormat, UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
const gdiPalette* palette, UINT32 flags) const gdiPalette* palette, UINT32 flags)
{ {
const UINT32 dstByte = GetBytesPerPixel(DstFormat); const UINT32 dstByte = FreeRDPGetBytesPerPixel(DstFormat);
const UINT32 srcByte = GetBytesPerPixel(SrcFormat); const UINT32 srcByte = FreeRDPGetBytesPerPixel(SrcFormat);
const UINT32 copyDstWidth = nWidth * dstByte; const UINT32 copyDstWidth = nWidth * dstByte;
const UINT32 xSrcOffset = nXSrc * srcByte; const UINT32 xSrcOffset = nXSrc * srcByte;
const UINT32 xDstOffset = nXDst * dstByte; const UINT32 xDstOffset = nXDst * dstByte;
@ -606,10 +606,10 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32
return FALSE; return FALSE;
if (nDstStep == 0) if (nDstStep == 0)
nDstStep = nWidth * GetBytesPerPixel(DstFormat); nDstStep = nWidth * FreeRDPGetBytesPerPixel(DstFormat);
if (nSrcStep == 0) if (nSrcStep == 0)
nSrcStep = nWidth * GetBytesPerPixel(SrcFormat); nSrcStep = nWidth * FreeRDPGetBytesPerPixel(SrcFormat);
if (vSrcVFlip) if (vSrcVFlip)
{ {
@ -693,22 +693,22 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32
const BYTE* srcLine = &pSrcData[(y + nYSrc) * nSrcStep * srcVMultiplier + srcVOffset]; const BYTE* srcLine = &pSrcData[(y + nYSrc) * nSrcStep * srcVMultiplier + srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) * nDstStep * dstVMultiplier + dstVOffset]; BYTE* dstLine = &pDstData[(y + nYDst) * nDstStep * dstVMultiplier + dstVOffset];
UINT32 color = ReadColor(&srcLine[nXSrc * srcByte], SrcFormat); UINT32 color = FreeRDPReadColor(&srcLine[nXSrc * srcByte], SrcFormat);
UINT32 oldColor = color; UINT32 oldColor = color;
UINT32 dstColor = FreeRDPConvertColor(color, SrcFormat, DstFormat, palette); UINT32 dstColor = FreeRDPConvertColor(color, SrcFormat, DstFormat, palette);
WriteColor(&dstLine[nXDst * dstByte], DstFormat, dstColor); FreeRDPWriteColor(&dstLine[nXDst * dstByte], DstFormat, dstColor);
for (x = 1; x < nWidth; x++) for (x = 1; x < nWidth; x++)
{ {
color = ReadColor(&srcLine[(x + nXSrc) * srcByte], SrcFormat); color = FreeRDPReadColor(&srcLine[(x + nXSrc) * srcByte], SrcFormat);
if (color == oldColor) if (color == oldColor)
{ {
WriteColor(&dstLine[(x + nXDst) * dstByte], DstFormat, dstColor); FreeRDPWriteColor(&dstLine[(x + nXDst) * dstByte], DstFormat, dstColor);
} }
else else
{ {
oldColor = color; oldColor = color;
dstColor = FreeRDPConvertColor(color, SrcFormat, DstFormat, palette); dstColor = FreeRDPConvertColor(color, SrcFormat, DstFormat, palette);
WriteColor(&dstLine[(x + nXDst) * dstByte], DstFormat, dstColor); FreeRDPWriteColor(&dstLine[(x + nXDst) * dstByte], DstFormat, dstColor);
} }
} }
} }
@ -721,12 +721,12 @@ BOOL freerdp_image_fill(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32
UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 color) UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 color)
{ {
UINT32 x, y; UINT32 x, y;
const UINT32 bpp = GetBytesPerPixel(DstFormat); const UINT32 bpp = FreeRDPGetBytesPerPixel(DstFormat);
BYTE* pFirstDstLine; BYTE* pFirstDstLine;
BYTE* pFirstDstLineXOffset; BYTE* pFirstDstLineXOffset;
if (nDstStep == 0) if (nDstStep == 0)
nDstStep = (nXDst + nWidth) * GetBytesPerPixel(DstFormat); nDstStep = (nXDst + nWidth) * FreeRDPGetBytesPerPixel(DstFormat);
pFirstDstLine = &pDstData[nYDst * nDstStep]; pFirstDstLine = &pDstData[nYDst * nDstStep];
pFirstDstLineXOffset = &pFirstDstLine[nXDst * bpp]; pFirstDstLineXOffset = &pFirstDstLine[nXDst * bpp];
@ -734,7 +734,7 @@ BOOL freerdp_image_fill(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
{ {
BYTE* pDst = &pFirstDstLine[(x + nXDst) * bpp]; BYTE* pDst = &pFirstDstLine[(x + nXDst) * bpp];
WriteColor(pDst, DstFormat, color); FreeRDPWriteColor(pDst, DstFormat, color);
} }
for (y = 1; y < nHeight; y++) for (y = 1; y < nHeight; y++)
@ -777,14 +777,14 @@ BOOL freerdp_image_scale(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT3
BOOL rc = FALSE; BOOL rc = FALSE;
if (nDstStep == 0) if (nDstStep == 0)
nDstStep = nDstWidth * GetBytesPerPixel(DstFormat); nDstStep = nDstWidth * FreeRDPGetBytesPerPixel(DstFormat);
if (nSrcStep == 0) if (nSrcStep == 0)
nSrcStep = nSrcWidth * GetBytesPerPixel(SrcFormat); nSrcStep = nSrcWidth * FreeRDPGetBytesPerPixel(SrcFormat);
#if defined(SWSCALE_FOUND) || defined(CAIRO_FOUND) #if defined(SWSCALE_FOUND) || defined(CAIRO_FOUND)
const BYTE* src = &pSrcData[nXSrc * GetBytesPerPixel(SrcFormat) + nYSrc * nSrcStep]; const BYTE* src = &pSrcData[nXSrc * FreeRDPGetBytesPerPixel(SrcFormat) + nYSrc * nSrcStep];
BYTE* dst = &pDstData[nXDst * GetBytesPerPixel(DstFormat) + nYDst * nDstStep]; BYTE* dst = &pDstData[nXDst * FreeRDPGetBytesPerPixel(DstFormat) + nYDst * nDstStep];
#endif #endif
/* direct copy is much faster than scaling, so check if we can simply copy... */ /* direct copy is much faster than scaling, so check if we can simply copy... */
@ -863,3 +863,667 @@ BOOL freerdp_image_scale(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT3
#endif #endif
return rc; return rc;
} }
DWORD FreeRDPAreColorFormatsEqualNoAlpha(DWORD first, DWORD second)
{
const DWORD mask = (DWORD) ~(8UL << 12UL);
return (first & mask) == (second & mask);
}
const char* FreeRDPGetColorFormatName(UINT32 format)
{
switch (format)
{
/* 32bpp formats */
case PIXEL_FORMAT_ARGB32:
return "PIXEL_FORMAT_ARGB32";
case PIXEL_FORMAT_XRGB32:
return "PIXEL_FORMAT_XRGB32";
case PIXEL_FORMAT_ABGR32:
return "PIXEL_FORMAT_ABGR32";
case PIXEL_FORMAT_XBGR32:
return "PIXEL_FORMAT_XBGR32";
case PIXEL_FORMAT_BGRA32:
return "PIXEL_FORMAT_BGRA32";
case PIXEL_FORMAT_BGRX32:
return "PIXEL_FORMAT_BGRX32";
case PIXEL_FORMAT_RGBA32:
return "PIXEL_FORMAT_RGBA32";
case PIXEL_FORMAT_RGBX32:
return "PIXEL_FORMAT_RGBX32";
case PIXEL_FORMAT_BGRX32_DEPTH30:
return "PIXEL_FORMAT_BGRX32_DEPTH30";
case PIXEL_FORMAT_RGBX32_DEPTH30:
return "PIXEL_FORMAT_RGBX32_DEPTH30";
/* 24bpp formats */
case PIXEL_FORMAT_RGB24:
return "PIXEL_FORMAT_RGB24";
case PIXEL_FORMAT_BGR24:
return "PIXEL_FORMAT_BGR24";
/* 16bpp formats */
case PIXEL_FORMAT_RGB16:
return "PIXEL_FORMAT_RGB16";
case PIXEL_FORMAT_BGR16:
return "PIXEL_FORMAT_BGR16";
case PIXEL_FORMAT_ARGB15:
return "PIXEL_FORMAT_ARGB15";
case PIXEL_FORMAT_RGB15:
return "PIXEL_FORMAT_RGB15";
case PIXEL_FORMAT_ABGR15:
return "PIXEL_FORMAT_ABGR15";
case PIXEL_FORMAT_BGR15:
return "PIXEL_FORMAT_BGR15";
/* 8bpp formats */
case PIXEL_FORMAT_RGB8:
return "PIXEL_FORMAT_RGB8";
/* 4 bpp formats */
case PIXEL_FORMAT_A4:
return "PIXEL_FORMAT_A4";
/* 1bpp formats */
case PIXEL_FORMAT_MONO:
return "PIXEL_FORMAT_MONO";
default:
return "UNKNOWN";
}
}
void FreeRDPSplitColor(UINT32 color, UINT32 format, BYTE* _r, BYTE* _g, BYTE* _b, BYTE* _a,
const gdiPalette* palette)
{
UINT32 tmp;
switch (format)
{
/* 32bpp formats */
case PIXEL_FORMAT_ARGB32:
if (_a)
*_a = (BYTE)(color >> 24);
if (_r)
*_r = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_b)
*_b = (BYTE)color;
break;
case PIXEL_FORMAT_XRGB32:
if (_r)
*_r = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_b)
*_b = (BYTE)color;
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_ABGR32:
if (_a)
*_a = (BYTE)(color >> 24);
if (_b)
*_b = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_r)
*_r = (BYTE)color;
break;
case PIXEL_FORMAT_XBGR32:
if (_b)
*_b = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_r)
*_r = (BYTE)color;
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_RGBA32:
if (_r)
*_r = (BYTE)(color >> 24);
if (_g)
*_g = (BYTE)(color >> 16);
if (_b)
*_b = (BYTE)(color >> 8);
if (_a)
*_a = (BYTE)color;
break;
case PIXEL_FORMAT_RGBX32:
if (_r)
*_r = (BYTE)(color >> 24);
if (_g)
*_g = (BYTE)(color >> 16);
if (_b)
*_b = (BYTE)(color >> 8);
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_BGRA32:
if (_b)
*_b = (BYTE)(color >> 24);
if (_g)
*_g = (BYTE)(color >> 16);
if (_r)
*_r = (BYTE)(color >> 8);
if (_a)
*_a = (BYTE)color;
break;
case PIXEL_FORMAT_BGRX32:
if (_b)
*_b = (BYTE)(color >> 24);
if (_g)
*_g = (BYTE)(color >> 16);
if (_r)
*_r = (BYTE)(color >> 8);
if (_a)
*_a = 0xFF;
break;
/* 24bpp formats */
case PIXEL_FORMAT_RGB24:
if (_r)
*_r = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_b)
*_b = (BYTE)color;
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_BGR24:
if (_b)
*_b = (BYTE)(color >> 16);
if (_g)
*_g = (BYTE)(color >> 8);
if (_r)
*_r = (BYTE)color;
if (_a)
*_a = 0xFF;
break;
/* 16bpp formats */
case PIXEL_FORMAT_RGB16:
if (_r)
{
const UINT32 c = (color >> 11) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x3F;
const UINT32 val = (c << 2) + c / 4 / 2;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_BGR16:
if (_r)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x3F;
const UINT32 val = (c << 2) + c / 4 / 2;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color >> 11) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_ARGB15:
if (_r)
{
const UINT32 c = (color >> 10) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = color & 0x8000 ? 0xFF : 0x00;
break;
case PIXEL_FORMAT_ABGR15:
if (_r)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color >> 10) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = color & 0x8000 ? 0xFF : 0x00;
break;
/* 15bpp formats */
case PIXEL_FORMAT_RGB15:
if (_r)
{
const UINT32 c = (color >> 10) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = 0xFF;
break;
case PIXEL_FORMAT_BGR15:
if (_r)
{
const UINT32 c = (color)&0x1F;
const UINT32 val = (c << 3) + c / 4;
*_r = (BYTE)(val > 255 ? 255 : val);
}
if (_g)
{
const UINT32 c = (color >> 5) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_g = (BYTE)(val > 255 ? 255 : val);
}
if (_b)
{
const UINT32 c = (color >> 10) & 0x1F;
const UINT32 val = (c << 3) + c / 4;
*_b = (BYTE)(val > 255 ? 255 : val);
}
if (_a)
*_a = 0xFF;
break;
/* 8bpp formats */
case PIXEL_FORMAT_RGB8:
if (color <= 0xFF)
{
tmp = palette->palette[color];
FreeRDPSplitColor(tmp, palette->format, _r, _g, _b, _a, NULL);
}
else
{
if (_r)
*_r = 0x00;
if (_g)
*_g = 0x00;
if (_b)
*_b = 0x00;
if (_a)
*_a = 0x00;
}
break;
/* 1bpp formats */
case PIXEL_FORMAT_MONO:
if (_r)
*_r = (color) ? 0xFF : 0x00;
if (_g)
*_g = (color) ? 0xFF : 0x00;
if (_b)
*_b = (color) ? 0xFF : 0x00;
if (_a)
*_a = (color) ? 0xFF : 0x00;
break;
/* 4 bpp formats */
case PIXEL_FORMAT_A4:
default:
if (_r)
*_r = 0x00;
if (_g)
*_g = 0x00;
if (_b)
*_b = 0x00;
if (_a)
*_a = 0x00;
WLog_ERR(TAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
break;
}
}
BOOL FreeRDPWriteColorIgnoreAlpha(BYTE* dst, UINT32 format, UINT32 color)
{
switch (format)
{
case PIXEL_FORMAT_ABGR32:
case PIXEL_FORMAT_ARGB32:
{
const UINT32 tmp = ((UINT32)dst[0] << 24ULL) | (color & 0x00FFFFFFULL);
return FreeRDPWriteColor(dst, format, tmp);
}
case PIXEL_FORMAT_BGRA32:
case PIXEL_FORMAT_RGBA32:
{
const UINT32 tmp = ((UINT32)dst[3]) | (color & 0xFFFFFF00ULL);
return FreeRDPWriteColor(dst, format, tmp);
}
default:
return FreeRDPWriteColor(dst, format, color);
}
}
BOOL FreeRDPWriteColor(BYTE* dst, UINT32 format, UINT32 color)
{
switch (FreeRDPGetBitsPerPixel(format))
{
case 32:
dst[0] = (BYTE)(color >> 24);
dst[1] = (BYTE)(color >> 16);
dst[2] = (BYTE)(color >> 8);
dst[3] = (BYTE)color;
break;
case 24:
dst[0] = (BYTE)(color >> 16);
dst[1] = (BYTE)(color >> 8);
dst[2] = (BYTE)color;
break;
case 16:
dst[1] = (BYTE)(color >> 8);
dst[0] = (BYTE)color;
break;
case 15:
if (!FreeRDPColorHasAlpha(format))
color = color & 0x7FFF;
dst[1] = (BYTE)(color >> 8);
dst[0] = (BYTE)color;
break;
case 8:
dst[0] = (BYTE)color;
break;
default:
WLog_ERR(TAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
return FALSE;
}
return TRUE;
}
UINT32 FreeRDPReadColor(const BYTE* src, UINT32 format)
{
UINT32 color;
switch (FreeRDPGetBitsPerPixel(format))
{
case 32:
color =
((UINT32)src[0] << 24) | ((UINT32)src[1] << 16) | ((UINT32)src[2] << 8) | src[3];
break;
case 24:
color = ((UINT32)src[0] << 16) | ((UINT32)src[1] << 8) | src[2];
break;
case 16:
color = ((UINT32)src[1] << 8) | src[0];
break;
case 15:
color = ((UINT32)src[1] << 8) | src[0];
if (!FreeRDPColorHasAlpha(format))
color = color & 0x7FFF;
break;
case 8:
case 4:
case 1:
color = *src;
break;
default:
WLog_ERR(TAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
color = 0;
break;
}
return color;
}
UINT32 FreeRDPGetColor(UINT32 format, BYTE r, BYTE g, BYTE b, BYTE a)
{
UINT32 _r = r;
UINT32 _g = g;
UINT32 _b = b;
UINT32 _a = a;
UINT32 t;
switch (format)
{
/* 32bpp formats */
case PIXEL_FORMAT_ARGB32:
return (_a << 24) | (_r << 16) | (_g << 8) | _b;
case PIXEL_FORMAT_XRGB32:
return (_r << 16) | (_g << 8) | _b;
case PIXEL_FORMAT_ABGR32:
return (_a << 24) | (_b << 16) | (_g << 8) | _r;
case PIXEL_FORMAT_XBGR32:
return (_b << 16) | (_g << 8) | _r;
case PIXEL_FORMAT_RGBA32:
return (_r << 24) | (_g << 16) | (_b << 8) | _a;
case PIXEL_FORMAT_RGBX32:
return (_r << 24) | (_g << 16) | (_b << 8) | _a;
case PIXEL_FORMAT_BGRA32:
return (_b << 24) | (_g << 16) | (_r << 8) | _a;
case PIXEL_FORMAT_BGRX32:
return (_b << 24) | (_g << 16) | (_r << 8) | _a;
case PIXEL_FORMAT_RGBX32_DEPTH30:
// TODO: Not tested
t = (_r << 22) | (_g << 12) | (_b << 2);
// NOTE: Swapping byte-order because FreeRDPWriteColor written UINT32 in big-endian
return ((t & 0xff) << 24) | (((t >> 8) & 0xff) << 16) | (((t >> 16) & 0xff) << 8) |
(t >> 24);
case PIXEL_FORMAT_BGRX32_DEPTH30:
// NOTE: Swapping b and r channel (unknown reason)
t = (_r << 22) | (_g << 12) | (_b << 2);
// NOTE: Swapping byte-order because FreeRDPWriteColor written UINT32 in big-endian
return ((t & 0xff) << 24) | (((t >> 8) & 0xff) << 16) | (((t >> 16) & 0xff) << 8) |
(t >> 24);
/* 24bpp formats */
case PIXEL_FORMAT_RGB24:
return (_r << 16) | (_g << 8) | _b;
case PIXEL_FORMAT_BGR24:
return (_b << 16) | (_g << 8) | _r;
/* 16bpp formats */
case PIXEL_FORMAT_RGB16:
return (((_r >> 3) & 0x1F) << 11) | (((_g >> 2) & 0x3F) << 5) | ((_b >> 3) & 0x1F);
case PIXEL_FORMAT_BGR16:
return (((_b >> 3) & 0x1F) << 11) | (((_g >> 2) & 0x3F) << 5) | ((_r >> 3) & 0x1F);
case PIXEL_FORMAT_ARGB15:
return (((_r >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_b >> 3) & 0x1F) |
(_a ? 0x8000 : 0x0000);
case PIXEL_FORMAT_ABGR15:
return (((_b >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_r >> 3) & 0x1F) |
(_a ? 0x8000 : 0x0000);
/* 15bpp formats */
case PIXEL_FORMAT_RGB15:
return (((_r >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_b >> 3) & 0x1F);
case PIXEL_FORMAT_BGR15:
return (((_b >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_r >> 3) & 0x1F);
/* 8bpp formats */
case PIXEL_FORMAT_RGB8:
/* 4 bpp formats */
case PIXEL_FORMAT_A4:
/* 1bpp formats */
case PIXEL_FORMAT_MONO:
default:
WLog_ERR(TAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
return 0;
}
}

View File

@ -433,7 +433,7 @@ BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp, UINT32 width, UINT32
return FALSE; return FALSE;
if (nDstStride == 0) if (nDstStride == 0)
nDstStride = nWidth * GetBytesPerPixel(DstFormat); nDstStride = nWidth * FreeRDPGetBytesPerPixel(DstFormat);
switch (bpp) switch (bpp)
{ {

View File

@ -527,9 +527,9 @@ BOOL nsc_decompose_message(NSC_CONTEXT* context, wStream* s, BYTE* bmpdata, UINT
if (size > UINT32_MAX) if (size > UINT32_MAX)
return FALSE; return FALSE;
if (!nsc_process_message(context, (UINT16)GetBitsPerPixel(context->format), width, height, if (!nsc_process_message(context, (UINT16)FreeRDPGetBitsPerPixel(context->format), width,
Stream_Pointer(s), (UINT32)size, bmpdata, format, rowstride, x, y, height, Stream_Pointer(s), (UINT32)size, bmpdata, format, rowstride, x,
width, height, flip)) y, width, height, flip))
return FALSE; return FALSE;
Stream_Seek(s, size); Stream_Seek(s, size);
return TRUE; return TRUE;

View File

@ -486,8 +486,8 @@ static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, cons
BYTE alpha = *(*ppA)++; BYTE alpha = *(*ppA)++;
UINT32 color = UINT32 color =
FreeRDPGetColor(DstFormat, *(*ppR)++, *(*ppG)++, *(*ppB)++, alpha); FreeRDPGetColor(DstFormat, *(*ppR)++, *(*ppG)++, *(*ppB)++, alpha);
WriteColor(*ppRgba, DstFormat, color); FreeRDPWriteColor(*ppRgba, DstFormat, color);
*ppRgba += GetBytesPerPixel(DstFormat); *ppRgba += FreeRDPGetBytesPerPixel(DstFormat);
} }
} }
else else
@ -498,8 +498,8 @@ static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, cons
{ {
UINT32 color = UINT32 color =
FreeRDPGetColor(DstFormat, *(*ppR)++, *(*ppG)++, *(*ppB)++, alpha); FreeRDPGetColor(DstFormat, *(*ppR)++, *(*ppG)++, *(*ppB)++, alpha);
WriteColor(*ppRgba, DstFormat, color); FreeRDPWriteColor(*ppRgba, DstFormat, color);
*ppRgba += GetBytesPerPixel(DstFormat); *ppRgba += FreeRDPGetBytesPerPixel(DstFormat);
} }
} }
@ -518,7 +518,7 @@ static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4], BYTE* p
const BYTE* pG = pSrcData[1]; const BYTE* pG = pSrcData[1];
const BYTE* pB = pSrcData[2]; const BYTE* pB = pSrcData[2];
const BYTE* pA = pSrcData[3]; const BYTE* pA = pSrcData[3];
const UINT32 bpp = GetBytesPerPixel(DstFormat); const UINT32 bpp = FreeRDPGetBytesPerPixel(DstFormat);
if (vFlip) if (vFlip)
{ {
@ -613,7 +613,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData, UINT
const primitives_t* prims = primitives_get(); const primitives_t* prims = primitives_get();
if (nDstStep <= 0) if (nDstStep <= 0)
nDstStep = nDstWidth * GetBytesPerPixel(DstFormat); nDstStep = nDstWidth * FreeRDPGetBytesPerPixel(DstFormat);
srcp = pSrcData; srcp = pSrcData;
@ -632,7 +632,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData, UINT
DstFormat = planar_invert_format(planar, alpha, DstFormat); DstFormat = planar_invert_format(planar, alpha, DstFormat);
if (alpha) if (alpha)
useAlpha = ColorHasAlpha(DstFormat); useAlpha = FreeRDPColorHasAlpha(DstFormat);
// WLog_INFO(TAG, "CLL: %"PRIu32" CS: %"PRIu8" RLE: %"PRIu8" ALPHA: %"PRIu8"", cll, cs, rle, // WLog_INFO(TAG, "CLL: %"PRIu32" CS: %"PRIu8" RLE: %"PRIu8" ALPHA: %"PRIu8"", cll, cs, rle,
// alpha); // alpha);
@ -836,7 +836,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData, UINT
BYTE* pTempData = planar->pTempData; BYTE* pTempData = planar->pTempData;
UINT32 nTempStep = planar->nTempStep; UINT32 nTempStep = planar->nTempStep;
UINT32 nTotalHeight = planar->maxHeight; UINT32 nTotalHeight = planar->maxHeight;
BYTE* dst = &pDstData[nXDst * GetBytesPerPixel(DstFormat) + nYDst * nDstStep]; BYTE* dst = &pDstData[nXDst * FreeRDPGetBytesPerPixel(DstFormat) + nYDst * nDstStep];
if (useAlpha) if (useAlpha)
TempFormat = PIXEL_FORMAT_BGRA32; TempFormat = PIXEL_FORMAT_BGRA32;
@ -949,7 +949,7 @@ static INLINE BOOL freerdp_split_color_planes(BITMAP_PLANAR_CONTEXT* planar, con
return FALSE; return FALSE;
if (scanline == 0) if (scanline == 0)
scanline = width * GetBytesPerPixel(format); scanline = width * FreeRDPGetBytesPerPixel(format);
if (planar->topdown) if (planar->topdown)
{ {
@ -960,10 +960,10 @@ static INLINE BOOL freerdp_split_color_planes(BITMAP_PLANAR_CONTEXT* planar, con
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
{ {
const UINT32 color = ReadColor(pixel, format); const UINT32 color = FreeRDPReadColor(pixel, format);
pixel += GetBytesPerPixel(format); pixel += FreeRDPGetBytesPerPixel(format);
SplitColor(color, format, &planes[1][k], &planes[2][k], &planes[3][k], FreeRDPSplitColor(color, format, &planes[1][k], &planes[2][k], &planes[3][k],
&planes[0][k], NULL); &planes[0][k], NULL);
k++; k++;
} }
} }
@ -979,10 +979,10 @@ static INLINE BOOL freerdp_split_color_planes(BITMAP_PLANAR_CONTEXT* planar, con
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
{ {
const UINT32 color = ReadColor(pixel, format); const UINT32 color = FreeRDPReadColor(pixel, format);
pixel += GetBytesPerPixel(format); pixel += FreeRDPGetBytesPerPixel(format);
SplitColor(color, format, &planes[1][k], &planes[2][k], &planes[3][k], FreeRDPSplitColor(color, format, &planes[1][k], &planes[2][k], &planes[3][k],
&planes[0][k], NULL); &planes[0][k], NULL);
k++; k++;
} }
} }

View File

@ -413,7 +413,7 @@ static RFX_RECT* rfx_message_get_rect(RFX_MESSAGE* message, UINT32 index)
void rfx_context_set_pixel_format(RFX_CONTEXT* context, UINT32 pixel_format) void rfx_context_set_pixel_format(RFX_CONTEXT* context, UINT32 pixel_format)
{ {
context->pixel_format = pixel_format; context->pixel_format = pixel_format;
context->bits_per_pixel = GetBitsPerPixel(pixel_format); context->bits_per_pixel = FreeRDPGetBitsPerPixel(pixel_format);
} }
BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height) BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height)
@ -1153,8 +1153,8 @@ BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data, UINT32 length,
UINT32 nbUpdateRects; UINT32 nbUpdateRects;
REGION16 clippingRects; REGION16 clippingRects;
const RECTANGLE_16* updateRects; const RECTANGLE_16* updateRects;
const DWORD formatSize = GetBytesPerPixel(context->pixel_format); const DWORD formatSize = FreeRDPGetBytesPerPixel(context->pixel_format);
const UINT32 dstWidth = dstStride / GetBytesPerPixel(dstFormat); const UINT32 dstWidth = dstStride / FreeRDPGetBytesPerPixel(dstFormat);
region16_init(&clippingRects); region16_init(&clippingRects);
for (i = 0; i < message->numRects; i++) for (i = 0; i < message->numRects; i++)

View File

@ -29,7 +29,7 @@ static BOOL run_encode_decode_single(UINT16 bpp, BITMAP_INTERLEAVED_CONTEXT* enc
const UINT32 x = 0; const UINT32 x = 0;
const UINT32 y = 0; const UINT32 y = 0;
const UINT32 format = PIXEL_FORMAT_RGBX32; const UINT32 format = PIXEL_FORMAT_RGBX32;
const UINT32 bstep = GetBytesPerPixel(format); const UINT32 bstep = FreeRDPGetBytesPerPixel(format);
const size_t step = (w + 13) * 4; const size_t step = (w + 13) * 4;
const size_t SrcSize = step * h; const size_t SrcSize = step * h;
const float maxDiff = 4.0f * ((bpp < 24) ? 2.0f : 1.0f); const float maxDiff = 4.0f * ((bpp < 24) ? 2.0f : 1.0f);
@ -70,10 +70,10 @@ static BOOL run_encode_decode_single(UINT16 bpp, BITMAP_INTERLEAVED_CONTEXT* enc
for (j = 0; j < w; j++) for (j = 0; j < w; j++)
{ {
BYTE r, g, b, dr, dg, db; BYTE r, g, b, dr, dg, db;
const UINT32 srcColor = ReadColor(&srcLine[j * bstep], format); const UINT32 srcColor = FreeRDPReadColor(&srcLine[j * bstep], format);
const UINT32 dstColor = ReadColor(&dstLine[j * bstep], format); const UINT32 dstColor = FreeRDPReadColor(&dstLine[j * bstep], format);
SplitColor(srcColor, format, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(srcColor, format, &r, &g, &b, NULL, NULL);
SplitColor(dstColor, format, &dr, &dg, &db, NULL, NULL); FreeRDPSplitColor(dstColor, format, &dr, &dg, &db, NULL, NULL);
if (fabsf((float)r - dr) > maxDiff) if (fabsf((float)r - dr) > maxDiff)
goto fail; goto fail;
@ -169,11 +169,11 @@ static BOOL TestColorConversion(void)
const UINT32 colorLow32 = FreeRDPConvertColor(colorLow, format, dstFormat, NULL); const UINT32 colorLow32 = FreeRDPConvertColor(colorLow, format, dstFormat, NULL);
const UINT32 colorHigh32 = FreeRDPConvertColor(colorHigh, format, dstFormat, NULL); const UINT32 colorHigh32 = FreeRDPConvertColor(colorHigh, format, dstFormat, NULL);
BYTE r, g, b, a; BYTE r, g, b, a;
SplitColor(colorLow32, dstFormat, &r, &g, &b, &a, NULL); FreeRDPSplitColor(colorLow32, dstFormat, &r, &g, &b, &a, NULL);
if ((r != 0) || (g != 0) || (b != 0)) if ((r != 0) || (g != 0) || (b != 0))
return FALSE; return FALSE;
SplitColor(colorHigh32, dstFormat, &r, &g, &b, &a, NULL); FreeRDPSplitColor(colorHigh32, dstFormat, &r, &g, &b, &a, NULL);
if ((r != 255) || (g != 255) || (b != 255)) if ((r != 255) || (g != 255) || (b != 255))
return FALSE; return FALSE;
} }

View File

@ -5424,8 +5424,8 @@ static BOOL CompareBitmap(const BYTE* srcA, UINT32 srcAFormat, const BYTE* srcB,
UINT32 width, UINT32 height) UINT32 width, UINT32 height)
{ {
double maxDiff; double maxDiff;
const UINT32 srcABits = GetBitsPerPixel(srcAFormat); const UINT32 srcABits = FreeRDPGetBitsPerPixel(srcAFormat);
const UINT32 srcBBits = GetBitsPerPixel(srcBFormat); const UINT32 srcBBits = FreeRDPGetBitsPerPixel(srcBFormat);
UINT32 diff = fabs((double)srcABits - srcBBits); UINT32 diff = fabs((double)srcABits - srcBBits);
UINT32 x, y; UINT32 x, y;
@ -5464,18 +5464,18 @@ static BOOL CompareBitmap(const BYTE* srcA, UINT32 srcAFormat, const BYTE* srcB,
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
const BYTE* lineA = &srcA[width * GetBytesPerPixel(srcAFormat) * y]; const BYTE* lineA = &srcA[width * FreeRDPGetBytesPerPixel(srcAFormat) * y];
const BYTE* lineB = &srcB[width * GetBytesPerPixel(srcBFormat) * y]; const BYTE* lineB = &srcB[width * FreeRDPGetBytesPerPixel(srcBFormat) * y];
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
BYTE sR, sG, sB, sA, dR, dG, dB, dA; BYTE sR, sG, sB, sA, dR, dG, dB, dA;
const BYTE* a = &lineA[x * GetBytesPerPixel(srcAFormat)]; const BYTE* a = &lineA[x * FreeRDPGetBytesPerPixel(srcAFormat)];
const BYTE* b = &lineB[x * GetBytesPerPixel(srcBFormat)]; const BYTE* b = &lineB[x * FreeRDPGetBytesPerPixel(srcBFormat)];
UINT32 colorA = ReadColor(a, srcAFormat); UINT32 colorA = FreeRDPReadColor(a, srcAFormat);
UINT32 colorB = ReadColor(b, srcBFormat); UINT32 colorB = FreeRDPReadColor(b, srcBFormat);
SplitColor(colorA, srcAFormat, &sR, &sG, &sB, &sA, NULL); FreeRDPSplitColor(colorA, srcAFormat, &sR, &sG, &sB, &sA, NULL);
SplitColor(colorB, srcBFormat, &dR, &dG, &dB, &dA, NULL); FreeRDPSplitColor(colorB, srcBFormat, &dR, &dG, &dB, &dA, NULL);
if (fabs((double)sR - dR) > maxDiff) if (fabs((double)sR - dR) > maxDiff)
return FALSE; return FALSE;
@ -5502,7 +5502,7 @@ static BOOL RunTestPlanar(BITMAP_PLANAR_CONTEXT* planar, const BYTE* srcBitmap,
UINT32 dstSize; UINT32 dstSize;
BYTE* compressedBitmap = freerdp_bitmap_compress_planar(planar, srcBitmap, srcFormat, width, BYTE* compressedBitmap = freerdp_bitmap_compress_planar(planar, srcBitmap, srcFormat, width,
height, 0, NULL, &dstSize); height, 0, NULL, &dstSize);
BYTE* decompressedBitmap = (BYTE*)calloc(height, width * GetBytesPerPixel(dstFormat)); BYTE* decompressedBitmap = (BYTE*)calloc(height, width * FreeRDPGetBytesPerPixel(dstFormat));
printf("%s [%s] --> [%s]: ", __FUNCTION__, FreeRDPGetColorFormatName(srcFormat), printf("%s [%s] --> [%s]: ", __FUNCTION__, FreeRDPGetColorFormatName(srcFormat),
FreeRDPGetColorFormatName(dstFormat)); FreeRDPGetColorFormatName(dstFormat));
fflush(stdout); fflush(stdout);
@ -5558,8 +5558,8 @@ static BOOL RunTestPlanarSingleColor(BITMAP_PLANAR_CONTEXT* planar, const UINT32
const UINT32 width = i; const UINT32 width = i;
const UINT32 height = i; const UINT32 height = i;
BOOL failed = TRUE; BOOL failed = TRUE;
const UINT32 srcSize = width * height * GetBytesPerPixel(srcFormat); const UINT32 srcSize = width * height * FreeRDPGetBytesPerPixel(srcFormat);
const UINT32 dstSize = width * height * GetBytesPerPixel(dstFormat); const UINT32 dstSize = width * height * FreeRDPGetBytesPerPixel(dstFormat);
BYTE* compressedBitmap = NULL; BYTE* compressedBitmap = NULL;
BYTE* bmp = malloc(srcSize); BYTE* bmp = malloc(srcSize);
BYTE* decompressedBitmap = (BYTE*)malloc(dstSize); BYTE* decompressedBitmap = (BYTE*)malloc(dstSize);
@ -5569,12 +5569,12 @@ static BOOL RunTestPlanarSingleColor(BITMAP_PLANAR_CONTEXT* planar, const UINT32
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
BYTE* line = &bmp[width * GetBytesPerPixel(srcFormat) * y]; BYTE* line = &bmp[width * FreeRDPGetBytesPerPixel(srcFormat) * y];
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
WriteColor(line, srcFormat, color); FreeRDPWriteColor(line, srcFormat, color);
line += GetBytesPerPixel(srcFormat); line += FreeRDPGetBytesPerPixel(srcFormat);
} }
} }
@ -5744,9 +5744,9 @@ static BOOL FuzzPlanar(void)
nDstStep = prand(sizeof(dstData)); nDstStep = prand(sizeof(dstData));
nXDst = prand(nDstStep); nXDst = prand(nDstStep);
nYDst = prand(sizeof(dstData) / nDstStep); nYDst = prand(sizeof(dstData) / nDstStep);
nDstWidth = prand(nDstStep / GetBytesPerPixel(DstFormat)); nDstWidth = prand(nDstStep / FreeRDPGetBytesPerPixel(DstFormat));
nDstHeight = prand(sizeof(dstData) / nDstStep); nDstHeight = prand(sizeof(dstData) / nDstStep);
invalid = nXDst * GetBytesPerPixel(DstFormat) + (nYDst + nDstHeight) * nDstStep > invalid = nXDst * FreeRDPGetBytesPerPixel(DstFormat) + (nYDst + nDstHeight) * nDstStep >
sizeof(dstData); sizeof(dstData);
} while (invalid); } while (invalid);
printf("DstFormat=%s, nXDst=%" PRIu32 ", nYDst=%" PRIu32 ", nDstWidth=%" PRIu32 printf("DstFormat=%s, nXDst=%" PRIu32 ", nYDst=%" PRIu32 ", nDstWidth=%" PRIu32

View File

@ -1032,8 +1032,8 @@ static BOOL colordiff(UINT32 format, UINT32 a, UINT32 b)
{ {
BYTE ar, ag, ab, aa; BYTE ar, ag, ab, aa;
BYTE br, bg, bb, ba; BYTE br, bg, bb, ba;
SplitColor(a, format, &ar, &ag, &ab, &aa, NULL); FreeRDPSplitColor(a, format, &ar, &ag, &ab, &aa, NULL);
SplitColor(b, format, &br, &bg, &bb, &ba, NULL); FreeRDPSplitColor(b, format, &br, &bg, &bb, &ba, NULL);
if (!diff(aa, ba) || !diff(ar, br) || !diff(ag, bg) || !diff(ab, bb)) if (!diff(aa, ba) || !diff(ar, br) || !diff(ag, bg) || !diff(ab, bb))
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -1098,8 +1098,8 @@ static BOOL test_encode_decode(const char* path)
const BYTE* po = &orig[x * 4]; const BYTE* po = &orig[x * 4];
const BYTE* pd = &dec[x * 4]; const BYTE* pd = &dec[x * 4];
const DWORD a = ReadColor(po, ColorFormat); const DWORD a = FreeRDPReadColor(po, ColorFormat);
const DWORD b = ReadColor(pd, ColorFormat); const DWORD b = FreeRDPReadColor(pd, ColorFormat);
if (!colordiff(ColorFormat, a, b)) if (!colordiff(ColorFormat, a, b))
{ {
printf("xxxxxxx [%u:%u] %08X != %08X\n", x, y, a, b); printf("xxxxxxx [%u:%u] %08X != %08X\n", x, y, a, b);

View File

@ -80,7 +80,8 @@ static INLINE BOOL avc420_yuv_to_rgb(const BYTE* pYUVData[3], const UINT32 iStri
const INT32 width = rect->right - rect->left; const INT32 width = rect->right - rect->left;
const INT32 height = rect->bottom - rect->top; const INT32 height = rect->bottom - rect->top;
BYTE* pDstPoint = pDstData + rect->top * nDstStep + rect->left * GetBytesPerPixel(DstFormat); BYTE* pDstPoint =
pDstData + rect->top * nDstStep + rect->left * FreeRDPGetBytesPerPixel(DstFormat);
pYUVPoint[0] = pYUVData[0] + rect->top * iStride[0] + rect->left; pYUVPoint[0] = pYUVData[0] + rect->top * iStride[0] + rect->left;
pYUVPoint[1] = pYUVData[1] + rect->top / 2 * iStride[1] + rect->left / 2; pYUVPoint[1] = pYUVData[1] + rect->top / 2 * iStride[1] + rect->left / 2;
@ -111,7 +112,8 @@ static INLINE BOOL avc444_yuv_to_rgb(const BYTE* pYUVData[3], const UINT32 iStri
const INT32 width = rect->right - rect->left; const INT32 width = rect->right - rect->left;
const INT32 height = rect->bottom - rect->top; const INT32 height = rect->bottom - rect->top;
BYTE* pDstPoint = pDstData + rect->top * nDstStep + rect->left * GetBytesPerPixel(DstFormat); BYTE* pDstPoint =
pDstData + rect->top * nDstStep + rect->left * FreeRDPGetBytesPerPixel(DstFormat);
pYUVPoint[0] = pYUVData[0] + rect->top * iStride[0] + rect->left; pYUVPoint[0] = pYUVData[0] + rect->top * iStride[0] + rect->left;
pYUVPoint[1] = pYUVData[1] + rect->top * iStride[1] + rect->left; pYUVPoint[1] = pYUVData[1] + rect->top * iStride[1] + rect->left;
@ -606,7 +608,7 @@ static void CALLBACK yuv420_encode_work_callback(PTP_CALLBACK_INSTANCE instance,
roi.width = param->rect.right - param->rect.left; roi.width = param->rect.right - param->rect.left;
roi.height = param->rect.bottom - param->rect.top; roi.height = param->rect.bottom - param->rect.top;
src = param->pSrcData + param->nSrcStep * param->rect.top + src = param->pSrcData + param->nSrcStep * param->rect.top +
param->rect.left * GetBytesPerPixel(param->SrcFormat); param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat);
pYUVData[0] = param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left; pYUVData[0] = param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left;
pYUVData[1] = pYUVData[1] =
param->pYUVLumaData[1] + param->rect.top / 2 * param->iStride[1] + param->rect.left / 2; param->pYUVLumaData[1] + param->rect.top / 2 * param->iStride[1] + param->rect.left / 2;
@ -637,7 +639,7 @@ static void CALLBACK yuv444v1_encode_work_callback(PTP_CALLBACK_INSTANCE instanc
roi.width = param->rect.right - param->rect.left; roi.width = param->rect.right - param->rect.left;
roi.height = param->rect.bottom - param->rect.top; roi.height = param->rect.bottom - param->rect.top;
src = param->pSrcData + param->nSrcStep * param->rect.top + src = param->pSrcData + param->nSrcStep * param->rect.top +
param->rect.left * GetBytesPerPixel(param->SrcFormat); param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat);
pYUVLumaData[0] = pYUVLumaData[0] =
param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left; param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left;
pYUVLumaData[1] = pYUVLumaData[1] =
@ -674,7 +676,7 @@ static void CALLBACK yuv444v2_encode_work_callback(PTP_CALLBACK_INSTANCE instanc
roi.width = param->rect.right - param->rect.left; roi.width = param->rect.right - param->rect.left;
roi.height = param->rect.bottom - param->rect.top; roi.height = param->rect.bottom - param->rect.top;
src = param->pSrcData + param->nSrcStep * param->rect.top + src = param->pSrcData + param->nSrcStep * param->rect.top +
param->rect.left * GetBytesPerPixel(param->SrcFormat); param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat);
pYUVLumaData[0] = pYUVLumaData[0] =
param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left; param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left;
pYUVLumaData[1] = pYUVLumaData[1] =

View File

@ -30,6 +30,8 @@
#include <winpr/environment.h> /* For GetEnvironmentVariableA */ #include <winpr/environment.h> /* For GetEnvironmentVariableA */
#define CRLF "\r\n" #define CRLF "\r\n"
#include <freerdp/log.h>
#define TAG FREERDP_TAG("core.proxy") #define TAG FREERDP_TAG("core.proxy")
/* SOCKS Proxy auth methods by rfc1928 */ /* SOCKS Proxy auth methods by rfc1928 */

View File

@ -53,13 +53,14 @@
UINT32 gdi_GetPixel(HGDI_DC hdc, UINT32 nXPos, UINT32 nYPos) UINT32 gdi_GetPixel(HGDI_DC hdc, UINT32 nXPos, UINT32 nYPos)
{ {
HGDI_BITMAP hBmp = (HGDI_BITMAP)hdc->selectedObject; HGDI_BITMAP hBmp = (HGDI_BITMAP)hdc->selectedObject;
BYTE* data = &(hBmp->data[(nYPos * hBmp->scanline) + nXPos * GetBytesPerPixel(hBmp->format)]); BYTE* data =
return ReadColor(data, hBmp->format); &(hBmp->data[(nYPos * hBmp->scanline) + nXPos * FreeRDPGetBytesPerPixel(hBmp->format)]);
return FreeRDPReadColor(data, hBmp->format);
} }
BYTE* gdi_GetPointer(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y) BYTE* gdi_GetPointer(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y)
{ {
UINT32 bpp = GetBytesPerPixel(hBmp->format); UINT32 bpp = FreeRDPGetBytesPerPixel(hBmp->format);
return &hBmp->data[(Y * hBmp->width * bpp) + X * bpp]; return &hBmp->data[(Y * hBmp->width * bpp) + X * bpp];
} }
@ -75,8 +76,8 @@ BYTE* gdi_GetPointer(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y)
static INLINE UINT32 gdi_SetPixelBmp(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y, UINT32 crColor) static INLINE UINT32 gdi_SetPixelBmp(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y, UINT32 crColor)
{ {
BYTE* p = &hBmp->data[(Y * hBmp->scanline) + X * GetBytesPerPixel(hBmp->format)]; BYTE* p = &hBmp->data[(Y * hBmp->scanline) + X * FreeRDPGetBytesPerPixel(hBmp->format)];
WriteColor(p, hBmp->format, crColor); FreeRDPWriteColor(p, hBmp->format, crColor);
return crColor; return crColor;
} }
@ -116,7 +117,7 @@ HGDI_BITMAP gdi_CreateBitmapEx(UINT32 nWidth, UINT32 nHeight, UINT32 format, UIN
if (stride > 0) if (stride > 0)
hBitmap->scanline = stride; hBitmap->scanline = stride;
else else
hBitmap->scanline = nWidth * GetBytesPerPixel(hBitmap->format); hBitmap->scanline = nWidth * FreeRDPGetBytesPerPixel(hBitmap->format);
hBitmap->width = nWidth; hBitmap->width = nWidth;
hBitmap->height = nHeight; hBitmap->height = nHeight;
@ -146,7 +147,7 @@ HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, UINT32 nWidth, UINT32 nHeigh
hBitmap->width = nWidth; hBitmap->width = nWidth;
hBitmap->height = nHeight; hBitmap->height = nHeight;
hBitmap->data = hBitmap->data =
_aligned_malloc(nWidth * nHeight * GetBytesPerPixel(hBitmap->format) * 1ULL, 16); _aligned_malloc(nWidth * nHeight * FreeRDPGetBytesPerPixel(hBitmap->format) * 1ULL, 16);
hBitmap->free = _aligned_free; hBitmap->free = _aligned_free;
if (!hBitmap->data) if (!hBitmap->data)
@ -155,7 +156,7 @@ HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, UINT32 nWidth, UINT32 nHeigh
return NULL; return NULL;
} }
hBitmap->scanline = nWidth * GetBytesPerPixel(hBitmap->format); hBitmap->scanline = nWidth * FreeRDPGetBytesPerPixel(hBitmap->format);
return hBitmap; return hBitmap;
} }
@ -284,7 +285,7 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, I
return FALSE; return FALSE;
} }
colorA = ReadColor(dstp, hdcDest->format); colorA = FreeRDPReadColor(dstp, hdcDest->format);
if (useSrc) if (useSrc)
{ {
@ -296,7 +297,7 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, I
return FALSE; return FALSE;
} }
colorC = ReadColor(srcp, hdcSrc->format); colorC = FreeRDPReadColor(srcp, hdcSrc->format);
colorC = FreeRDPConvertColor(colorC, hdcSrc->format, hdcDest->format, palette); colorC = FreeRDPConvertColor(colorC, hdcSrc->format, hdcDest->format, palette);
} }
@ -319,7 +320,7 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, I
return FALSE; return FALSE;
} }
colorB = ReadColor(patp, hdcDest->format); colorB = FreeRDPReadColor(patp, hdcDest->format);
} }
break; break;
@ -329,7 +330,7 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest, I
} }
dstColor = process_rop(colorC, colorA, colorB, rop, hdcDest->format); dstColor = process_rop(colorC, colorA, colorB, rop, hdcDest->format);
return WriteColor(dstp, hdcDest->format, dstColor); return FreeRDPWriteColor(dstp, hdcDest->format, dstColor);
} }
static BOOL adjust_src_coordinates(HGDI_DC hdcSrc, INT32 nWidth, INT32 nHeight, INT32* px, static BOOL adjust_src_coordinates(HGDI_DC hdcSrc, INT32 nWidth, INT32 nHeight, INT32* px,

View File

@ -867,8 +867,8 @@ static BOOL gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
{ {
HGDI_BITMAP hBmp; HGDI_BITMAP hBmp;
UINT32 brushFormat; UINT32 brushFormat;
BYTE* data = BYTE* data = (BYTE*)_aligned_malloc(
(BYTE*)_aligned_malloc(8 * 8 * GetBytesPerPixel(gdi->drawing->hdc->format), 16); 8 * 8 * FreeRDPGetBytesPerPixel(gdi->drawing->hdc->format), 16);
if (!data) if (!data)
{ {
@ -1057,7 +1057,7 @@ static BOOL gdi_surface_bits(rdpContext* context, const SURFACE_BITS_COMMAND* cm
case RDP_CODEC_ID_NONE: case RDP_CODEC_ID_NONE:
format = gdi_get_pixel_format(cmd->bmp.bpp); format = gdi_get_pixel_format(cmd->bmp.bpp);
size = cmd->bmp.width * cmd->bmp.height * GetBytesPerPixel(format) * 1ULL; size = cmd->bmp.width * cmd->bmp.height * FreeRDPGetBytesPerPixel(format) * 1ULL;
if (size > cmd->bmp.bitmapDataLength) if (size > cmd->bmp.bitmapDataLength)
{ {
WLog_ERR(TAG, "Short nocodec message: got %" PRIu32 " bytes, require %" PRIuz, WLog_ERR(TAG, "Short nocodec message: got %" PRIu32 " bytes, require %" PRIuz,
@ -1172,7 +1172,7 @@ static BOOL gdi_init_primary(rdpGdi* gdi, UINT32 stride, UINT32 format, BYTE* bu
if (stride > 0) if (stride > 0)
gdi->stride = stride; gdi->stride = stride;
else else
gdi->stride = gdi->width * GetBytesPerPixel(gdi->dstFormat); gdi->stride = gdi->width * FreeRDPGetBytesPerPixel(gdi->dstFormat);
if (!gdi->primary) if (!gdi->primary)
goto fail_primary; goto fail_primary;

View File

@ -37,7 +37,7 @@ static INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, INT32 x, INT32 y)
if ((x >= 0) && (y >= 0) && (x < hBmp->width) && (y < hBmp->height)) if ((x >= 0) && (y >= 0) && (x < hBmp->width) && (y < hBmp->height))
{ {
p = hBmp->data + (y * hBmp->scanline) + (x * GetBytesPerPixel(hdcBmp->format)); p = hBmp->data + (y * hBmp->scanline) + (x * FreeRDPGetBytesPerPixel(hdcBmp->format));
return p; return p;
} }
else else
@ -77,7 +77,7 @@ static INLINE BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) % y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %
hBmpBrush->height; hBmpBrush->height;
p = hBmpBrush->data + (y * hBmpBrush->scanline) + p = hBmpBrush->data + (y * hBmpBrush->scanline) +
(x * GetBytesPerPixel(hBmpBrush->format)); (x * FreeRDPGetBytesPerPixel(hBmpBrush->format));
return p; return p;
} }
break; break;

View File

@ -333,7 +333,7 @@ static UINT gdi_SurfaceCommand_Uncompressed(rdpGdi* gdi, RdpgfxClientContext* co
if (!is_within_surface(surface, cmd)) if (!is_within_surface(surface, cmd))
return ERROR_INVALID_DATA; return ERROR_INVALID_DATA;
bpp = GetBytesPerPixel(cmd->format); bpp = FreeRDPGetBytesPerPixel(cmd->format);
size = bpp * cmd->width * cmd->height * 1ULL; size = bpp * cmd->width * cmd->height * 1ULL;
if (cmd->length < size) if (cmd->length < size)
{ {
@ -733,7 +733,7 @@ static BOOL gdi_apply_alpha(BYTE* data, UINT32 format, UINT32 stride, RECTANGLE_
UINT32 y; UINT32 y;
UINT32 written = 0; UINT32 written = 0;
BOOL first = TRUE; BOOL first = TRUE;
const UINT32 bpp = GetBytesPerPixel(format); const UINT32 bpp = FreeRDPGetBytesPerPixel(format);
WINPR_ASSERT(rect); WINPR_ASSERT(rect);
for (y = rect->top; y < rect->bottom; y++) for (y = rect->top; y < rect->bottom; y++)
@ -751,10 +751,10 @@ static BOOL gdi_apply_alpha(BYTE* data, UINT32 format, UINT32 stride, RECTANGLE_
return TRUE; return TRUE;
src = &line[x * bpp]; src = &line[x * bpp];
color = ReadColor(src, format); color = FreeRDPReadColor(src, format);
SplitColor(color, format, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, format, &r, &g, &b, NULL, NULL);
color = FreeRDPGetColor(format, r, g, b, a); color = FreeRDPGetColor(format, r, g, b, a);
WriteColor(src, format, color); FreeRDPWriteColor(src, format, color);
written++; written++;
} }
@ -819,12 +819,12 @@ static UINT gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context,
{ {
UINT32 color; UINT32 color;
BYTE r, g, b, a; BYTE r, g, b, a;
BYTE* src = &line[x * GetBytesPerPixel(surface->format)]; BYTE* src = &line[x * FreeRDPGetBytesPerPixel(surface->format)];
Stream_Read_UINT8(s, a); Stream_Read_UINT8(s, a);
color = ReadColor(src, surface->format); color = FreeRDPReadColor(src, surface->format);
SplitColor(color, surface->format, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, surface->format, &r, &g, &b, NULL, NULL);
color = FreeRDPGetColor(surface->format, r, g, b, a); color = FreeRDPGetColor(surface->format, r, g, b, a);
WriteColor(src, surface->format, color); FreeRDPWriteColor(src, surface->format, color);
} }
} }
} }

View File

@ -49,14 +49,14 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight, UINT32
if (!gdi) if (!gdi)
return NULL; return NULL;
nDstStep = nWidth * GetBytesPerPixel(gdi->dstFormat); nDstStep = nWidth * FreeRDPGetBytesPerPixel(gdi->dstFormat);
pDstData = _aligned_malloc(nHeight * nDstStep * 1ULL, 16); pDstData = _aligned_malloc(nHeight * nDstStep * 1ULL, 16);
if (!pDstData) if (!pDstData)
return NULL; return NULL;
pSrcData = data; pSrcData = data;
nSrcStep = nWidth * GetBytesPerPixel(SrcFormat); nSrcStep = nWidth * FreeRDPGetBytesPerPixel(SrcFormat);
if (!freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0, nWidth, nHeight, pSrcData, if (!freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0, nWidth, nHeight, pSrcData,
SrcFormat, nSrcStep, 0, 0, &gdi->palette, FREERDP_FLIP_NONE)) SrcFormat, nSrcStep, 0, 0, &gdi->palette, FREERDP_FLIP_NONE))
@ -137,12 +137,12 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, const
bitmap->compressed = FALSE; bitmap->compressed = FALSE;
bitmap->format = gdi->dstFormat; bitmap->format = gdi->dstFormat;
if ((GetBytesPerPixel(bitmap->format) == 0) || (DstWidth == 0) || (DstHeight == 0) || if ((FreeRDPGetBytesPerPixel(bitmap->format) == 0) || (DstWidth == 0) || (DstHeight == 0) ||
(DstWidth > UINT32_MAX / DstHeight) || (DstWidth > UINT32_MAX / DstHeight) ||
(size > (UINT32_MAX / GetBytesPerPixel(bitmap->format)))) (size > (UINT32_MAX / FreeRDPGetBytesPerPixel(bitmap->format))))
return FALSE; return FALSE;
size *= GetBytesPerPixel(bitmap->format); size *= FreeRDPGetBytesPerPixel(bitmap->format);
bitmap->length = size; bitmap->length = size;
bitmap->data = (BYTE*)_aligned_malloc(bitmap->length, 16); bitmap->data = (BYTE*)_aligned_malloc(bitmap->length, 16);
@ -171,8 +171,8 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, const
else else
{ {
const UINT32 SrcFormat = gdi_get_pixel_format(bpp); const UINT32 SrcFormat = gdi_get_pixel_format(bpp);
const size_t sbpp = GetBytesPerPixel(SrcFormat); const size_t sbpp = FreeRDPGetBytesPerPixel(SrcFormat);
const size_t dbpp = GetBytesPerPixel(bitmap->format); const size_t dbpp = FreeRDPGetBytesPerPixel(bitmap->format);
if ((sbpp == 0) || (dbpp == 0)) if ((sbpp == 0) || (dbpp == 0))
return FALSE; return FALSE;

View File

@ -45,7 +45,7 @@
*/ */
static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format) static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format)
{ {
const UINT32 srcPixel = ReadColor(pixelPtr, format); const UINT32 srcPixel = FreeRDPReadColor(pixelPtr, format);
UINT32 dstPixel; UINT32 dstPixel;
switch (rop) switch (rop)
@ -118,7 +118,7 @@ static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format)
return FALSE; return FALSE;
} }
return WriteColor(pixelPtr, format, dstPixel); return FreeRDPWriteColor(pixelPtr, format, dstPixel);
} }
BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd) BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)

View File

@ -147,11 +147,11 @@ BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr)
BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest); BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest);
if (dstp) if (dstp)
WriteColor(dstp, hdc->format, color); FreeRDPWriteColor(dstp, hdc->format, color);
} }
srcp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest); srcp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest);
formatSize = GetBytesPerPixel(hdc->format); formatSize = FreeRDPGetBytesPerPixel(hdc->format);
for (y = 1; y < nHeight; y++) for (y = 1; y < nHeight; y++)
{ {
@ -164,7 +164,7 @@ BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr)
case GDI_BS_HATCHED: case GDI_BS_HATCHED:
case GDI_BS_PATTERN: case GDI_BS_PATTERN:
monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO); monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO);
formatSize = GetBytesPerPixel(hbr->pattern->format); formatSize = FreeRDPGetBytesPerPixel(hbr->pattern->format);
for (y = 0; y < nHeight; y++) for (y = 0; y < nHeight; y++)
{ {
@ -188,13 +188,13 @@ BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr)
} }
else else
{ {
dstColor = ReadColor(patp, hbr->pattern->format); dstColor = FreeRDPReadColor(patp, hbr->pattern->format);
dstColor = dstColor =
FreeRDPConvertColor(dstColor, hbr->pattern->format, hdc->format, NULL); FreeRDPConvertColor(dstColor, hbr->pattern->format, hdc->format, NULL);
} }
if (dstp) if (dstp)
WriteColor(dstp, hdc->format, dstColor); FreeRDPWriteColor(dstp, hdc->format, dstColor);
} }
} }
@ -255,10 +255,10 @@ BOOL gdi_Rectangle(HGDI_DC hdc, INT32 nXDst, INT32 nYDst, INT32 nWidth, INT32 nH
BYTE* dstRight = gdi_get_bitmap_pointer(hdc, nXDst + nWidth - 1, nYDst + y); BYTE* dstRight = gdi_get_bitmap_pointer(hdc, nXDst + nWidth - 1, nYDst + y);
if (dstLeft) if (dstLeft)
WriteColor(dstLeft, hdc->format, color); FreeRDPWriteColor(dstLeft, hdc->format, color);
if (dstRight) if (dstRight)
WriteColor(dstRight, hdc->format, color); FreeRDPWriteColor(dstRight, hdc->format, color);
} }
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
@ -267,10 +267,10 @@ BOOL gdi_Rectangle(HGDI_DC hdc, INT32 nXDst, INT32 nYDst, INT32 nWidth, INT32 nH
BYTE* dstBottom = gdi_get_bitmap_pointer(hdc, nXDst + x, nYDst + nHeight - 1); BYTE* dstBottom = gdi_get_bitmap_pointer(hdc, nXDst + x, nYDst + nHeight - 1);
if (dstTop) if (dstTop)
WriteColor(dstTop, hdc->format, color); FreeRDPWriteColor(dstTop, hdc->format, color);
if (dstBottom) if (dstBottom)
WriteColor(dstBottom, hdc->format, color); FreeRDPWriteColor(dstBottom, hdc->format, color);
} }
return FALSE; return FALSE;

View File

@ -355,7 +355,7 @@ static BOOL test_gdi_GetPixel(void)
} }
gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap); gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap);
bpp = GetBytesPerPixel(hBitmap->format); bpp = FreeRDPGetBytesPerPixel(hBitmap->format);
for (i = 0; i < height; i++) for (i = 0; i < height; i++)
{ {
@ -364,7 +364,8 @@ static BOOL test_gdi_GetPixel(void)
UINT32 pixel; UINT32 pixel;
const UINT32 color = const UINT32 color =
FreeRDPGetColor(hBitmap->format, rand(), rand(), rand(), rand()); FreeRDPGetColor(hBitmap->format, rand(), rand(), rand(), rand());
WriteColor(&hBitmap->data[i * hBitmap->scanline + j * bpp], hBitmap->format, color); FreeRDPWriteColor(&hBitmap->data[i * hBitmap->scanline + j * bpp], hBitmap->format,
color);
pixel = gdi_GetPixel(hdc, j, i); pixel = gdi_GetPixel(hdc, j, i);
if (pixel != color) if (pixel != color)
@ -407,7 +408,7 @@ static BOOL test_gdi_SetPixel(void)
hdc->format = colorFormatList[x]; hdc->format = colorFormatList[x];
hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height); hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height);
gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap); gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap);
bpp = GetBytesPerPixel(hBitmap->format); bpp = FreeRDPGetBytesPerPixel(hBitmap->format);
for (i = 0; i < height; i++) for (i = 0; i < height; i++)
{ {
@ -417,7 +418,8 @@ static BOOL test_gdi_SetPixel(void)
const UINT32 color = const UINT32 color =
FreeRDPGetColor(hBitmap->format, rand(), rand(), rand(), rand()); FreeRDPGetColor(hBitmap->format, rand(), rand(), rand(), rand());
gdi_SetPixel(hdc, j, i, color); gdi_SetPixel(hdc, j, i, color);
pixel = ReadColor(&hBitmap->data[i * hBitmap->scanline + j * bpp], hBitmap->format); pixel = FreeRDPReadColor(&hBitmap->data[i * hBitmap->scanline + j * bpp],
hBitmap->format);
if (pixel != color) if (pixel != color)
{ {

View File

@ -97,7 +97,7 @@ static int test_gdi_FillRect(void)
} }
hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height); hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height);
ZeroMemory(hBitmap->data, width * height * GetBytesPerPixel(hdc->format)); ZeroMemory(hBitmap->data, width * height * FreeRDPGetBytesPerPixel(hdc->format));
gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap); gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap);
color = FreeRDPGetColor(PIXEL_FORMAT_ARGB32, 0xAA, 0xBB, 0xCC, 0xFF); color = FreeRDPGetColor(PIXEL_FORMAT_ARGB32, 0xAA, 0xBB, 0xCC, 0xFF);
hBrush = gdi_CreateSolidBrush(color); hBrush = gdi_CreateSolidBrush(color);

View File

@ -28,7 +28,7 @@ HGDI_BITMAP test_convert_to_bitmap(const BYTE* src, UINT32 SrcFormat, UINT32 Src
BYTE* data; BYTE* data;
if (DstStride == 0) if (DstStride == 0)
DstStride = nWidth * GetBytesPerPixel(DstFormat); DstStride = nWidth * FreeRDPGetBytesPerPixel(DstFormat);
data = _aligned_malloc(DstStride * nHeight, 16); data = _aligned_malloc(DstStride * nHeight, 16);
@ -85,7 +85,7 @@ static void test_dump_data(unsigned char* p, int len, int width, const char* nam
void test_dump_bitmap(HGDI_BITMAP hBmp, const char* name) void test_dump_bitmap(HGDI_BITMAP hBmp, const char* name)
{ {
UINT32 stride = hBmp->width * GetBytesPerPixel(hBmp->format); UINT32 stride = hBmp->width * FreeRDPGetBytesPerPixel(hBmp->format);
test_dump_data(hBmp->data, hBmp->height * stride, stride, name); test_dump_data(hBmp->data, hBmp->height * stride, stride, name);
} }
@ -102,10 +102,10 @@ static BOOL CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2, const gdiPalett
{ {
for (x = 0; x < minw; x++) for (x = 0; x < minw; x++)
{ {
colorA = ReadColor(p1, hBmp1->format); colorA = FreeRDPReadColor(p1, hBmp1->format);
colorB = ReadColor(p2, hBmp2->format); colorB = FreeRDPReadColor(p2, hBmp2->format);
p1 += GetBytesPerPixel(hBmp1->format); p1 += FreeRDPGetBytesPerPixel(hBmp1->format);
p2 += GetBytesPerPixel(hBmp2->format); p2 += FreeRDPGetBytesPerPixel(hBmp2->format);
if (hBmp1->format != hBmp2->format) if (hBmp1->format != hBmp2->format)
colorB = FreeRDPConvertColor(colorB, hBmp2->format, hBmp1->format, palette); colorB = FreeRDPConvertColor(colorB, hBmp2->format, hBmp1->format, palette);

View File

@ -193,7 +193,7 @@ VideoSurface* VideoClient_CreateCommonContext(size_t size, UINT32 x, UINT32 y, U
ret->alignedWidth = ret->w + 32 - ret->w % 16; ret->alignedWidth = ret->w + 32 - ret->w % 16;
ret->alignedHeight = ret->h + 32 - ret->h % 16; ret->alignedHeight = ret->h + 32 - ret->h % 16;
ret->scanline = ret->alignedWidth * GetBytesPerPixel(ret->format); ret->scanline = ret->alignedWidth * FreeRDPGetBytesPerPixel(ret->format);
ret->data = _aligned_malloc(ret->scanline * ret->alignedHeight * 1ULL, 64); ret->data = _aligned_malloc(ret->scanline * ret->alignedHeight * 1ULL, 64);
if (!ret->data) if (!ret->data)
goto fail; goto fail;

View File

@ -38,7 +38,7 @@ static pstatus_t general_YCoCgToRGB_8u_AC4R(const BYTE* pSrc, INT32 srcStep, BYT
UINT32 height, UINT8 shift, BOOL withAlpha) UINT32 height, UINT8 shift, BOOL withAlpha)
{ {
UINT32 x, y; UINT32 x, y;
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, TRUE); fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, TRUE);
for (y = 0; y < height; y++) for (y = 0; y < height; y++)

View File

@ -431,7 +431,7 @@ static pstatus_t neon_YCoCgToRGB_8u_X(const BYTE* pSrc, INT32 srcStep, BYTE* pDs
UINT32 y; UINT32 y;
BYTE* dptr = pDst; BYTE* dptr = pDst;
const BYTE* sptr = pSrc; const BYTE* sptr = pSrc;
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
const int8_t cll = shift - 1; /* -1 builds in the /2's */ const int8_t cll = shift - 1; /* -1 builds in the /2's */
const UINT32 srcPad = srcStep - (width * 4); const UINT32 srcPad = srcStep - (width * 4);
const UINT32 dstPad = dstStep - (width * formatSize); const UINT32 dstPad = dstStep - (width * formatSize);

View File

@ -382,7 +382,7 @@ static pstatus_t general_YUV444ToRGB_8u_P3AC4R_general(const BYTE* const pSrc[3]
{ {
UINT32 x, y; UINT32 x, y;
UINT32 nWidth, nHeight; UINT32 nWidth, nHeight;
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, FALSE); fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, FALSE);
nWidth = roi->width; nWidth = roi->width;
nHeight = roi->height; nHeight = roi->height;
@ -416,7 +416,7 @@ static pstatus_t general_YUV444ToRGB_8u_P3AC4R_BGRX(const BYTE* const pSrc[3],
{ {
UINT32 x, y; UINT32 x, y;
UINT32 nWidth, nHeight; UINT32 nWidth, nHeight;
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
nWidth = roi->width; nWidth = roi->width;
nHeight = roi->height; nHeight = roi->height;
@ -478,7 +478,7 @@ static pstatus_t general_YUV420ToRGB_8u_P3AC4R(const BYTE* const pSrc[3], const
BYTE* pRGB = pDst; BYTE* pRGB = pDst;
UINT32 nWidth, nHeight; UINT32 nWidth, nHeight;
UINT32 lastRow, lastCol; UINT32 lastRow, lastCol;
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, FALSE); fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, FALSE);
pY = pSrc[0]; pY = pSrc[0];
pU = pSrc[1]; pU = pSrc[1];
@ -610,7 +610,7 @@ static pstatus_t general_RGBToYUV444_8u_P3AC4R(const BYTE* pSrc, UINT32 SrcForma
const UINT32 srcStep, BYTE* pDst[3], const UINT32 srcStep, BYTE* pDst[3],
UINT32 dstStep[3], const prim_size_t* roi) UINT32 dstStep[3], const prim_size_t* roi)
{ {
const UINT32 bpp = GetBytesPerPixel(SrcFormat); const UINT32 bpp = FreeRDPGetBytesPerPixel(SrcFormat);
UINT32 x, y; UINT32 x, y;
UINT32 nWidth, nHeight; UINT32 nWidth, nHeight;
nWidth = roi->width; nWidth = roi->width;
@ -626,8 +626,8 @@ static pstatus_t general_RGBToYUV444_8u_P3AC4R(const BYTE* pSrc, UINT32 SrcForma
for (x = 0; x < nWidth; x++) for (x = 0; x < nWidth; x++)
{ {
BYTE B, G, R; BYTE B, G, R;
const UINT32 color = ReadColor(&pRGB[x * bpp], SrcFormat); const UINT32 color = FreeRDPReadColor(&pRGB[x * bpp], SrcFormat);
SplitColor(color, SrcFormat, &R, &G, &B, NULL, NULL); FreeRDPSplitColor(color, SrcFormat, &R, &G, &B, NULL, NULL);
pY[x] = RGB2Y(R, G, B); pY[x] = RGB2Y(R, G, B);
pU[x] = RGB2U(R, G, B); pU[x] = RGB2U(R, G, B);
pV[x] = RGB2V(R, G, B); pV[x] = RGB2V(R, G, B);
@ -773,7 +773,7 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* pSrc, UINT32 srcForm
BYTE* pDst[3], const UINT32 dstStep[3], BYTE* pDst[3], const UINT32 dstStep[3],
const prim_size_t* roi) const prim_size_t* roi)
{ {
const UINT32 bpp = GetBytesPerPixel(srcFormat); const UINT32 bpp = FreeRDPGetBytesPerPixel(srcFormat);
UINT32 x, y, i; UINT32 x, y, i;
size_t x1 = 0, x2 = bpp, x3 = srcStep, x4 = srcStep + bpp; size_t x1 = 0, x2 = bpp, x3 = srcStep, x4 = srcStep + bpp;
size_t y1 = 0, y2 = 1, y3 = dstStep[0], y4 = dstStep[0] + 1; size_t y1 = 0, y2 = 1, y3 = dstStep[0], y4 = dstStep[0] + 1;
@ -793,8 +793,8 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* pSrc, UINT32 srcForm
INT32 Ra, Ga, Ba; INT32 Ra, Ga, Ba;
UINT32 color; UINT32 color;
/* row 1, pixel 1 */ /* row 1, pixel 1 */
color = ReadColor(src + x1, srcFormat); color = FreeRDPReadColor(src + x1, srcFormat);
SplitColor(color, srcFormat, &R, &G, &B, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &R, &G, &B, NULL, NULL);
Ra = R; Ra = R;
Ga = G; Ga = G;
Ba = B; Ba = B;
@ -803,8 +803,8 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* pSrc, UINT32 srcForm
if (x < max_x) if (x < max_x)
{ {
/* row 1, pixel 2 */ /* row 1, pixel 2 */
color = ReadColor(src + x2, srcFormat); color = FreeRDPReadColor(src + x2, srcFormat);
SplitColor(color, srcFormat, &R, &G, &B, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &R, &G, &B, NULL, NULL);
Ra += R; Ra += R;
Ga += G; Ga += G;
Ba += B; Ba += B;
@ -814,8 +814,8 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* pSrc, UINT32 srcForm
if (y < max_y) if (y < max_y)
{ {
/* row 2, pixel 1 */ /* row 2, pixel 1 */
color = ReadColor(src + x3, srcFormat); color = FreeRDPReadColor(src + x3, srcFormat);
SplitColor(color, srcFormat, &R, &G, &B, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &R, &G, &B, NULL, NULL);
Ra += R; Ra += R;
Ga += G; Ga += G;
Ba += B; Ba += B;
@ -824,8 +824,8 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* pSrc, UINT32 srcForm
if (x < max_x) if (x < max_x)
{ {
/* row 2, pixel 2 */ /* row 2, pixel 2 */
color = ReadColor(src + x4, srcFormat); color = FreeRDPReadColor(src + x4, srcFormat);
SplitColor(color, srcFormat, &R, &G, &B, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &R, &G, &B, NULL, NULL);
Ra += R; Ra += R;
Ga += G; Ga += G;
Ba += B; Ba += B;
@ -1132,7 +1132,7 @@ static INLINE void general_RGBToAVC444YUV_ANY_DOUBLE_ROW(const BYTE* srcEven, co
BYTE* b1Odd, BYTE* b2, BYTE* b3, BYTE* b4, BYTE* b1Odd, BYTE* b2, BYTE* b3, BYTE* b4,
BYTE* b5, BYTE* b6, BYTE* b7, UINT32 width) BYTE* b5, BYTE* b6, BYTE* b7, UINT32 width)
{ {
const UINT32 bpp = GetBytesPerPixel(srcFormat); const UINT32 bpp = FreeRDPGetBytesPerPixel(srcFormat);
UINT32 x; UINT32 x;
for (x = 0; x < width; x += 2) for (x = 0; x < width; x += 2)
@ -1143,9 +1143,9 @@ static INLINE void general_RGBToAVC444YUV_ANY_DOUBLE_ROW(const BYTE* srcEven, co
/* Read 4 pixels, 2 from even, 2 from odd lines */ /* Read 4 pixels, 2 from even, 2 from odd lines */
{ {
BYTE r, g, b; BYTE r, g, b;
const UINT32 color = ReadColor(srcEven, srcFormat); const UINT32 color = FreeRDPReadColor(srcEven, srcFormat);
srcEven += bpp; srcEven += bpp;
SplitColor(color, srcFormat, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, NULL, NULL);
Y1e = Y2e = Y1o = Y2o = RGB2Y(r, g, b); Y1e = Y2e = Y1o = Y2o = RGB2Y(r, g, b);
U1e = U2e = U1o = U2o = RGB2U(r, g, b); U1e = U2e = U1o = U2o = RGB2U(r, g, b);
V1e = V2e = V1o = V2o = RGB2V(r, g, b); V1e = V2e = V1o = V2o = RGB2V(r, g, b);
@ -1154,9 +1154,9 @@ static INLINE void general_RGBToAVC444YUV_ANY_DOUBLE_ROW(const BYTE* srcEven, co
if (!lastX) if (!lastX)
{ {
BYTE r, g, b; BYTE r, g, b;
const UINT32 color = ReadColor(srcEven, srcFormat); const UINT32 color = FreeRDPReadColor(srcEven, srcFormat);
srcEven += bpp; srcEven += bpp;
SplitColor(color, srcFormat, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, NULL, NULL);
Y2e = RGB2Y(r, g, b); Y2e = RGB2Y(r, g, b);
U2e = RGB2U(r, g, b); U2e = RGB2U(r, g, b);
V2e = RGB2V(r, g, b); V2e = RGB2V(r, g, b);
@ -1165,9 +1165,9 @@ static INLINE void general_RGBToAVC444YUV_ANY_DOUBLE_ROW(const BYTE* srcEven, co
if (b1Odd) if (b1Odd)
{ {
BYTE r, g, b; BYTE r, g, b;
const UINT32 color = ReadColor(srcOdd, srcFormat); const UINT32 color = FreeRDPReadColor(srcOdd, srcFormat);
srcOdd += bpp; srcOdd += bpp;
SplitColor(color, srcFormat, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, NULL, NULL);
Y1o = Y2o = RGB2Y(r, g, b); Y1o = Y2o = RGB2Y(r, g, b);
U1o = U2o = RGB2U(r, g, b); U1o = U2o = RGB2U(r, g, b);
V1o = V2o = RGB2V(r, g, b); V1o = V2o = RGB2V(r, g, b);
@ -1176,9 +1176,9 @@ static INLINE void general_RGBToAVC444YUV_ANY_DOUBLE_ROW(const BYTE* srcEven, co
if (b1Odd && !lastX) if (b1Odd && !lastX)
{ {
BYTE r, g, b; BYTE r, g, b;
const UINT32 color = ReadColor(srcOdd, srcFormat); const UINT32 color = FreeRDPReadColor(srcOdd, srcFormat);
srcOdd += bpp; srcOdd += bpp;
SplitColor(color, srcFormat, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, NULL, NULL);
Y2o = RGB2Y(r, g, b); Y2o = RGB2Y(r, g, b);
U2o = RGB2U(r, g, b); U2o = RGB2U(r, g, b);
V2o = RGB2V(r, g, b); V2o = RGB2V(r, g, b);
@ -1359,7 +1359,7 @@ static INLINE void general_RGBToAVC444YUVv2_ANY_DOUBLE_ROW(
BYTE* vChromaDst1, BYTE* vChromaDst2, UINT32 width) BYTE* vChromaDst1, BYTE* vChromaDst2, UINT32 width)
{ {
UINT32 x; UINT32 x;
const UINT32 bpp = GetBytesPerPixel(srcFormat); const UINT32 bpp = FreeRDPGetBytesPerPixel(srcFormat);
for (x = 0; x < width; x += 2) for (x = 0; x < width; x += 2)
{ {
@ -1369,9 +1369,9 @@ static INLINE void general_RGBToAVC444YUVv2_ANY_DOUBLE_ROW(
BYTE Yd, Ud, Vd; BYTE Yd, Ud, Vd;
{ {
BYTE b, g, r; BYTE b, g, r;
const UINT32 color = ReadColor(srcEven, srcFormat); const UINT32 color = FreeRDPReadColor(srcEven, srcFormat);
srcEven += bpp; srcEven += bpp;
SplitColor(color, srcFormat, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, NULL, NULL);
Ya = RGB2Y(r, g, b); Ya = RGB2Y(r, g, b);
Ua = RGB2U(r, g, b); Ua = RGB2U(r, g, b);
Va = RGB2V(r, g, b); Va = RGB2V(r, g, b);
@ -1380,9 +1380,9 @@ static INLINE void general_RGBToAVC444YUVv2_ANY_DOUBLE_ROW(
if (x < width - 1) if (x < width - 1)
{ {
BYTE b, g, r; BYTE b, g, r;
const UINT32 color = ReadColor(srcEven, srcFormat); const UINT32 color = FreeRDPReadColor(srcEven, srcFormat);
srcEven += bpp; srcEven += bpp;
SplitColor(color, srcFormat, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, NULL, NULL);
Yb = RGB2Y(r, g, b); Yb = RGB2Y(r, g, b);
Ub = RGB2U(r, g, b); Ub = RGB2U(r, g, b);
Vb = RGB2V(r, g, b); Vb = RGB2V(r, g, b);
@ -1397,9 +1397,9 @@ static INLINE void general_RGBToAVC444YUVv2_ANY_DOUBLE_ROW(
if (srcOdd) if (srcOdd)
{ {
BYTE b, g, r; BYTE b, g, r;
const UINT32 color = ReadColor(srcOdd, srcFormat); const UINT32 color = FreeRDPReadColor(srcOdd, srcFormat);
srcOdd += bpp; srcOdd += bpp;
SplitColor(color, srcFormat, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, NULL, NULL);
Yc = RGB2Y(r, g, b); Yc = RGB2Y(r, g, b);
Uc = RGB2U(r, g, b); Uc = RGB2U(r, g, b);
Vc = RGB2V(r, g, b); Vc = RGB2V(r, g, b);
@ -1414,9 +1414,9 @@ static INLINE void general_RGBToAVC444YUVv2_ANY_DOUBLE_ROW(
if (srcOdd && (x < width - 1)) if (srcOdd && (x < width - 1))
{ {
BYTE b, g, r; BYTE b, g, r;
const UINT32 color = ReadColor(srcOdd, srcFormat); const UINT32 color = FreeRDPReadColor(srcOdd, srcFormat);
srcOdd += bpp; srcOdd += bpp;
SplitColor(color, srcFormat, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(color, srcFormat, &r, &g, &b, NULL, NULL);
Yd = RGB2Y(r, g, b); Yd = RGB2Y(r, g, b);
Ud = RGB2U(r, g, b); Ud = RGB2U(r, g, b);
Vd = RGB2V(r, g, b); Vd = RGB2V(r, g, b);

View File

@ -40,7 +40,7 @@ static pstatus_t general_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const pSrc[3]
const INT16* pCr = pSrc[2]; const INT16* pCr = pSrc[2];
const size_t srcPad = (srcStep - (roi->width * 2)) / 2; const size_t srcPad = (srcStep - (roi->width * 2)) / 2;
const size_t dstPad = (dstStep - (roi->width * 4)); const size_t dstPad = (dstStep - (roi->width * 4));
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
for (y = 0; y < roi->height; y++) for (y = 0; y < roi->height; y++)
{ {
@ -82,7 +82,7 @@ static pstatus_t general_yCbCrToRGB_16s8u_P3AC4R_general(const INT16* const pSrc
const size_t srcPad = (srcStep - (roi->width * 2)) / 2; const size_t srcPad = (srcStep - (roi->width * 2)) / 2;
const size_t dstPad = (dstStep - (roi->width * 4)); const size_t dstPad = (dstStep - (roi->width * 4));
const fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, FALSE); const fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, FALSE);
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
for (y = 0; y < roi->height; y++) for (y = 0; y < roi->height; y++)
{ {
@ -448,7 +448,7 @@ general_RGBToRGB_16s8u_P3AC4R_general(const INT16* const pSrc[3], /* 16-bit R,G,
UINT32 y; UINT32 y;
const DWORD srcAdd = srcStep / sizeof(INT16); const DWORD srcAdd = srcStep / sizeof(INT16);
fkt_writeScanline writeScanline = getScanlineWriteFunction(DstFormat); fkt_writeScanline writeScanline = getScanlineWriteFunction(DstFormat);
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
for (y = 0; y < roi->height; ++y) for (y = 0; y < roi->height; ++y)
{ {
@ -475,7 +475,7 @@ general_RGBToRGB_16s8u_P3AC4R_BGRX(const INT16* const pSrc[3], /* 16-bit R,G, an
const INT16* b = pSrc[2]; const INT16* b = pSrc[2];
UINT32 y; UINT32 y;
const DWORD srcAdd = srcStep / sizeof(INT16); const DWORD srcAdd = srcStep / sizeof(INT16);
const DWORD formatSize = GetBytesPerPixel(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
for (y = 0; y < roi->height; ++y) for (y = 0; y < roi->height; ++y)
{ {

View File

@ -159,7 +159,7 @@ static INLINE BYTE* writePixelGenericAlpha(BYTE* dst, DWORD formatSize, UINT32 f
BYTE G, BYTE B, BYTE A) BYTE G, BYTE B, BYTE A)
{ {
UINT32 color = FreeRDPGetColor(format, R, G, B, A); UINT32 color = FreeRDPGetColor(format, R, G, B, A);
WriteColor(dst, format, color); FreeRDPWriteColor(dst, format, color);
return dst + formatSize; return dst + formatSize;
} }
@ -167,7 +167,7 @@ static INLINE BYTE* writePixelGeneric(BYTE* dst, DWORD formatSize, UINT32 format
BYTE B, BYTE A) BYTE B, BYTE A)
{ {
UINT32 color = FreeRDPGetColor(format, R, G, B, A); UINT32 color = FreeRDPGetColor(format, R, G, B, A);
WriteColorIgnoreAlpha(dst, format, color); FreeRDPWriteColorIgnoreAlpha(dst, format, color);
return dst + formatSize; return dst + formatSize;
} }

View File

@ -28,6 +28,7 @@
#include "prim_internal.h" #include "prim_internal.h"
#include <freerdp/log.h>
#define TAG FREERDP_TAG("primitives") #define TAG FREERDP_TAG("primitives")
/* hints to know which kind of primitives to use */ /* hints to know which kind of primitives to use */

View File

@ -86,8 +86,8 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_func(prim_size_t roi, DWORD DstFormat)
{ {
for (i = 0; i < roi.width * roi.height; ++i) for (i = 0; i < roi.width * roi.height; ++i)
{ {
const UINT32 o1 = ReadColor(out1 + 4 * i, DstFormat); const UINT32 o1 = FreeRDPReadColor(out1 + 4 * i, DstFormat);
const UINT32 o2 = ReadColor(out2 + 4 * i, DstFormat); const UINT32 o2 = FreeRDPReadColor(out2 + 4 * i, DstFormat);
if (o1 != o2) if (o1 != o2)
{ {

View File

@ -1536,8 +1536,8 @@ static int test_bmp_cmp_dump(const BYTE* actual, const BYTE* expected, int size,
BYTE R, G, B; BYTE R, G, B;
BYTE eR, eG, eB; BYTE eR, eG, eB;
SplitColor(pixel, PIXEL_FORMAT_XRGB32, &R, &G, &B, NULL, NULL); FreeRDPSplitColor(pixel, PIXEL_FORMAT_XRGB32, &R, &G, &B, NULL, NULL);
SplitColor(ePixel, PIXEL_FORMAT_XRGB32, &eR, &eG, &eB, NULL, NULL); FreeRDPSplitColor(ePixel, PIXEL_FORMAT_XRGB32, &eR, &eG, &eB, NULL, NULL);
error[0] = (R > eR) ? R - eR : eR - R; error[0] = (R > eR) ? R - eR : eR - R;
error[1] = (G > eG) ? G - eG : eG - G; error[1] = (G > eG) ? G - eG : eG - G;
error[2] = (B > eB) ? B - eB : eB - B; error[2] = (B > eB) ? B - eB : eB - B;
@ -1571,7 +1571,7 @@ static int test_PrimitivesYCbCr(const primitives_t* prims, UINT32 format, prim_s
int margin = 1; int margin = 1;
INT16* pYCbCr[3] = { NULL, NULL, NULL }; INT16* pYCbCr[3] = { NULL, NULL, NULL };
const UINT32 srcStride = roi.width * 2; const UINT32 srcStride = roi.width * 2;
const UINT32 dstStride = roi.width * GetBytesPerPixel(format); const UINT32 dstStride = roi.width * FreeRDPGetBytesPerPixel(format);
const UINT32 srcSize = srcStride * roi.height; const UINT32 srcSize = srcStride * roi.height;
const UINT32 dstSize = dstStride * roi.height; const UINT32 dstSize = dstStride * roi.height;
PROFILER_DEFINE(prof) PROFILER_DEFINE(prof)

View File

@ -48,7 +48,7 @@ static BOOL test_YCoCgRToRGB_8u_AC4R_func(UINT32 width, UINT32 height)
for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++)
{ {
const UINT32 format = formats[x]; const UINT32 format = formats[x];
const UINT32 dstStride = width * GetBytesPerPixel(format); const UINT32 dstStride = width * FreeRDPGetBytesPerPixel(format);
const char* formatName = FreeRDPGetColorFormatName(format); const char* formatName = FreeRDPGetColorFormatName(format);
PROFILER_CREATE(genericProf, "YCoCgRToRGB_8u_AC4R-GENERIC") PROFILER_CREATE(genericProf, "YCoCgRToRGB_8u_AC4R-GENERIC")
PROFILER_CREATE(optProf, "YCoCgRToRGB_8u_AC4R-OPT") PROFILER_CREATE(optProf, "YCoCgRToRGB_8u_AC4R-OPT")
@ -72,8 +72,8 @@ static BOOL test_YCoCgRToRGB_8u_AC4R_func(UINT32 width, UINT32 height)
{ {
for (i = 0; i < width * height; ++i) for (i = 0; i < width * height; ++i)
{ {
const UINT32 c = ReadColor(out_c + 4 * i, format); const UINT32 c = FreeRDPReadColor(out_c + 4 * i, format);
const UINT32 sse = ReadColor(out_sse + 4 * i, format); const UINT32 sse = FreeRDPReadColor(out_sse + 4 * i, format);
if (c != sse) if (c != sse)
{ {

View File

@ -38,9 +38,9 @@ static BOOL similar(const BYTE* src, const BYTE* dst, size_t size)
static BOOL similarRGB(const BYTE* src, const BYTE* dst, size_t size, UINT32 format, BOOL use444) static BOOL similarRGB(const BYTE* src, const BYTE* dst, size_t size, UINT32 format, BOOL use444)
{ {
size_t x; size_t x;
const UINT32 bpp = GetBytesPerPixel(format); const UINT32 bpp = FreeRDPGetBytesPerPixel(format);
BYTE fill = PADDING_FILL_VALUE; BYTE fill = PADDING_FILL_VALUE;
if (!ColorHasAlpha(format)) if (!FreeRDPColorHasAlpha(format))
fill = 0xFF; fill = 0xFF;
for (x = 0; x < size; x++) for (x = 0; x < size; x++)
@ -49,12 +49,12 @@ static BOOL similarRGB(const BYTE* src, const BYTE* dst, size_t size, UINT32 for
UINT32 sColor, dColor; UINT32 sColor, dColor;
BYTE sR, sG, sB, sA; BYTE sR, sG, sB, sA;
BYTE dR, dG, dB, dA; BYTE dR, dG, dB, dA;
sColor = ReadColor(src, format); sColor = FreeRDPReadColor(src, format);
dColor = ReadColor(dst, format); dColor = FreeRDPReadColor(dst, format);
src += bpp; src += bpp;
dst += bpp; dst += bpp;
SplitColor(sColor, format, &sR, &sG, &sB, &sA, NULL); FreeRDPSplitColor(sColor, format, &sR, &sG, &sB, &sA, NULL);
SplitColor(dColor, format, &dR, &dG, &dB, &dA, NULL); FreeRDPSplitColor(dColor, format, &dR, &dG, &dB, &dA, NULL);
if ((abs(sR - dR) > maxDiff) || (abs(sG - dG) > maxDiff) || (abs(sB - dB) > maxDiff)) if ((abs(sR - dR) > maxDiff) || (abs(sG - dG) > maxDiff) || (abs(sB - dB) > maxDiff))
{ {

View File

@ -38,6 +38,7 @@
#include "wf_interface.h" #include "wf_interface.h"
#include <freerdp/log.h>
#define TAG SERVER_TAG("windows") #define TAG SERVER_TAG("windows")
#define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server" #define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server"

View File

@ -38,6 +38,7 @@
#include "wf_peer.h" #include "wf_peer.h"
#include <freerdp/peer.h> #include <freerdp/peer.h>
#include <freerdp/log.h>
#define TAG SERVER_TAG("windows") #define TAG SERVER_TAG("windows")
#define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING #define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING

View File

@ -39,6 +39,7 @@
#endif #endif
#include <freerdp/log.h>
#define TAG SERVER_TAG("windows") #define TAG SERVER_TAG("windows")
static void wf_peer_rdpsnd_activated(RdpsndServerContext* context) static void wf_peer_rdpsnd_activated(RdpsndServerContext* context)

View File

@ -33,6 +33,7 @@
#include "wf_update.h" #include "wf_update.h"
#include <freerdp/log.h>
#define TAG SERVER_TAG("windows") #define TAG SERVER_TAG("windows")
DWORD WINAPI wf_update_thread(LPVOID lpParam) DWORD WINAPI wf_update_thread(LPVOID lpParam)

View File

@ -7,6 +7,7 @@
#include <functiondiscoverykeys_devpkey.h> #include <functiondiscoverykeys_devpkey.h>
#include <audioclient.h> #include <audioclient.h>
#include <freerdp/log.h>
#define TAG SERVER_TAG("windows") #define TAG SERVER_TAG("windows")
//#define REFTIMES_PER_SEC 10000000 //#define REFTIMES_PER_SEC 10000000

View File

@ -327,8 +327,8 @@ static int freerdp_image_copy_from_retina(BYTE* pDstData, DWORD DstFormat, int n
if (nSrcStep < 0) if (nSrcStep < 0)
nSrcStep = srcBytesPerPixel * nWidth; nSrcStep = srcBytesPerPixel * nWidth;
dstBitsPerPixel = GetBitsPerPixel(DstFormat); dstBitsPerPixel = FreeRDPGetBitsPerPixel(DstFormat);
dstBytesPerPixel = GetBytesPerPixel(DstFormat); dstBytesPerPixel = FreeRDPGetBytesPerPixel(DstFormat);
if (nDstStep < 0) if (nDstStep < 0)
nDstStep = dstBytesPerPixel * nWidth; nDstStep = dstBytesPerPixel * nWidth;

View File

@ -27,6 +27,8 @@
#include <winpr/tools/makecert.h> #include <winpr/tools/makecert.h>
#include <freerdp/server/shadow.h> #include <freerdp/server/shadow.h>
#include <freerdp/log.h>
#define TAG SERVER_TAG("shadow") #define TAG SERVER_TAG("shadow")
int main(int argc, char** argv) int main(int argc, char** argv)

View File

@ -1229,7 +1229,8 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
BOOL rc; BOOL rc;
const UINT32 w = cmd.right - cmd.left; const UINT32 w = cmd.right - cmd.left;
const UINT32 h = cmd.bottom - cmd.top; const UINT32 h = cmd.bottom - cmd.top;
const BYTE* src = &pSrcData[cmd.top * nSrcStep + cmd.left * GetBytesPerPixel(SrcFormat)]; const BYTE* src =
&pSrcData[cmd.top * nSrcStep + cmd.left * FreeRDPGetBytesPerPixel(SrcFormat)];
if (shadow_encoder_prepare(encoder, FREERDP_CODEC_PLANAR) < 0) if (shadow_encoder_prepare(encoder, FREERDP_CODEC_PLANAR) < 0)
{ {
WLog_ERR(TAG, "Failed to prepare encoder FREERDP_CODEC_PLANAR"); WLog_ERR(TAG, "Failed to prepare encoder FREERDP_CODEC_PLANAR");

View File

@ -24,6 +24,7 @@
#include "shadow_encoder.h" #include "shadow_encoder.h"
#include <freerdp/log.h>
#define TAG CLIENT_TAG("shadow") #define TAG CLIENT_TAG("shadow")
UINT32 shadow_encoder_preferred_fps(rdpShadowEncoder* encoder) UINT32 shadow_encoder_preferred_fps(rdpShadowEncoder* encoder)