ReactOS  0.4.15-dev-1054-gd029a62
tiffformat.c File Reference
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "wincodec.h"
#include "wine/test.h"
#include "pshpack2.h"
#include "poppack.h"
Include dependency graph for tiffformat.c:

Go to the source code of this file.

Classes

struct  IFD_entry
 
struct  IFD_rational
 
struct  tiff_1bpp_data
 
struct  tiff_8bpp_alpha
 
struct  tiff_8bpp_data
 
struct  tiff_resolution_test_data
 
struct  tiff_resolution_image_data
 
struct  tiff_24bpp_data
 
struct  tiff_4bps_bgra
 
struct  tiff_1x1_data
 

Macros

#define COBJMACROS
 
#define EXPECT_REF(obj, ref)   _expect_ref((IUnknown*)obj, ref, __LINE__)
 
#define IFD_BYTE   1
 
#define IFD_ASCII   2
 
#define IFD_SHORT   3
 
#define IFD_LONG   4
 
#define IFD_RATIONAL   5
 
#define IFD_SBYTE   6
 
#define IFD_UNDEFINED   7
 
#define IFD_SSHORT   8
 
#define IFD_SLONG   9
 
#define IFD_SRATIONAL   10
 
#define IFD_FLOAT   11
 
#define IFD_DOUBLE   12
 

Functions

static void _expect_ref (IUnknown *obj, ULONG ref, int line)
 
static IStreamcreate_stream (const void *data, int data_size)
 
static HRESULT create_decoder (const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
 
static HRESULT get_pixelformat_info (const GUID *format, UINT *bpp, UINT *channels, BOOL *trasparency)
 
static void dump_tiff (void *buf)
 
static void test_tiff_1bpp_palette (void)
 
static void test_QueryCapability (void)
 
static void test_tiff_8bpp_alpha (void)
 
static void generate_tiff_palette (void *buf, unsigned count)
 
static void test_tiff_8bpp_palette (void)
 
static void test_tiff_resolution (void)
 
static void test_tiff_24bpp (void)
 
static UINT width_bytes (UINT width, UINT bpp)
 
static void test_color_formats (void)
 
static void test_tiff_4bps_bgra (void)
 
 START_TEST (tiffformat)
 

Variables

static const struct tiff_1bpp_data tiff_1bpp_data
 
static const struct tiff_8bpp_alpha tiff_8bpp_alpha
 
static const struct tiff_8bpp_data tiff_8bpp_data
 
static const struct tiff_resolution_test_data tiff_resolution_test_data []
 
static struct tiff_resolution_image_data tiff_resolution_image_data
 
static const struct tiff_24bpp_data tiff_24bpp_data
 
static const struct tiff_4bps_bgra tiff_4bps_bgra
 
static IWICImagingFactoryfactory
 
static const struct tiff_1x1_data tiff_1x1_data
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file tiffformat.c.

◆ EXPECT_REF

#define EXPECT_REF (   obj,
  ref 
)    _expect_ref((IUnknown*)obj, ref, __LINE__)

Definition at line 29 of file tiffformat.c.

◆ IFD_ASCII

#define IFD_ASCII   2

Definition at line 39 of file tiffformat.c.

◆ IFD_BYTE

#define IFD_BYTE   1

Definition at line 38 of file tiffformat.c.

◆ IFD_DOUBLE

#define IFD_DOUBLE   12

Definition at line 49 of file tiffformat.c.

◆ IFD_FLOAT

#define IFD_FLOAT   11

Definition at line 48 of file tiffformat.c.

◆ IFD_LONG

#define IFD_LONG   4

Definition at line 41 of file tiffformat.c.

◆ IFD_RATIONAL

#define IFD_RATIONAL   5

Definition at line 42 of file tiffformat.c.

◆ IFD_SBYTE

#define IFD_SBYTE   6

Definition at line 43 of file tiffformat.c.

◆ IFD_SHORT

#define IFD_SHORT   3

Definition at line 40 of file tiffformat.c.

◆ IFD_SLONG

#define IFD_SLONG   9

Definition at line 46 of file tiffformat.c.

◆ IFD_SRATIONAL

#define IFD_SRATIONAL   10

Definition at line 47 of file tiffformat.c.

◆ IFD_SSHORT

#define IFD_SSHORT   8

Definition at line 45 of file tiffformat.c.

◆ IFD_UNDEFINED

#define IFD_UNDEFINED   7

Definition at line 44 of file tiffformat.c.

Function Documentation

◆ _expect_ref()

static void _expect_ref ( IUnknown obj,
ULONG  ref,
int  line 
)
static

Definition at line 30 of file tiffformat.c.

31 {
32  ULONG rc;
33  IUnknown_AddRef(obj);
34  rc = IUnknown_Release(obj);
35  ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
36 }
GLenum GLint ref
Definition: glext.h:6028
Definition: parser.c:48
unsigned int ULONG
Definition: retypes.h:1
#define ok_(x1, x2)
Definition: atltest.h:61

◆ create_decoder()

static HRESULT create_decoder ( const void image_data,
UINT  image_size,
IWICBitmapDecoder **  decoder 
)
static

Definition at line 371 of file tiffformat.c.

372 {
373  HGLOBAL hmem;
374  BYTE *data;
375  HRESULT hr;
376  IStream *stream;
377  GUID format;
378  LONG refcount;
379 
380  *decoder = NULL;
381 
382  hmem = GlobalAlloc(0, image_size);
383  data = GlobalLock(hmem);
384  memcpy(data, image_data, image_size);
385  GlobalUnlock(hmem);
386 
387  hr = CreateStreamOnHGlobal(hmem, TRUE, &stream);
388  ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr);
389 
390  hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, decoder);
391  if (hr == S_OK)
392  {
393  hr = IWICBitmapDecoder_GetContainerFormat(*decoder, &format);
394  ok(hr == S_OK, "GetContainerFormat error %#x\n", hr);
395  ok(IsEqualGUID(&format, &GUID_ContainerFormatTiff),
396  "wrong container format %s\n", wine_dbgstr_guid(&format));
397 
398  refcount = IStream_Release(stream);
399  ok(refcount > 0, "expected stream refcount > 0\n");
400  }
401 
402  return hr;
403 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
const char * wine_dbgstr_guid(const GUID *guid)
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
long LONG
Definition: pedump.c:60
Definition: main.c:438
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: xxhash.c:193
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static GLint image_size(GLint width, GLint height, GLenum format, GLenum type)
Definition: mipmap.c:4858

Referenced by test_color_formats(), test_tiff_1bpp_palette(), test_tiff_24bpp(), test_tiff_4bps_bgra(), test_tiff_8bpp_alpha(), test_tiff_8bpp_palette(), and test_tiff_resolution().

◆ create_stream()

static IStream* create_stream ( const void data,
int  data_size 
)
static

Definition at line 350 of file tiffformat.c.

351 {
352  HRESULT hr;
353  IStream *stream;
354  HGLOBAL hdata;
355  void *locked_data;
356 
357  hdata = GlobalAlloc(GMEM_MOVEABLE, data_size);
358  ok(hdata != 0, "GlobalAlloc failed\n");
359  if (!hdata) return NULL;
360 
361  locked_data = GlobalLock(hdata);
362  memcpy(locked_data, data, data_size);
363  GlobalUnlock(hdata);
364 
365  hr = CreateStreamOnHGlobal(hdata, TRUE, &stream);
366  ok(hr == S_OK, "CreateStreamOnHGlobal failed, hr=%x\n", hr);
367 
368  return stream;
369 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define GMEM_MOVEABLE
Definition: winbase.h:291

Referenced by test_QueryCapability().

◆ dump_tiff()

static void dump_tiff ( void buf)
static

Definition at line 436 of file tiffformat.c.

437 {
438  UINT count, i;
439  struct tiff_1bpp_data *tiff;
440  struct IFD_entry *tag;
441 
442  tiff = buf;
443  count = *(short *)((char *)tiff + tiff->dir_offset);
444  tag = (struct IFD_entry *)((char *)tiff + tiff->dir_offset + sizeof(short));
445 
446  for (i = 0; i < count; i++)
447  {
448  printf("tag %u: id %04x, type %04x, count %u, value %d",
449  i, tag[i].id, tag[i].type, tag[i].count, tag[i].value);
450  if (tag[i].id == 0x102 && tag[i].count > 2)
451  {
452  short *bps = (short *)((char *)tiff + tag[i].value);
453  printf(" (%d,%d,%d,%d)\n", bps[0], bps[1], bps[2], bps[3]);
454  }
455  else
456  printf("\n");
457  }
458 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: ecma_167.h:138
Definition: tiffiop.h:115
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const WCHAR tiff[]
unsigned int UINT
Definition: ndis.h:50
#define printf
Definition: config.h:203
char * tag
Definition: main.c:59

Referenced by test_color_formats().

◆ generate_tiff_palette()

static void generate_tiff_palette ( void buf,
unsigned  count 
)
static

Definition at line 651 of file tiffformat.c.

652 {
653  unsigned short *r, *g, *b;
654  unsigned i;
655 
656  r = buf;
657  g = r + count;
658  b = g + count;
659 
660  r[0] = 0x11 * 257;
661  g[0] = 0x22 * 257;
662  b[0] = 0x33 * 257;
663  r[1] = 0x44 * 257;
664  g[1] = 0x55 * 257;
665  b[1] = 0x66 * 257;
666  r[2] = 0x77 * 257;
667  g[2] = 0x88 * 257;
668  b[2] = 0x99 * 257;
669  r[3] = 0xa1 * 257;
670  g[3] = 0xb5 * 257;
671  b[3] = 0xff * 257;
672 
673  for (i = 4; i < count; i++)
674  {
675  r[i] = i * 257;
676  g[i] = (i | 0x40) * 257;
677  b[i] = (i | 0x80) * 257;
678  }
679 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define b
Definition: ke_i.h:79
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

Referenced by test_color_formats(), and test_tiff_8bpp_palette().

◆ get_pixelformat_info()

static HRESULT get_pixelformat_info ( const GUID format,
UINT bpp,
UINT channels,
BOOL trasparency 
)
static

Definition at line 405 of file tiffformat.c.

406 {
407  HRESULT hr;
409  IWICPixelFormatInfo2 *formatinfo;
410 
411  hr = IWICImagingFactory_CreateComponentInfo(factory, format, &info);
412  ok(hr == S_OK, "CreateComponentInfo(%s) error %#x\n", wine_dbgstr_guid(format), hr);
413  if (hr == S_OK)
414  {
415  hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void **)&formatinfo);
416  if (hr == S_OK)
417  {
418  hr = IWICPixelFormatInfo2_SupportsTransparency(formatinfo, trasparency);
419  ok(hr == S_OK, "SupportsTransparency error %#x\n", hr);
420  IWICPixelFormatInfo2_Release(formatinfo);
421  }
422  hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void **)&formatinfo);
423  if (hr == S_OK)
424  {
425  hr = IWICPixelFormatInfo2_GetBitsPerPixel(formatinfo, bpp);
426  ok(hr == S_OK, "GetBitsPerPixel error %#x\n", hr);
427  hr = IWICPixelFormatInfo2_GetChannelCount(formatinfo, channels);
428  ok(hr == S_OK, "GetChannelCount error %#x\n", hr);
429  IWICPixelFormatInfo2_Release(formatinfo);
430  }
431  IWICComponentInfo_Release(info);
432  }
433  return hr;
434 }
HRESULT hr
Definition: shlfolder.c:183
const char * wine_dbgstr_guid(const GUID *guid)
int This channels
Definition: rdpsnd_libao.c:37
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
struct _test_info info[]
Definition: SetCursorPos.c:19
Definition: main.c:438
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
DWORD bpp
Definition: surface.c:182

Referenced by test_color_formats().

◆ START_TEST()

START_TEST ( tiffformat  )

Definition at line 1285 of file tiffformat.c.

1286 {
1287  HRESULT hr;
1288 
1290 
1291  hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
1292  &IID_IWICImagingFactory, (void **)&factory);
1293  ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
1294  if (FAILED(hr)) return;
1295 
1303  test_tiff_24bpp();
1304 
1305  IWICImagingFactory_Release(factory);
1306  CoUninitialize();
1307 }
HRESULT hr
Definition: shlfolder.c:183
static void test_tiff_resolution(void)
Definition: tiffformat.c:729
Definition: main.c:438
static void test_QueryCapability(void)
Definition: tiffformat.c:491
smooth NULL
Definition: ftsmooth.c:416
static void test_tiff_8bpp_alpha(void)
Definition: tiffformat.c:588
static void test_tiff_1bpp_palette(void)
Definition: tiffformat.c:460
LONG HRESULT
Definition: typedefs.h:79
static void test_tiff_4bps_bgra(void)
Definition: tiffformat.c:1223
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:51
static void test_tiff_8bpp_palette(void)
Definition: tiffformat.c:681
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define ok(value,...)
Definition: atltest.h:57
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
static void test_tiff_24bpp(void)
Definition: tiffformat.c:781
static void test_color_formats(void)
Definition: tiffformat.c:893

◆ test_color_formats()

static void test_color_formats ( void  )
static

Definition at line 893 of file tiffformat.c.

894 {
895  struct bitmap_data
896  {
897  UINT bpp;
898  UINT width;
899  UINT height;
900  const WICPixelFormatGUID *format;
901  const BYTE *bits;
902  };
903  static const BYTE bits_1bpsBGR[] = { 0,255,0,255,0,255,255,255,0,0,0,255,255,0,0,0,255,255,255,255,255,0,0,0,0,255,0,255,0,255 };
904  static const struct bitmap_data data_1bpsBGR =
905  {
906  24, 10, 2, &GUID_WICPixelFormat24bppBGR, bits_1bpsBGR
907  };
908  static const BYTE bits_4bpsBGR[] = { 204,85,85,136,187,51,0,85,85,85,0,68,0,102,0,136,0,119,0,153,0 };
909  static const struct bitmap_data data_4bpsBGR =
910  {
911  24, 5, 2, &GUID_WICPixelFormat24bppBGR, bits_4bpsBGR
912  };
913  static const BYTE bits_8bpsBGR[] = { 2,0,1,5,4,3,8,7,6 };
914  static const struct bitmap_data data_8bpsBGR =
915  {
916  24, 3, 1, &GUID_WICPixelFormat24bppBGR, bits_8bpsBGR
917  };
918  static const BYTE bits_48bppRGB[] = { 1,0,2,3,4,5,6,7,8,9,0,1 };
919  static const struct bitmap_data data_48bppRGB =
920  {
921  48, 2, 1, &GUID_WICPixelFormat48bppRGB, bits_48bppRGB
922  };
923  static const BYTE bits_1bpsBGRA[] = { 0,255,0,255,0,255,0,255,0,255,255,0,255,0,0,255,255,0,255,255,0,0,255,0,0,255,0,255,0,255,0,255,0,0,0,0,0,255,0,0 };
924  static const struct bitmap_data data_1bpsBGRA =
925  {
926  32, 5, 2, &GUID_WICPixelFormat32bppBGRA, bits_1bpsBGRA
927  };
928  static const BYTE bits_4bpsBGRA[] = { 204,85,85,51,85,136,187,85,0,68,0,85,0,102,0,119,0,136,0,153,0,0,0,17,0,34,0,51 };
929  static const struct bitmap_data data_4bpsBGRA =
930  {
931  32, 5, 2, &GUID_WICPixelFormat32bppBGRA, bits_4bpsBGRA
932  };
933  static const BYTE bits_8bpsBGRA[] = { 2,0,1,3,6,5,4,7,0,9,8,1,4,3,2,5 };
934  static const struct bitmap_data data_8bpsBGRA =
935  {
936  32, 4, 1, &GUID_WICPixelFormat32bppBGRA, bits_8bpsBGRA
937  };
938  static const BYTE bits_64bppRGBA[] = { 1,0,2,3,4,5,6,7,8,9,0,1,2,3,4,5 };
939  static const struct bitmap_data data_64bppRGBA =
940  {
941  64, 2, 1, &GUID_WICPixelFormat64bppRGBA, bits_64bppRGBA
942  };
943  static const BYTE bits_BlackWhite[] = { 85,195,184,85 };
944  static const struct bitmap_data data_BlackWhite =
945  {
946  1, 30, 1, &GUID_WICPixelFormatBlackWhite, bits_BlackWhite
947  };
948  static const BYTE bits_BlackWhite_xp[] = { 85,195,184,84 };
949  static const struct bitmap_data data_BlackWhite_xp =
950  {
951  1, 30, 1, &GUID_WICPixelFormatBlackWhite, bits_BlackWhite_xp
952  };
953  static const BYTE bits_4bppGray[] = { 85,195,184,85 };
954  static const struct bitmap_data data_4bppGray =
955  {
956  4, 7, 1, &GUID_WICPixelFormat4bppGray, bits_4bppGray
957  };
958  static const BYTE bits_4bppGray_xp[] = { 85,195,184,80 };
959  static const struct bitmap_data data_4bppGray_xp =
960  {
961  4, 7, 1, &GUID_WICPixelFormat4bppGray, bits_4bppGray_xp
962  };
963  static const BYTE bits_8bppGray[] = { 1,0,2,3,4,5,6,7,8,9 };
964  static const struct bitmap_data data_8bppGray =
965  {
966  8, 10, 1, &GUID_WICPixelFormat8bppGray, bits_8bppGray
967  };
968  static const BYTE bits_16bppGray[] = { 1,0,2,3,4,5 };
969  static const struct bitmap_data data_16bppGray =
970  {
971  16, 3, 1, &GUID_WICPixelFormat16bppGray, bits_16bppGray
972  };
973  static const BYTE bits_32bppGrayFloat[] = { 1,0,2,3,4,5,6,7,8,9,0,1 };
974  static const struct bitmap_data data_32bppGrayFloat =
975  {
976  32, 3, 1, &GUID_WICPixelFormat32bppGrayFloat, bits_32bppGrayFloat
977  };
978 #if 0 /* FIXME */
979  static const BYTE bits_96bpp3Channels[] = { 0 };
980  static const struct bitmap_data data_96bpp3Channels =
981  {
982  64, 1, 1, &GUID_WICPixelFormat96bpp3Channels, bits_96bpp3Channels
983  };
984 #endif
985  static const BYTE bits_128bppRGBAFloat[] = { 1,0,2,3,4,5,6,7,8,9,0,1,2,3,4,5 };
986  static const struct bitmap_data data_128bppRGBAFloat =
987  {
988  128, 1, 1, &GUID_WICPixelFormat128bppRGBAFloat, bits_128bppRGBAFloat
989  };
990  static const BYTE bits_1bppIndexed[] = { 85,195,184,85 };
991  static const struct bitmap_data data_1bppIndexed =
992  {
993  1, 32, 1, &GUID_WICPixelFormat1bppIndexed, bits_1bppIndexed
994  };
995  static const BYTE bits_4bppIndexed[] = { 85,195,184,85 };
996  static const struct bitmap_data data_4bppIndexed =
997  {
998  4, 7, 1, &GUID_WICPixelFormat4bppIndexed, bits_4bppIndexed
999  };
1000  static const BYTE bits_4bppIndexed_xp[] = { 85,195,184,80 };
1001  static const struct bitmap_data data_4bppIndexed_xp =
1002  {
1003  4, 7, 1, &GUID_WICPixelFormat4bppIndexed, bits_4bppIndexed_xp
1004  };
1005  static const BYTE bits_8bppIndexed[] = { 1,0,2,3,4,5,6,7,8,9 };
1006  static const struct bitmap_data data_8bppIndexed =
1007  {
1008  8, 3, 1, &GUID_WICPixelFormat8bppIndexed, bits_8bppIndexed
1009  };
1010  static const BYTE bits_32bppCMYK[] = { 1,0,2,3,4,5,6,7,8,9,0,1 };
1011  static const struct bitmap_data data_32bppCMYK =
1012  {
1013  32, 3, 1, &GUID_WICPixelFormat32bppCMYK, bits_32bppCMYK
1014  };
1015  static const BYTE bits_64bppCMYK[] = { 1,0,2,3,4,5,6,7,8,9,0,1,2,3,4,5 };
1016  static const struct bitmap_data data_64bppCMYK =
1017  {
1018  64, 2, 1, &GUID_WICPixelFormat64bppCMYK, bits_64bppCMYK
1019  };
1020  static const struct
1021  {
1022  int photometric; /* PhotometricInterpretation */
1023  int samples; /* SamplesPerPixel */
1024  int bps; /* BitsPerSample */
1025  const struct bitmap_data *data;
1026  const struct bitmap_data *alt_data;
1027  } td[] =
1028  {
1029  /* 2 - RGB */
1030  { 2, 3, 1, &data_1bpsBGR },
1031  { 2, 3, 4, &data_4bpsBGR },
1032  { 2, 3, 8, &data_8bpsBGR },
1033  { 2, 3, 16, &data_48bppRGB },
1034  { 2, 3, 24, NULL },
1035 #if 0 /* FIXME */
1036  { 2, 3, 32, &data_96bpp3Channels },
1037 #endif
1038  { 2, 4, 1, &data_1bpsBGRA },
1039  { 2, 4, 4, &data_4bpsBGRA },
1040  { 2, 4, 8, &data_8bpsBGRA },
1041  { 2, 4, 16, &data_64bppRGBA },
1042  { 2, 4, 24, NULL },
1043  { 2, 4, 32, &data_128bppRGBAFloat },
1044  /* 1 - BlackIsZero (Bilevel) */
1045  { 1, 1, 1, &data_BlackWhite, &data_BlackWhite_xp },
1046  { 1, 1, 4, &data_4bppGray, &data_4bppGray_xp },
1047  { 1, 1, 8, &data_8bppGray },
1048  { 1, 1, 16, &data_16bppGray },
1049  { 1, 1, 24, NULL },
1050  { 1, 1, 32, &data_32bppGrayFloat },
1051  /* 3 - Palette Color */
1052  { 3, 1, 1, &data_1bppIndexed },
1053  { 3, 1, 4, &data_4bppIndexed, &data_4bppIndexed_xp },
1054  { 3, 1, 8, &data_8bppIndexed },
1055 #if 0 /* FIXME: for some reason libtiff replaces photometric 3 by 1 for bps > 8 */
1056  { 3, 1, 16, &data_8bppIndexed },
1057  { 3, 1, 24, &data_8bppIndexed },
1058  { 3, 1, 32, &data_8bppIndexed },
1059 #endif
1060  /* 5 - Separated */
1061  { 5, 4, 1, NULL },
1062  { 5, 4, 4, NULL },
1063  { 5, 4, 8, &data_32bppCMYK },
1064  { 5, 4, 16, &data_64bppCMYK },
1065  { 5, 4, 24, NULL },
1066  { 5, 4, 32, NULL },
1067  };
1068  BYTE buf[sizeof(tiff_1x1_data)];
1069  BYTE pixels[256];
1070  HRESULT hr;
1071  IWICBitmapDecoder *decoder;
1072  IWICBitmapFrameDecode *frame;
1073  GUID format;
1074  UINT count, i, bpp, channels, ret;
1075  BOOL trasparency;
1076  struct IFD_entry *tag, *tag_photo = NULL, *tag_bps = NULL, *tag_samples = NULL, *tag_colormap = NULL;
1077  struct IFD_entry *tag_width = NULL, *tag_height = NULL;
1078  short *bps;
1079 
1080  memcpy(buf, &tiff_1x1_data, sizeof(tiff_1x1_data));
1081  generate_tiff_palette(buf + FIELD_OFFSET(struct tiff_1x1_data, palette_data), 256);
1082 
1083  count = *(short *)(buf + tiff_1x1_data.dir_offset);
1084  tag = (struct IFD_entry *)(buf + tiff_1x1_data.dir_offset + sizeof(short));
1085 
1086  /* verify the TIFF structure */
1087  for (i = 0; i < count; i++)
1088  {
1089  if (tag[i].id == 0x100) /* ImageWidth */
1090  tag_width = &tag[i];
1091  else if (tag[i].id == 0x101) /* ImageLength */
1092  tag_height = &tag[i];
1093  else if (tag[i].id == 0x102) /* BitsPerSample */
1094  tag_bps = &tag[i];
1095  else if (tag[i].id == 0x106) /* PhotometricInterpretation */
1096  tag_photo = &tag[i];
1097  else if (tag[i].id == 0x115) /* SamplesPerPixel */
1098  tag_samples = &tag[i];
1099  else if (tag[i].id == 0x140) /* ColorMap */
1100  tag_colormap = &tag[i];
1101  }
1102 
1103  ok(tag_bps && tag_photo && tag_samples && tag_colormap, "tag 0x102,0x106,0x115 or 0x140 is missing\n");
1104  if (!tag_bps || !tag_photo || !tag_samples || !tag_colormap) return;
1105 
1106  ok(tag_bps->type == IFD_SHORT, "tag 0x102 should have type IFD_SHORT\n");
1107  bps = (short *)(buf + tag_bps->value);
1108  ok(bps[0] == 8 && bps[1] == 8 && bps[2] == 8 && bps[3] == 0,
1109  "expected bps 8,8,8,0 got %d,%d,%d,%d\n", bps[0], bps[1], bps[2], bps[3]);
1110 
1111  for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
1112  {
1113  if (td[i].data)
1114  {
1115  bpp = td[i].samples * td[i].bps;
1116  if (winetest_debug > 1)
1117  trace("samples %u, bps %u, bpp %u, width %u => width_bytes %u\n", td[i].samples, td[i].bps, bpp,
1118  td[i].data->width, width_bytes(td[i].data->width, bpp));
1119  tag_width->value = td[i].data->width;
1120  tag_height->value = td[i].data->height;
1121  }
1122  else
1123  {
1124  tag_width->value = 1;
1125  tag_height->value = 1;
1126  }
1127 
1128  tag_colormap->count = (1 << td[i].bps) * 3;
1129 
1130  if (td[i].bps < 8)
1131  {
1132  buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data)] = 0x55;
1133  buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 1] = 0xc3;
1134  buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 2] = 0xb8;
1135  buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 3] = 0x55;
1136  }
1137  else
1138  {
1139  buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data)] = 1;
1140  buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 1] = 0;
1141  buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 2] = 2;
1142  buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 3] = 3;
1143  }
1144 
1145  tag_photo->value = td[i].photometric;
1146  tag_bps->count = td[i].samples;
1147  tag_samples->value = td[i].samples;
1148 
1149  if (td[i].samples == 1)
1150  tag_bps->value = td[i].bps;
1151  else if (td[i].samples == 2)
1152  tag_bps->value = MAKELONG(td[i].bps, td[i].bps);
1153  else if (td[i].samples == 3)
1154  {
1155  tag_bps->value = (BYTE *)bps - buf;
1156  bps[0] = bps[1] = bps[2] = td[i].bps;
1157  }
1158  else if (td[i].samples == 4)
1159  {
1160  tag_bps->value = (BYTE *)bps - buf;
1161  bps[0] = bps[1] = bps[2] = bps[3] = td[i].bps;
1162  }
1163  else
1164  {
1165  ok(0, "%u: unsupported samples count %d\n", i, td[i].samples);
1166  continue;
1167  }
1168 
1169  hr = create_decoder(buf, sizeof(buf), &decoder);
1170  if (!td[i].data)
1171  {
1173  "%u: (%d,%d,%d) wrong error %#x\n", i, td[i].photometric, td[i].samples, td[i].bps, hr);
1174  if (hr == S_OK)
1175  {
1176  IWICBitmapDecoder_Release(decoder);
1177  dump_tiff(buf);
1178  }
1179  continue;
1180  }
1181  else
1183  "%u: failed to load TIFF image data (%d,%d,%d) %#x\n",
1184  i, td[i].photometric, td[i].samples, td[i].bps, hr);
1185  if (hr != S_OK) continue;
1186 
1187  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
1188  ok(hr == S_OK, "%u: GetFrame error %#x\n", i, hr);
1189 
1190  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
1191  ok(hr == S_OK, "%u: GetPixelFormat error %#x\n", i, hr);
1192  ok(IsEqualGUID(&format, td[i].data->format),
1193  "%u (%d,%d,%d): expected %s, got %s\n",
1194  i, td[i].photometric, td[i].samples, td[i].bps,
1195  wine_dbgstr_guid(td[i].data->format), wine_dbgstr_guid(&format));
1196 
1197  trasparency = (td[i].photometric == 2 && td[i].samples == 4); /* for XP */
1198  hr = get_pixelformat_info(&format, &bpp, &channels, &trasparency);
1199  ok(hr == S_OK, "%u: get_pixelformat_bpp error %#x\n", i, hr);
1200  ok(bpp == td[i].data->bpp, "%u: expected %u, got %u\n", i, td[i].data->bpp, bpp);
1201  ok(channels == td[i].samples, "%u: expected %u, got %u\n", i, td[i].samples, channels);
1202  ok(trasparency == (td[i].photometric == 2 && td[i].samples == 4), "%u: got %u\n", i, trasparency);
1203 
1204  memset(pixels, 0, sizeof(pixels));
1205  hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, width_bytes(td[i].data->width, bpp), sizeof(pixels), pixels);
1206  ok(hr == S_OK, "%u: CopyPixels error %#x\n", i, hr);
1207  ret = memcmp(pixels, td[i].data->bits, width_bytes(td[i].data->width, bpp));
1208  if (ret && td[i].alt_data)
1209  ret = memcmp(pixels, td[i].alt_data->bits, width_bytes(td[i].data->width, bpp));
1210  ok(ret == 0, "%u: (%d,%d,%d) wrong pixel data\n", i, td[i].photometric, td[i].samples, td[i].bps);
1211  if (ret)
1212  {
1213  UINT j, n = width_bytes(td[i].data->width, bpp);
1214  for (j = 0; j < n; j++)
1215  printf("%u%s", pixels[j], (j + 1) < n ? "," : "\n");
1216  }
1217 
1218  IWICBitmapFrameDecode_Release(frame);
1219  IWICBitmapDecoder_Release(decoder);
1220  }
1221 }
GLsizei samples
Definition: glext.h:7006
UINT bpp
Definition: converter.c:37
static void dump_tiff(void *buf)
Definition: tiffformat.c:436
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT hr
Definition: shlfolder.c:183
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
static const struct tiff_1x1_data tiff_1x1_data
const char * wine_dbgstr_guid(const GUID *guid)
Definition: ecma_167.h:138
int This channels
Definition: rdpsnd_libao.c:37
ULONG dir_offset
Definition: image.c:5507
static const float bits_32bppGrayFloat[]
Definition: converter.c:519
int winetest_debug
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
static HRESULT get_pixelformat_info(const GUID *format, UINT *bpp, UINT *channels, BOOL *trasparency)
Definition: tiffformat.c:405
#define MAKELONG(a, b)
Definition: typedefs.h:249
smooth NULL
Definition: ftsmooth.c:416
#define IFD_SHORT
Definition: tiffformat.c:40
static const BYTE bits_8bppGray[]
Definition: converter.c:539
LONG value
static void generate_tiff_palette(void *buf, unsigned count)
Definition: tiffformat.c:651
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
UINT height
Definition: converter.c:40
#define trace
Definition: atltest.h:70
LONG HRESULT
Definition: typedefs.h:79
static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
Definition: tiffformat.c:371
static const BYTE bits_64bppRGBA[]
Definition: converter.c:494
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
UINT width
Definition: converter.c:39
int ret
static UINT width_bytes(UINT width, UINT bpp)
Definition: tiffformat.c:888
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: xxhash.c:193
#define broken(x)
Definition: _sntprintf.h:21
#define S_OK
Definition: intsafe.h:51
#define WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT
Definition: winerror.h:3299
#define ok(value,...)
Definition: atltest.h:57
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
const BYTE * bits
Definition: converter.c:38
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define WINCODEC_ERR_COMPONENTNOTFOUND
Definition: winerror.h:3288
#define WINCODEC_ERR_BADIMAGE
Definition: winerror.h:3291
const WICPixelFormatGUID * format
Definition: converter.c:36
DWORD bpp
Definition: surface.c:182
#define memset(x, y, z)
Definition: compat.h:39
const struct bitmap_data * alt_data
Definition: converter.c:43
#define printf
Definition: config.h:203
char * tag
Definition: main.c:59

Referenced by START_TEST().

◆ test_QueryCapability()

static void test_QueryCapability ( void  )
static

Definition at line 491 of file tiffformat.c.

492 {
493  HRESULT hr;
494  IStream *stream;
495  IWICBitmapDecoder *decoder;
496  IWICBitmapFrameDecode *frame;
497  static const DWORD exp_caps = WICBitmapDecoderCapabilityCanDecodeAllImages |
500  static const DWORD exp_caps_xp = WICBitmapDecoderCapabilityCanDecodeAllImages |
502  DWORD capability;
504  ULARGE_INTEGER cur_pos;
505  UINT frame_count;
506 
508  if (!stream) return;
509 
510  hr = IWICImagingFactory_CreateDecoder(factory, &GUID_ContainerFormatTiff, NULL, &decoder);
511  ok(hr == S_OK, "CreateDecoder error %#x\n", hr);
512  if (FAILED(hr)) return;
513 
514  frame_count = 0xdeadbeef;
515  hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
516  ok(hr == S_OK || broken(hr == E_POINTER) /* XP */, "GetFrameCount error %#x\n", hr);
517  ok(frame_count == 0, "expected 0, got %u\n", frame_count);
518 
519  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
520  ok(hr == WINCODEC_ERR_FRAMEMISSING || broken(hr == E_POINTER) /* XP */, "expected WINCODEC_ERR_FRAMEMISSING, got %#x\n", hr);
521 
522  pos.QuadPart = 4;
523  hr = IStream_Seek(stream, pos, SEEK_SET, NULL);
524  ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
525 
526  capability = 0xdeadbeef;
527  hr = IWICBitmapDecoder_QueryCapability(decoder, stream, &capability);
528  ok(hr == S_OK, "QueryCapability error %#x\n", hr);
529  ok(capability == exp_caps || capability == exp_caps_xp,
530  "expected %#x, got %#x\n", exp_caps, capability);
531 
532  frame_count = 0xdeadbeef;
533  hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
534  ok(hr == S_OK, "GetFrameCount error %#x\n", hr);
535  ok(frame_count == 1, "expected 1, got %u\n", frame_count);
536 
537  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
538  ok(hr == S_OK, "GetFrame error %#x\n", hr);
539  IWICBitmapFrameDecode_Release(frame);
540 
541  pos.QuadPart = 0;
542  hr = IStream_Seek(stream, pos, SEEK_CUR, &cur_pos);
543  ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
544  ok(cur_pos.QuadPart > 4 && cur_pos.QuadPart < sizeof(tiff_1bpp_data),
545  "current stream pos is at %x/%x\n", cur_pos.u.LowPart, cur_pos.u.HighPart);
546 
547  hr = IWICBitmapDecoder_QueryCapability(decoder, stream, &capability);
548  ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, got %#x\n", hr);
549 
550  hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnDemand);
551  ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, got %#x\n", hr);
552 
553  IWICBitmapDecoder_Release(decoder);
554 
555  hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder);
556 todo_wine
557  ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND, "expected WINCODEC_ERR_COMPONENTNOTFOUND, got %#x\n", hr);
558 
559  if (SUCCEEDED(hr))
560  IWICBitmapDecoder_Release(decoder);
561 
562  pos.QuadPart = 0;
563  hr = IStream_Seek(stream, pos, SEEK_SET, NULL);
564  ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
565 
566  hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder);
567  ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr);
568 
569  frame_count = 0xdeadbeef;
570  hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
571  ok(hr == S_OK, "GetFrameCount error %#x\n", hr);
572  ok(frame_count == 1, "expected 1, got %u\n", frame_count);
573 
574  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
575  ok(hr == S_OK, "GetFrame error %#x\n", hr);
576  IWICBitmapFrameDecode_Release(frame);
577 
578  hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnDemand);
579  ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, got %#x\n", hr);
580 
581  hr = IWICBitmapDecoder_QueryCapability(decoder, stream, &capability);
582  ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, got %#x\n", hr);
583 
584  IWICBitmapDecoder_Release(decoder);
585  IStream_Release(stream);
586 }
#define SEEK_CUR
Definition: util.h:63
HRESULT hr
Definition: shlfolder.c:183
struct _ULARGE_INTEGER::@3866 u
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
Definition: main.c:438
smooth NULL
Definition: ftsmooth.c:416
#define SEEK_SET
Definition: jmemansi.c:26
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINCODEC_ERR_FRAMEMISSING
Definition: winerror.h:3293
#define todo_wine
Definition: test.h:162
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define broken(x)
Definition: _sntprintf.h:21
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define WINCODEC_ERR_COMPONENTNOTFOUND
Definition: winerror.h:3288
#define E_POINTER
Definition: winerror.h:2365
static IStream * create_stream(const void *data, int data_size)
Definition: tiffformat.c:350
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by START_TEST().

◆ test_tiff_1bpp_palette()

static void test_tiff_1bpp_palette ( void  )
static

Definition at line 460 of file tiffformat.c.

461 {
462  HRESULT hr;
463  IWICBitmapDecoder *decoder;
464  IWICBitmapFrameDecode *frame;
466  GUID format;
467 
468  hr = create_decoder(&tiff_1bpp_data, sizeof(tiff_1bpp_data), &decoder);
469  ok(hr == S_OK, "Failed to load TIFF image data %#x\n", hr);
470  if (hr != S_OK) return;
471 
472  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
473  ok(hr == S_OK, "GetFrame error %#x\n", hr);
474 
475  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
476  ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
477  ok(IsEqualGUID(&format, &GUID_WICPixelFormatBlackWhite),
478  "got wrong format %s\n", wine_dbgstr_guid(&format));
479 
480  hr = IWICImagingFactory_CreatePalette(factory, &palette);
481  ok(hr == S_OK, "CreatePalette error %#x\n", hr);
482  hr = IWICBitmapFrameDecode_CopyPalette(frame, palette);
484  "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %#x\n", hr);
485 
486  IWICPalette_Release(palette);
487  IWICBitmapFrameDecode_Release(frame);
488  IWICBitmapDecoder_Release(decoder);
489 }
HRESULT hr
Definition: shlfolder.c:183
const char * wine_dbgstr_guid(const GUID *guid)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: main.c:438
#define WINCODEC_ERR_PALETTEUNAVAILABLE
Definition: winerror.h:3284
LONG HRESULT
Definition: typedefs.h:79
static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
Definition: tiffformat.c:371
static HPALETTE palette
Definition: clipboard.c:1345
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

Referenced by START_TEST().

◆ test_tiff_24bpp()

static void test_tiff_24bpp ( void  )
static

Definition at line 781 of file tiffformat.c.

782 {
783  HRESULT hr;
784  IWICBitmapDecoder *decoder;
785  IWICBitmapFrameDecode *frame;
787  double dpi_x, dpi_y;
788  GUID format;
789  WICRect rc;
790  BYTE data[3];
791  static const BYTE expected_data[] = { 0x33,0x22,0x11 };
792 
793  hr = create_decoder(&tiff_24bpp_data, sizeof(tiff_24bpp_data), &decoder);
794  ok(hr == S_OK, "Failed to load TIFF image data %#x\n", hr);
795  if (hr != S_OK) return;
796  ok(decoder != NULL, "Failed to load TIFF image data\n");
797 
798  hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
799  ok(hr == S_OK, "GetFrameCount error %#x\n", hr);
800  ok(count == 1, "got %u\n", count);
801 
802  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
803  ok(hr == S_OK, "GetFrame error %#x\n", hr);
804 
805  hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height);
806  ok(hr == S_OK, "GetSize error %#x\n", hr);
807  ok(width == 1, "got %u\n", width);
808  ok(height == 1, "got %u\n", height);
809 
810  hr = IWICBitmapFrameDecode_GetResolution(frame, &dpi_x, &dpi_y);
811  ok(hr == S_OK, "GetResolution error %#x\n", hr);
812  ok(dpi_x == 300.0, "got %f\n", dpi_x);
813  ok(dpi_y == 300.0, "got %f\n", dpi_y);
814 
815  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
816  ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
817  ok(IsEqualGUID(&format, &GUID_WICPixelFormat24bppBGR),
818  "got wrong format %s\n", wine_dbgstr_guid(&format));
819 
820  for (stride = 0; stride <= 32; stride++)
821  {
822  memset(data, 0, sizeof(data));
823  rc.X = 0;
824  rc.Y = 0;
825  rc.Width = 1;
826  rc.Height = 1;
827  hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, stride, sizeof(data), data);
828  if (stride < 3)
829  ok(hr == E_INVALIDARG, "CopyPixels(%u) should fail: %#x\n", stride, hr);
830  else
831  {
832  ok(hr == S_OK, "CopyPixels(%u) error %#x\n", stride, hr);
833 
834  for (i = 0; i < sizeof(data); i++)
835  ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]);
836  }
837  }
838 
839  IWICBitmapFrameDecode_Release(frame);
840  IWICBitmapDecoder_Release(decoder);
841 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
const char * wine_dbgstr_guid(const GUID *guid)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
INT Height
Definition: wincodec.idl:239
GLsizei stride
Definition: glext.h:5848
LONG HRESULT
Definition: typedefs.h:79
static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
Definition: tiffformat.c:371
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char BYTE
Definition: xxhash.c:193
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
INT Width
Definition: wincodec.idl:238
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_tiff_4bps_bgra()

static void test_tiff_4bps_bgra ( void  )
static

Definition at line 1223 of file tiffformat.c.

1224 {
1225  HRESULT hr;
1226  IWICBitmapDecoder *decoder;
1227  IWICBitmapFrameDecode *frame;
1228  UINT frame_count, width, height, i;
1229  double dpi_x, dpi_y;
1231  GUID format;
1232  WICRect rc;
1233  BYTE data[24];
1234  static const BYTE expected_data[24] = { 0,0,0,0xff, 0xff,0,0,0, 0xff,0,0,0xff,
1235  0,0xff,0,0, 0xff,0xff,0,0xff, 0xff,0xff,0xff,0 };
1236 
1237  hr = create_decoder(&tiff_4bps_bgra, sizeof(tiff_4bps_bgra), &decoder);
1238  ok(hr == S_OK, "Failed to load TIFF image data %#x\n", hr);
1239  if (hr != S_OK) return;
1240 
1241  hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
1242  ok(hr == S_OK, "GetFrameCount error %#x\n", hr);
1243  ok(frame_count == 1, "expected 1, got %u\n", frame_count);
1244 
1245  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
1246  ok(hr == S_OK, "GetFrame error %#x\n", hr);
1247 
1248  hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height);
1249  ok(hr == S_OK, "GetSize error %#x\n", hr);
1250  ok(width == 3, "got %u\n", width);
1251  ok(height == 2, "got %u\n", height);
1252 
1253  hr = IWICBitmapFrameDecode_GetResolution(frame, &dpi_x, &dpi_y);
1254  ok(hr == S_OK, "GetResolution error %#x\n", hr);
1255  ok(dpi_x == 96.0, "expected 96.0, got %f\n", dpi_x);
1256  ok(dpi_y == 96.0, "expected 96.0, got %f\n", dpi_y);
1257 
1258  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
1259  ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
1260  ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGRA),
1261  "got wrong format %s\n", wine_dbgstr_guid(&format));
1262 
1263  hr = IWICImagingFactory_CreatePalette(factory, &palette);
1264  ok(hr == S_OK, "CreatePalette error %#x\n", hr);
1265  hr = IWICBitmapFrameDecode_CopyPalette(frame, palette);
1267  "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %#x\n", hr);
1268  IWICPalette_Release(palette);
1269 
1270  memset(data, 0xaa, sizeof(data));
1271  rc.X = 0;
1272  rc.Y = 0;
1273  rc.Width = 3;
1274  rc.Height = 2;
1275  hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, 12, sizeof(data), data);
1276  ok(hr == S_OK, "CopyPixels error %#x\n", hr);
1277 
1278  for (i = 0; i < sizeof(data); i++)
1279  ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]);
1280 
1281  IWICBitmapFrameDecode_Release(frame);
1282  IWICBitmapDecoder_Release(decoder);
1283 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
const char * wine_dbgstr_guid(const GUID *guid)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: main.c:438
#define WINCODEC_ERR_PALETTEUNAVAILABLE
Definition: winerror.h:3284
INT Height
Definition: wincodec.idl:239
LONG HRESULT
Definition: typedefs.h:79
static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
Definition: tiffformat.c:371
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char BYTE
Definition: xxhash.c:193
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
INT Width
Definition: wincodec.idl:238
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_tiff_8bpp_alpha()

static void test_tiff_8bpp_alpha ( void  )
static

Definition at line 588 of file tiffformat.c.

589 {
590  HRESULT hr;
591  IWICBitmapDecoder *decoder;
592  IWICBitmapFrameDecode *frame;
593  UINT frame_count, width, height, i;
594  double dpi_x, dpi_y;
596  GUID format;
597  WICRect rc;
598  BYTE data[16];
599  static const BYTE expected_data[16] = { 0x11,0x11,0x11,0x22,0x33,0x33,0x33,0x44,
600  0x55,0x55,0x55,0x66,0x77,0x77,0x77,0x88 };
601 
602  hr = create_decoder(&tiff_8bpp_alpha, sizeof(tiff_8bpp_alpha), &decoder);
603  ok(hr == S_OK, "Failed to load TIFF image data %#x\n", hr);
604  if (hr != S_OK) return;
605 
606  hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
607  ok(hr == S_OK, "GetFrameCount error %#x\n", hr);
608  ok(frame_count == 1, "expected 1, got %u\n", frame_count);
609 
610  EXPECT_REF(decoder, 1);
611  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
612  ok(hr == S_OK, "GetFrame error %#x\n", hr);
613  EXPECT_REF(decoder, 2);
614  IWICBitmapDecoder_Release(decoder);
615 
616  hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height);
617  ok(hr == S_OK, "GetSize error %#x\n", hr);
618  ok(width == 2, "expected 2, got %u\n", width);
619  ok(height == 2, "expected 2, got %u\n", height);
620 
621  hr = IWICBitmapFrameDecode_GetResolution(frame, &dpi_x, &dpi_y);
622  ok(hr == S_OK, "GetResolution error %#x\n", hr);
623  ok(dpi_x == 96.0, "expected 96.0, got %f\n", dpi_x);
624  ok(dpi_y == 96.0, "expected 96.0, got %f\n", dpi_y);
625 
626  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
627  ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
628  ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppPBGRA),
629  "got wrong format %s\n", wine_dbgstr_guid(&format));
630 
631  hr = IWICImagingFactory_CreatePalette(factory, &palette);
632  ok(hr == S_OK, "CreatePalette error %#x\n", hr);
633  hr = IWICBitmapFrameDecode_CopyPalette(frame, palette);
635  "expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %#x\n", hr);
636  IWICPalette_Release(palette);
637 
638  rc.X = 0;
639  rc.Y = 0;
640  rc.Width = 2;
641  rc.Height = 2;
642  hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, 8, sizeof(data), data);
643  ok(hr == S_OK, "CopyPixels error %#x\n", hr);
644 
645  for (i = 0; i < sizeof(data); i++)
646  ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]);
647 
648  IWICBitmapFrameDecode_Release(frame);
649 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
const char * wine_dbgstr_guid(const GUID *guid)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define EXPECT_REF(obj, ref)
Definition: tiffformat.c:29
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: main.c:438
#define WINCODEC_ERR_PALETTEUNAVAILABLE
Definition: winerror.h:3284
INT Height
Definition: wincodec.idl:239
LONG HRESULT
Definition: typedefs.h:79
static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
Definition: tiffformat.c:371
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char BYTE
Definition: xxhash.c:193
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
INT Width
Definition: wincodec.idl:238

Referenced by START_TEST().

◆ test_tiff_8bpp_palette()

static void test_tiff_8bpp_palette ( void  )
static

Definition at line 681 of file tiffformat.c.

682 {
683  char buf[sizeof(tiff_8bpp_data)];
684  HRESULT hr;
685  IWICBitmapDecoder *decoder;
686  IWICBitmapFrameDecode *frame;
688  GUID format;
689  UINT count, ret;
690  WICColor color[256];
691 
693  generate_tiff_palette(buf + FIELD_OFFSET(struct tiff_8bpp_data, palette_data), 256);
694 
695  hr = create_decoder(buf, sizeof(buf), &decoder);
696  ok(hr == S_OK, "Failed to load TIFF image data %#x\n", hr);
697  if (hr != S_OK) return;
698 
699  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
700  ok(hr == S_OK, "GetFrame error %#x\n", hr);
701 
702  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
703  ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
704  ok(IsEqualGUID(&format, &GUID_WICPixelFormat8bppIndexed),
705  "expected GUID_WICPixelFormat8bppIndexed, got %s\n", wine_dbgstr_guid(&format));
706 
707  hr = IWICImagingFactory_CreatePalette(factory, &palette);
708  ok(hr == S_OK, "CreatePalette error %#x\n", hr);
709  hr = IWICBitmapFrameDecode_CopyPalette(frame, palette);
710  ok(hr == S_OK, "CopyPalette error %#x\n", hr);
711 
712  hr = IWICPalette_GetColorCount(palette, &count);
713  ok(hr == S_OK, "GetColorCount error %#x\n", hr);
714  ok(count == 256, "expected 256, got %u\n", count);
715 
716  hr = IWICPalette_GetColors(palette, 256, color, &ret);
717  ok(hr == S_OK, "GetColors error %#x\n", hr);
718  ok(ret == count, "expected %u, got %u\n", count, ret);
719  ok(color[0] == 0xff112233, "got %#x\n", color[0]);
720  ok(color[1] == 0xff445566, "got %#x\n", color[1]);
721  ok(color[2] == 0xff778899, "got %#x\n", color[2]);
722  ok(color[3] == 0xffa1b5ff, "got %#x\n", color[3]);
723 
724  IWICPalette_Release(palette);
725  IWICBitmapFrameDecode_Release(frame);
726  IWICBitmapDecoder_Release(decoder);
727 }
HRESULT hr
Definition: shlfolder.c:183
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static const struct tiff_8bpp_data tiff_8bpp_data
GLuint GLuint GLsizei count
Definition: gl.h:1545
const char * wine_dbgstr_guid(const GUID *guid)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: main.c:438
GLuint color
Definition: glext.h:6243
static void generate_tiff_palette(void *buf, unsigned count)
Definition: tiffformat.c:651
LONG HRESULT
Definition: typedefs.h:79
static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
Definition: tiffformat.c:371
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HPALETTE palette
Definition: clipboard.c:1345
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
UINT32 WICColor
Definition: wincodec.idl:250

Referenced by START_TEST().

◆ test_tiff_resolution()

static void test_tiff_resolution ( void  )
static

Definition at line 729 of file tiffformat.c.

730 {
731  HRESULT hr;
732  IWICBitmapDecoder *decoder;
733  IWICBitmapFrameDecode *frame;
734  double dpi_x, dpi_y;
735  int i;
736 
737  for (i = 0; i < ARRAY_SIZE(tiff_resolution_test_data); i++)
738  {
742  tiff_resolution_image_data.entry[12].value = test_data->resolution_unit;
743 
745  ok(hr == S_OK, "Failed to load TIFF image data %#x\n", hr);
746  if (hr != S_OK) return;
747 
748  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
749  ok(hr == S_OK, "%d: GetFrame error %#x\n", i, hr);
750 
751  hr = IWICBitmapFrameDecode_GetResolution(frame, &dpi_x, &dpi_y);
752  ok(hr == S_OK, "%d: GetResolution error %#x\n", i, hr);
753 
754  if (test_data->broken_dpi_x != 0)
755  {
756  ok(fabs(dpi_x - test_data->expected_dpi_x) < 0.01 || broken(fabs(dpi_x - test_data->broken_dpi_x) < 0.01),
757  "%d: x: expected %f or %f, got %f\n", i, test_data->expected_dpi_x, test_data->broken_dpi_x, dpi_x);
758  }
759  else
760  {
761  ok(fabs(dpi_x - test_data->expected_dpi_x) < 0.01,
762  "%d: x: expected %f, got %f\n", i, test_data->expected_dpi_x, dpi_x);
763  }
764 
765  if (test_data->broken_dpi_y != 0)
766  {
767  ok(fabs(dpi_y - test_data->expected_dpi_y) < 0.01 || broken(fabs(dpi_y - test_data->broken_dpi_y) < 0.01),
768  "%d: y: expected %f or %f, got %f\n", i, test_data->expected_dpi_y, test_data->broken_dpi_y, dpi_y);
769  }
770  else
771  {
772  ok(fabs(dpi_y - test_data->expected_dpi_y) < 0.01,
773  "%d: y: expected %f, got %f\n", i, test_data->expected_dpi_y, dpi_y);
774  }
775 
776  IWICBitmapFrameDecode_Release(frame);
777  IWICBitmapDecoder_Release(decoder);
778  }
779 }
struct IFD_entry entry[13]
Definition: tiffformat.c:230
struct IFD_rational resy
Definition: tiffformat.c:233
HRESULT hr
Definition: shlfolder.c:183
struct IFD_rational resx
Definition: tiffformat.c:232
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LONG HRESULT
Definition: typedefs.h:79
static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
Definition: tiffformat.c:371
#define broken(x)
Definition: _sntprintf.h:21
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
#define S_OK
Definition: intsafe.h:51
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

◆ width_bytes()

static UINT width_bytes ( UINT  width,
UINT  bpp 
)
static

Definition at line 888 of file tiffformat.c.

889 {
890  return (width * bpp + 7) / 8;
891 }
GLint GLint GLsizei width
Definition: gl.h:1546
DWORD bpp
Definition: surface.c:182

Referenced by alpha_blend_image(), MFDRV_CreateBrushIndirect(), test_bitmap_info(), test_bitmapbits(), test_color_formats(), and test_D3DKMTCreateDCFromMemory().

Variable Documentation

◆ factory

Definition at line 348 of file tiffformat.c.

◆ tiff_1bpp_data

Initial value:
=
{
'I' | 'I' << 8,
42,
FIELD_OFFSET(struct tiff_1bpp_data, number_of_entries),
13,
{
{ 0xff, IFD_SHORT, 1, 0 },
{ 0x100, IFD_LONG, 1, 1 },
{ 0x101, IFD_LONG, 1, 1 },
{ 0x102, IFD_SHORT, 1, 1 },
{ 0x103, IFD_SHORT, 1, 1 },
{ 0x106, IFD_SHORT, 1, 1 },
{ 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_1bpp_data, pixel_data) },
{ 0x115, IFD_SHORT, 1, 1 },
{ 0x116, IFD_LONG, 1, 1 },
{ 0x117, IFD_LONG, 1, 1 },
{ 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_1bpp_data, res) },
{ 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_1bpp_data, res) },
{ 0x128, IFD_SHORT, 1, 2 },
},
0,
{ 900, 3 },
{ 0x11, 0x22, 0x33, 0 }
}
#define IFD_LONG
Definition: tiffformat.c:41
#define IFD_SHORT
Definition: tiffformat.c:40
#define IFD_RATIONAL
Definition: tiffformat.c:42
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
GLuint res
Definition: glext.h:9613

◆ tiff_1x1_data

Initial value:
=
{
'I' | 'I' << 8,
42,
FIELD_OFFSET(struct tiff_1x1_data, number_of_entries),
12,
{
{ 0xff, IFD_SHORT, 1, 0 },
{ 0x100, IFD_LONG, 1, 1 },
{ 0x101, IFD_LONG, 1, 1 },
{ 0x102, IFD_SHORT, 3, FIELD_OFFSET(struct tiff_1x1_data, bps_data) },
{ 0x103, IFD_SHORT, 1, 1 },
{ 0x106, IFD_SHORT, 1, 2 },
{ 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_1x1_data, pixel_data) },
{ 0x115, IFD_SHORT, 1, 3 },
{ 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_1x1_data, res) },
{ 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_1x1_data, res) },
{ 0x128, IFD_SHORT, 1, 2 },
{ 0x140, IFD_SHORT, 256*3, FIELD_OFFSET(struct tiff_1x1_data, palette_data) }
},
0,
{ 96, 1 },
{ { 0 } },
{ 8,8,8,0 },
{ 1,0,2,3,4,5,6,7,8,9,0,1,2,3,4,5 }
}
#define IFD_LONG
Definition: tiffformat.c:41
#define IFD_SHORT
Definition: tiffformat.c:40
#define IFD_RATIONAL
Definition: tiffformat.c:42
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
GLuint res
Definition: glext.h:9613

Referenced by test_color_formats().

◆ tiff_24bpp_data

Initial value:
=
{
'I' | 'I' << 8,
42,
FIELD_OFFSET(struct tiff_1bpp_data, number_of_entries),
13,
{
{ 0xff, IFD_SHORT, 1, 0 },
{ 0x100, IFD_LONG, 1, 1 },
{ 0x101, IFD_LONG, 1, 1 },
{ 0x102, IFD_SHORT, 1, 8 },
{ 0x103, IFD_SHORT, 1, 1 },
{ 0x106, IFD_SHORT, 1, 2 },
{ 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_24bpp_data, pixel_data) },
{ 0x115, IFD_SHORT, 1, 3 },
{ 0x116, IFD_LONG, 1, 1 },
{ 0x117, IFD_LONG, 1, 3 },
{ 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_24bpp_data, res) },
{ 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_24bpp_data, res) },
{ 0x128, IFD_SHORT, 1, 2 },
},
0,
{ 900, 3 },
{ 0x11, 0x22, 0x33 }
}
#define IFD_LONG
Definition: tiffformat.c:41
#define IFD_SHORT
Definition: tiffformat.c:40
#define IFD_RATIONAL
Definition: tiffformat.c:42
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
GLuint res
Definition: glext.h:9613

◆ tiff_4bps_bgra

Initial value:
=
{
'I' | 'I' << 8,
42,
FIELD_OFFSET(struct tiff_4bps_bgra, number_of_entries),
14,
{
{ 0xff, IFD_SHORT, 1, 0 },
{ 0x100, IFD_LONG, 1, 3 },
{ 0x101, IFD_LONG, 1, 2 },
{ 0x102, IFD_SHORT, 1, 1 },
{ 0x103, IFD_SHORT, 1, 1 },
{ 0x106, IFD_SHORT, 1, 2 },
{ 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_4bps_bgra, pixel_data) },
{ 0x115, IFD_SHORT, 1, 4 },
{ 0x116, IFD_LONG, 1, 2 },
{ 0x117, IFD_LONG, 1, 4 },
{ 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_4bps_bgra, res) },
{ 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_4bps_bgra, res) },
{ 0x11c, IFD_SHORT, 1, 1 },
{ 0x128, IFD_SHORT, 1, 2 }
},
0,
{ 96, 1 },
{ 0x12,0x30, 0x47,0xe0 }
}
#define IFD_LONG
Definition: tiffformat.c:41
#define IFD_SHORT
Definition: tiffformat.c:40
#define IFD_RATIONAL
Definition: tiffformat.c:42
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
GLuint res
Definition: glext.h:9613

◆ tiff_8bpp_alpha

◆ tiff_8bpp_data

◆ tiff_resolution_image_data

Initial value:
=
{
'I' | 'I' << 8,
42,
FIELD_OFFSET(struct tiff_resolution_image_data, number_of_entries),
13,
{
{ 0xff, IFD_SHORT, 1, 0 },
{ 0x100, IFD_LONG, 1, 1 },
{ 0x101, IFD_LONG, 1, 1 },
{ 0x102, IFD_SHORT, 1, 1 },
{ 0x103, IFD_SHORT, 1, 1 },
{ 0x106, IFD_SHORT, 1, 1 },
{ 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_resolution_image_data, pixel_data) },
{ 0x115, IFD_SHORT, 1, 1 },
{ 0x116, IFD_LONG, 1, 1 },
{ 0x117, IFD_LONG, 1, 1 },
{ 0x128, IFD_SHORT, 1, 1 },
},
0,
{ 72, 1 },
{ 72, 1 },
{ 0x11, 0x22, 0x33, 0 }
}
struct IFD_rational resy
Definition: tiffformat.c:194
#define IFD_LONG
Definition: tiffformat.c:41
#define IFD_SHORT
Definition: tiffformat.c:40
#define IFD_RATIONAL
Definition: tiffformat.c:42
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
struct IFD_rational resx
Definition: tiffformat.c:193

◆ tiff_resolution_test_data

Initial value:
=
{
{ { 100, 1 }, { 50, 1 }, 0, 100.0, 50.0, 0, 0 },
{ { 50, 1 }, { 100, 1 }, 0, 50.0, 100.0, 0, 0 },
{ { 100, 1 }, { 50, 1 }, 1, 100.0, 50.0, 0, 0 },
{ { 50, 1 }, { 100, 1 }, 1, 50.0, 100.0, 0, 0 },
{ { 49, 1 }, { 49, 1 }, 2, 49.0, 49.0, 0, 0 },
{ { 33, 1 }, { 55, 1 }, 2, 33.0, 55.0, 0, 0 },
{ { 50, 2 }, { 66, 3 }, 2, 25.0, 22.0, 0, 0 },
{ { 100, 1 }, { 200, 1 }, 3, 254.0, 508.0, 0, 0 },
{ { 0, 1 }, { 29, 1 }, 2, 96.0, 96.0, 0, 29.0 },
{ { 58, 1 }, { 29, 0 }, 2, 96.0, 96.0, 58.0, 0 },
{ { 0, 1 }, { 100, 1 }, 3, 96.0, 96.0, 243.84, 254.0 },
{ { 50, 1 }, { 72, 0 }, 3, 96.0, 96.0, 127.0, 243.84 }
}