2014-11-20 21:06:39 -08:00
|
|
|
/*
|
2016-03-25 12:59:40 -07: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-20 21:06:39 -08:00
|
|
|
*
|
2016-03-25 12:59:40 -07:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-11-20 21:06:39 -08:00
|
|
|
*
|
2016-03-25 12:59:40 -07: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-20 21:06:39 -08:00
|
|
|
*/
|
|
|
|
|
2019-12-23 12:48:22 -08:00
|
|
|
#include "settings.h"
|
2014-11-20 21:06:39 -08:00
|
|
|
|
|
|
|
#include <freerdp/codec/color.h>
|
|
|
|
#include <freerdp/freerdp.h>
|
2019-09-22 14:36:34 -07:00
|
|
|
#include <freerdp/gdi/gdi.h>
|
2014-11-20 21:06:39 -08:00
|
|
|
#include <winpr/wtypes.h>
|
|
|
|
|
2020-01-04 13:07:28 -08:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2020-01-04 01:11:05 -08:00
|
|
|
UINT32 guac_rdp_get_native_pixel_format(BOOL alpha) {
|
2019-09-21 16:09:50 -07:00
|
|
|
|
2020-01-04 01:11:05 -08:00
|
|
|
uint8_t color[] = { 0x0A, 0x0B, 0x0C, 0x0D };
|
2019-09-21 16:09:50 -07:00
|
|
|
|
2020-01-04 01:11:05 -08:00
|
|
|
/* Local platform stores bytes in decreasing order of significance
|
|
|
|
* (big-endian) */
|
|
|
|
if (*((uint32_t*) color) == 0x0A0B0C0D)
|
|
|
|
return alpha ? PIXEL_FORMAT_ARGB32 : PIXEL_FORMAT_XRGB32;
|
2019-09-21 16:09:50 -07:00
|
|
|
|
2020-01-04 01:11:05 -08:00
|
|
|
/* Local platform stores bytes in increasing order of significance
|
|
|
|
* (little-endian) */
|
|
|
|
else
|
|
|
|
return alpha ? PIXEL_FORMAT_BGRA32 : PIXEL_FORMAT_BGRX32;
|
2019-09-21 16:09:50 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-11-20 21:06:39 -08:00
|
|
|
UINT32 guac_rdp_convert_color(rdpContext* context, UINT32 color) {
|
|
|
|
|
2019-09-21 16:09:50 -07:00
|
|
|
int depth = guac_rdp_get_depth(context->instance);
|
2020-01-06 11:04:12 -08:00
|
|
|
int src_format = gdi_get_pixel_format(depth);
|
|
|
|
int dst_format = guac_rdp_get_native_pixel_format(TRUE);
|
2019-09-21 16:09:50 -07:00
|
|
|
rdpGdi* gdi = context->gdi;
|
2015-01-23 15:08:00 -08:00
|
|
|
|
2020-01-06 11:04:12 -08:00
|
|
|
/* Convert provided color into the intermediate representation expected by
|
|
|
|
* FreeRDPConvertColor() */
|
|
|
|
UINT32 intermed = ReadColor((BYTE*) &color, src_format);
|
|
|
|
|
|
|
|
/* Convert color from RDP source format to the native format used by Cairo,
|
|
|
|
* still maintaining intermediate representation */
|
|
|
|
intermed = FreeRDPConvertColor(intermed, src_format, dst_format,
|
|
|
|
&gdi->palette);
|
|
|
|
|
|
|
|
/* Convert color from intermediate representation to the actual desired
|
|
|
|
* format */
|
|
|
|
WriteColor((BYTE*) &color, dst_format, intermed);
|
|
|
|
return color;
|
2015-01-23 15:08:00 -08:00
|
|
|
|
2014-11-20 21:06:39 -08:00
|
|
|
}
|
|
|
|
|