2014-11-21 05:06:39 +00:00
|
|
|
/*
|
2016-03-25 19:59:40 +00:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
2014-11-21 05:06:39 +00:00
|
|
|
*
|
2016-03-25 19:59:40 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-11-21 05:06:39 +00:00
|
|
|
*
|
2016-03-25 19:59:40 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-11-21 05:06:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "client.h"
|
2016-03-01 05:50:00 +00:00
|
|
|
#include "rdp.h"
|
2019-12-23 20:48:22 +00:00
|
|
|
#include "settings.h"
|
2014-11-21 05:06:39 +00:00
|
|
|
|
|
|
|
#include <freerdp/codec/color.h>
|
|
|
|
#include <freerdp/freerdp.h>
|
2019-09-22 21:36:34 +00:00
|
|
|
#include <freerdp/gdi/gdi.h>
|
2014-11-21 05:06:39 +00:00
|
|
|
#include <winpr/wtypes.h>
|
|
|
|
|
2019-09-21 23:09:50 +00:00
|
|
|
/**
|
|
|
|
* Returns the integer constant used by the FreeRDP API to represent the colors
|
|
|
|
* used by a connection having the given bit depth. These constants each have
|
|
|
|
* corresponding PIXEL_FORMAT_* macros defined within freerdp/codec/color.h.
|
|
|
|
*
|
|
|
|
* @param depth
|
|
|
|
* The color depth which should be translated into the integer constant
|
|
|
|
* defined by FreeRDP's corresponding PIXEL_FORMAT_* macro.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* The integer value of the PIXEL_FORMAT_* macro corresponding to the
|
|
|
|
* given color depth.
|
|
|
|
*/
|
|
|
|
static UINT32 guac_rdp_get_pixel_format(int depth) {
|
|
|
|
|
|
|
|
switch (depth) {
|
|
|
|
|
|
|
|
/* 32- and 24-bit RGB (8 bits per color component) */
|
|
|
|
case 32:
|
|
|
|
case 24:
|
2019-09-29 23:08:27 +00:00
|
|
|
return PIXEL_FORMAT_RGB24;
|
2019-09-21 23:09:50 +00:00
|
|
|
|
|
|
|
/* 16-bit palette (6-bit green, 5-bit red and blue) */
|
|
|
|
case 16:
|
|
|
|
return PIXEL_FORMAT_RGB16;
|
|
|
|
|
|
|
|
/* 15-bit RGB (5 bits per color component) */
|
|
|
|
case 15:
|
|
|
|
return PIXEL_FORMAT_RGB15;
|
|
|
|
|
|
|
|
/* 8-bit palette */
|
|
|
|
case 8:
|
|
|
|
return PIXEL_FORMAT_RGB8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unknown format */
|
2019-09-29 23:08:27 +00:00
|
|
|
return PIXEL_FORMAT_RGB24;
|
2019-09-21 23:09:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-11-21 05:06:39 +00:00
|
|
|
UINT32 guac_rdp_convert_color(rdpContext* context, UINT32 color) {
|
|
|
|
|
2019-09-21 23:09:50 +00:00
|
|
|
int depth = guac_rdp_get_depth(context->instance);
|
|
|
|
rdpGdi* gdi = context->gdi;
|
2015-01-23 23:08:00 +00:00
|
|
|
|
|
|
|
/* Convert given color to ARGB32 */
|
2019-09-21 23:09:50 +00:00
|
|
|
return FreeRDPConvertColor(color, guac_rdp_get_pixel_format(depth),
|
2019-09-29 23:08:27 +00:00
|
|
|
PIXEL_FORMAT_BGRA32, &gdi->palette);
|
2015-01-23 23:08:00 +00:00
|
|
|
|
2014-11-21 05:06:39 +00:00
|
|
|
}
|
|
|
|
|