2 * FreeRDP: A Remote Desktop Protocol Client
3 * Color Conversion Unit Tests
5 * Copyright 2010 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <freerdp/freerdp.h>
23 #include <freerdp/gdi/gdi.h>
24 #include <freerdp/common/color.h>
25 #include "test_color.h"
27 int init_color_suite(void)
32 int clean_color_suite(void)
37 int add_color_suite(void)
39 add_test_suite(color);
41 add_test_function(color_GetRGB32);
42 add_test_function(color_GetBGR32);
43 add_test_function(color_GetRGB_565);
44 add_test_function(color_GetRGB16);
45 add_test_function(color_GetBGR_565);
46 add_test_function(color_GetBGR16);
51 /* GDI Color Space Conversions: http://msdn.microsoft.com/en-us/library/ff566496(VS.85).aspx */
53 void test_color_GetRGB32(void)
56 uint32 rgb32 = 0x00AABBCC;
57 GetRGB32(r, g, b, rgb32);
64 void test_color_GetBGR32(void)
67 uint32 bgr32 = 0x00CCBBAA;
68 GetBGR32(r, g, b, bgr32);
75 void test_color_GetRGB_565(void)
82 0xAE7D, 10101110 01111101
86 uint16 rgb16 = 0xAE7D;
87 GetRGB_565(r, g, b, rgb16);
94 void test_color_GetRGB16(void)
97 R: 0x15 -> 0xAD, 10101 -> 10101101
98 G: 0x33 -> 0xCF, 110011 -> 11001111
99 B: 0x1D -> 0xEF, 11101 -> 11101101
102 10101110 01111101 -> 10101101 11001111 11101101
106 uint16 rgb16 = 0xAE7D;
107 GetRGB16(r, g, b, rgb16);
109 CU_ASSERT(r == 0xAD);
110 CU_ASSERT(g == 0xCF);
111 CU_ASSERT(b == 0xEF);
114 void test_color_GetBGR_565(void)
121 0xEE75, 11101110 01110101
125 uint16 bgr16 = 0xEE75;
126 GetBGR_565(r, g, b, bgr16);
128 CU_ASSERT(r == 0x15);
129 CU_ASSERT(g == 0x33);
130 CU_ASSERT(b == 0x1D);
133 void test_color_GetBGR16(void)
136 B: 0x1D -> 0xEF, 11101 -> 11101101
137 G: 0x33 -> 0xCF, 110011 -> 11001111
138 R: 0x15 -> 0xAD, 10101 -> 10101101
141 11101110 01110101 -> 10101101 11001111 11101101
145 uint16 bgr16 = 0xEE75;
146 GetBGR16(r, g, b, bgr16);
148 CU_ASSERT(r == 0xAD);
149 CU_ASSERT(g == 0xCF);
150 CU_ASSERT(b == 0xEF);