Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c5820b79
Commit
c5820b79
authored
Jul 12, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 12, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Add a test for palette associated with black&white TIFF image.
parent
dfefd3a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
166 additions
and
2 deletions
+166
-2
Makefile.in
dlls/windowscodecs/tests/Makefile.in
+2
-1
tiffformat.c
dlls/windowscodecs/tests/tiffformat.c
+163
-0
tiffformat.c
dlls/windowscodecs/tiffformat.c
+1
-1
No files found.
dlls/windowscodecs/tests/Makefile.in
View file @
c5820b79
...
...
@@ -8,6 +8,7 @@ C_SRCS = \
info.c
\
metadata.c
\
palette.c
\
stream.c
stream.c
\
tiffformat.c
@MAKE_TEST_RULES@
dlls/windowscodecs/tests/tiffformat.c
0 → 100644
View file @
c5820b79
/*
* Copyright 2012 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "wincodec.h"
#include "wine/test.h"
#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
#include "pshpack2.h"
struct
IFD_entry
{
SHORT
id
;
SHORT
type
;
ULONG
count
;
LONG
value
;
};
struct
IFD_rational
{
LONG
numerator
;
LONG
denominator
;
};
static
const
struct
tiff_1bpp_data
{
USHORT
byte_order
;
USHORT
version
;
ULONG
dir_offset
;
USHORT
number_of_entries
;
struct
IFD_entry
entry
[
13
];
ULONG
next_IFD
;
struct
IFD_rational
res
;
BYTE
pixel_data
[
4
];
}
tiff_1bpp_data
=
{
#ifdef WORDS_BIGENDIAN
'M'
|
'M'
<<
8
,
#else
'I'
|
'I'
<<
8
,
#endif
42
,
FIELD_OFFSET
(
struct
tiff_1bpp_data
,
number_of_entries
),
13
,
{
{
0xff
,
IFD_SHORT
,
1
,
0
},
/* SUBFILETYPE */
{
0x100
,
IFD_LONG
,
1
,
1
},
/* IMAGEWIDTH */
{
0x101
,
IFD_LONG
,
1
,
1
},
/* IMAGELENGTH */
{
0x102
,
IFD_SHORT
,
1
,
1
},
/* BITSPERSAMPLE */
{
0x103
,
IFD_SHORT
,
1
,
1
},
/* COMPRESSION: XP doesn't accept IFD_LONG here */
{
0x106
,
IFD_SHORT
,
1
,
1
},
/* PHOTOMETRIC */
{
0x111
,
IFD_LONG
,
1
,
FIELD_OFFSET
(
struct
tiff_1bpp_data
,
pixel_data
)
},
/* STRIPOFFSETS */
{
0x115
,
IFD_SHORT
,
1
,
1
},
/* SAMPLESPERPIXEL */
{
0x116
,
IFD_LONG
,
1
,
1
},
/* ROWSPERSTRIP */
{
0x117
,
IFD_LONG
,
1
,
1
},
/* STRIPBYTECOUNT */
{
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
},
/* RESOLUTIONUNIT */
},
0
,
{
900
,
3
},
{
0x11
,
0x22
,
0x33
,
0
}
};
#include "poppack.h"
static
IWICBitmapDecoder
*
create_decoder
(
IWICImagingFactory
*
factory
,
const
void
*
image_data
,
UINT
image_size
)
{
HGLOBAL
hmem
;
BYTE
*
data
;
HRESULT
hr
;
IWICBitmapDecoder
*
decoder
=
NULL
;
IStream
*
stream
;
GUID
guid
;
hmem
=
GlobalAlloc
(
0
,
image_size
);
data
=
GlobalLock
(
hmem
);
memcpy
(
data
,
image_data
,
image_size
);
GlobalUnlock
(
hmem
);
hr
=
CreateStreamOnHGlobal
(
hmem
,
TRUE
,
&
stream
);
ok
(
hr
==
S_OK
,
"CreateStreamOnHGlobal error %#x
\n
"
,
hr
);
hr
=
IWICImagingFactory_CreateDecoderFromStream
(
factory
,
stream
,
NULL
,
0
,
&
decoder
);
ok
(
hr
==
S_OK
,
"CreateDecoderFromStream error %#x
\n
"
,
hr
);
hr
=
IWICBitmapDecoder_GetContainerFormat
(
decoder
,
&
guid
);
ok
(
hr
==
S_OK
,
"GetContainerFormat error %#x
\n
"
,
hr
);
ok
(
IsEqualGUID
(
&
guid
,
&
GUID_ContainerFormatTiff
),
"container format is not TIFF
\n
"
);
IStream_Release
(
stream
);
return
decoder
;
}
static
void
test_tiff_palette
(
void
)
{
HRESULT
hr
;
IWICImagingFactory
*
factory
;
IWICBitmapDecoder
*
decoder
;
IWICBitmapFrameDecode
*
frame
;
IWICPalette
*
palette
;
hr
=
CoCreateInstance
(
&
CLSID_WICImagingFactory
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IWICImagingFactory
,
(
void
**
)
&
factory
);
ok
(
hr
==
S_OK
,
"CoCreateInstance error %#x
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
decoder
=
create_decoder
(
factory
,
&
tiff_1bpp_data
,
sizeof
(
tiff_1bpp_data
));
ok
(
decoder
!=
0
,
"Failed to load TIFF image data
\n
"
);
hr
=
IWICBitmapDecoder_GetFrame
(
decoder
,
0
,
&
frame
);
ok
(
hr
==
S_OK
,
"GetFrame error %#x
\n
"
,
hr
);
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette
);
ok
(
hr
==
S_OK
,
"CreatePalette error %#x
\n
"
,
hr
);
hr
=
IWICBitmapFrameDecode_CopyPalette
(
frame
,
palette
);
ok
(
hr
==
WINCODEC_ERR_PALETTEUNAVAILABLE
,
"expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %#x
\n
"
,
hr
);
IWICPalette_Release
(
palette
);
IWICBitmapFrameDecode_Release
(
frame
);
IWICBitmapDecoder_Release
(
decoder
);
IWICImagingFactory_Release
(
factory
);
}
START_TEST
(
tiffformat
)
{
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
);
test_tiff_palette
();
CoUninitialize
();
}
dlls/windowscodecs/tiffformat.c
View file @
c5820b79
...
...
@@ -878,7 +878,7 @@ static HRESULT WINAPI TiffFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
if
(
!
ret
)
{
WARN
(
"Couldn't read color map
\n
"
);
return
E_FAIL
;
return
WINCODEC_ERR_PALETTEUNAVAILABLE
;
}
for
(
i
=
0
;
i
<
color_count
;
i
++
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment