~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/windowscodecs/tests/palette.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Copyright 2009 Vincent Povirk for CodeWeavers
  3  *
  4  * This library is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2.1 of the License, or (at your option) any later version.
  8  *
  9  * This library is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with this library; if not, write to the Free Software
 16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 17  */
 18 
 19 #include <stdarg.h>
 20 
 21 #define COBJMACROS
 22 
 23 #include "windef.h"
 24 #include "objbase.h"
 25 #include "wincodec.h"
 26 #include "wine/test.h"
 27 
 28 static void test_custom_palette(void)
 29 {
 30     IWICImagingFactory *factory;
 31     IWICPalette *palette;
 32     HRESULT hr;
 33     WICBitmapPaletteType type=0xffffffff;
 34     UINT count=1;
 35     const WICColor initcolors[4]={0xff000000,0xff0000ff,0xffffff00,0xffffffff};
 36     WICColor colors[4];
 37     BOOL boolresult;
 38 
 39     hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
 40         &IID_IWICImagingFactory, (void**)&factory);
 41     ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
 42     if (FAILED(hr)) return;
 43 
 44     hr = IWICImagingFactory_CreatePalette(factory, &palette);
 45     ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
 46     if (SUCCEEDED(hr))
 47     {
 48         hr = IWICPalette_GetType(palette, &type);
 49         ok(SUCCEEDED(hr), "GetType failed, hr=%x\n", hr);
 50         ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %x\n", type);
 51 
 52         hr = IWICPalette_GetColorCount(palette, &count);
 53         ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
 54         ok(count == 0, "expected 0, got %u\n", count);
 55 
 56         hr = IWICPalette_GetColors(palette, 0, colors, &count);
 57         ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
 58         ok(count == 0, "expected 0, got %u\n", count);
 59 
 60         hr = IWICPalette_GetColors(palette, 4, colors, &count);
 61         ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
 62         ok(count == 0, "expected 0, got %u\n", count);
 63 
 64         memcpy(colors, initcolors, sizeof(initcolors));
 65         hr = IWICPalette_InitializeCustom(palette, colors, 4);
 66         ok(SUCCEEDED(hr), "InitializeCustom failed, hr=%x\n", hr);
 67 
 68         hr = IWICPalette_GetType(palette, &type);
 69         ok(SUCCEEDED(hr), "GetType failed, hr=%x\n", hr);
 70         ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %x\n", type);
 71 
 72         hr = IWICPalette_GetColorCount(palette, &count);
 73         ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
 74         ok(count == 4, "expected 4, got %u\n", count);
 75 
 76         memset(colors, 0, sizeof(colors));
 77         count = 0;
 78         hr = IWICPalette_GetColors(palette, 4, colors, &count);
 79         ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
 80         ok(count == 4, "expected 4, got %u\n", count);
 81         ok(!memcmp(colors, initcolors, sizeof(colors)), "got unexpected palette data\n");
 82 
 83         memset(colors, 0, sizeof(colors));
 84         count = 0;
 85         hr = IWICPalette_GetColors(palette, 2, colors, &count);
 86         ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
 87         ok(count == 2, "expected 2, got %u\n", count);
 88         ok(!memcmp(colors, initcolors, sizeof(WICColor)*2), "got unexpected palette data\n");
 89 
 90         count = 0;
 91         hr = IWICPalette_GetColors(palette, 6, colors, &count);
 92         ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
 93         ok(count == 4, "expected 4, got %u\n", count);
 94 
 95         hr = IWICPalette_HasAlpha(palette, &boolresult);
 96         ok(SUCCEEDED(hr), "HasAlpha failed, hr=%x\n", hr);
 97         ok(!boolresult, "expected FALSE, got TRUE\n");
 98 
 99         hr = IWICPalette_IsBlackWhite(palette, &boolresult);
100         ok(SUCCEEDED(hr), "IsBlackWhite failed, hr=%x\n", hr);
101         ok(!boolresult, "expected FALSE, got TRUE\n");
102 
103         hr = IWICPalette_IsGrayscale(palette, &boolresult);
104         ok(SUCCEEDED(hr), "IsGrayscale failed, hr=%x\n", hr);
105         ok(!boolresult, "expected FALSE, got TRUE\n");
106 
107         /* try a palette with some alpha in it */
108         colors[2] = 0x80ffffff;
109         hr = IWICPalette_InitializeCustom(palette, colors, 4);
110         ok(SUCCEEDED(hr), "InitializeCustom failed, hr=%x\n", hr);
111 
112         hr = IWICPalette_HasAlpha(palette, &boolresult);
113         ok(SUCCEEDED(hr), "HasAlpha failed, hr=%x\n", hr);
114         ok(boolresult, "expected TRUE, got FALSE\n");
115 
116         /* setting to a 0-color palette is acceptable */
117         hr = IWICPalette_InitializeCustom(palette, NULL, 0);
118         ok(SUCCEEDED(hr), "InitializeCustom failed, hr=%x\n", hr);
119 
120         /* IWICPalette is paranoid about NULL pointers */
121         hr = IWICPalette_GetType(palette, NULL);
122         ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
123 
124         hr = IWICPalette_GetColorCount(palette, NULL);
125         ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
126 
127         hr = IWICPalette_InitializeCustom(palette, NULL, 4);
128         ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
129 
130         hr = IWICPalette_GetColors(palette, 4, NULL, &count);
131         ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
132 
133         hr = IWICPalette_GetColors(palette, 4, colors, NULL);
134         ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
135 
136         hr = IWICPalette_HasAlpha(palette, NULL);
137         ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
138 
139         hr = IWICPalette_IsBlackWhite(palette, NULL);
140         ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
141 
142         hr = IWICPalette_IsGrayscale(palette, NULL);
143         ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
144 
145         IWICPalette_Release(palette);
146     }
147 
148     IWICImagingFactory_Release(factory);
149 }
150 
151 START_TEST(palette)
152 {
153     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
154 
155     test_custom_palette();
156 
157     CoUninitialize();
158 }
159 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.