2011-01-27 00:23:44 +01:00
|
|
|
/*
|
|
|
|
* Unit test suite for metafiles
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Vincent Povirk for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2014-01-16 21:58:50 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
2013-10-16 05:49:40 +02:00
|
|
|
#include "objbase.h"
|
2011-01-27 00:23:44 +01:00
|
|
|
#include "gdiplus.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
|
2015-10-30 20:12:49 +01:00
|
|
|
#define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
|
|
|
|
#define expectf(expected, got) expectf_((expected), (got), 0.001)
|
2011-01-27 00:23:44 +01:00
|
|
|
|
2014-01-24 23:22:58 +01:00
|
|
|
static BOOL save_metafiles;
|
|
|
|
|
2011-01-27 01:50:10 +01:00
|
|
|
typedef struct emfplus_record
|
|
|
|
{
|
2013-11-12 22:11:13 +01:00
|
|
|
BOOL todo;
|
2011-01-27 01:50:10 +01:00
|
|
|
ULONG record_type;
|
2013-11-12 22:11:13 +01:00
|
|
|
BOOL playback_todo;
|
2011-01-27 01:50:10 +01:00
|
|
|
} emfplus_record;
|
|
|
|
|
|
|
|
typedef struct emfplus_check_state
|
|
|
|
{
|
|
|
|
const char *desc;
|
|
|
|
int count;
|
|
|
|
const struct emfplus_record *expected;
|
2011-07-07 20:31:55 +02:00
|
|
|
GpMetafile *metafile;
|
2011-01-27 01:50:10 +01:00
|
|
|
} emfplus_check_state;
|
|
|
|
|
|
|
|
static void check_record(int count, const char *desc, const struct emfplus_record *expected, const struct emfplus_record *actual)
|
|
|
|
{
|
2016-02-15 23:14:36 +01:00
|
|
|
todo_wine_if (expected->todo)
|
2011-05-22 01:32:23 +02:00
|
|
|
ok(expected->record_type == actual->record_type,
|
|
|
|
"%s.%i: Expected record type 0x%x, got 0x%x\n", desc, count,
|
|
|
|
expected->record_type, actual->record_type);
|
2011-01-27 01:50:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct EmfPlusRecordHeader
|
|
|
|
{
|
|
|
|
WORD Type;
|
|
|
|
WORD Flags;
|
|
|
|
DWORD Size;
|
|
|
|
DWORD DataSize;
|
|
|
|
} EmfPlusRecordHeader;
|
|
|
|
|
|
|
|
static int CALLBACK enum_emf_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR,
|
|
|
|
int nObj, LPARAM lpData)
|
|
|
|
{
|
|
|
|
emfplus_check_state *state = (emfplus_check_state*)lpData;
|
|
|
|
emfplus_record actual;
|
|
|
|
|
|
|
|
if (lpEMFR->iType == EMR_GDICOMMENT)
|
|
|
|
{
|
|
|
|
const EMRGDICOMMENT *comment = (const EMRGDICOMMENT*)lpEMFR;
|
|
|
|
|
|
|
|
if (comment->cbData >= 4 && memcmp(comment->Data, "EMF+", 4) == 0)
|
|
|
|
{
|
|
|
|
int offset = 4;
|
|
|
|
|
|
|
|
while (offset + sizeof(EmfPlusRecordHeader) <= comment->cbData)
|
|
|
|
{
|
|
|
|
const EmfPlusRecordHeader *record = (const EmfPlusRecordHeader*)&comment->Data[offset];
|
|
|
|
|
|
|
|
ok(record->Size == record->DataSize + sizeof(EmfPlusRecordHeader),
|
|
|
|
"%s: EMF+ record datasize %u and size %u mismatch\n", state->desc, record->DataSize, record->Size);
|
|
|
|
|
|
|
|
ok(offset + record->DataSize <= comment->cbData,
|
|
|
|
"%s: EMF+ record truncated\n", state->desc);
|
|
|
|
|
|
|
|
if (offset + record->DataSize > comment->cbData)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (state->expected[state->count].record_type)
|
|
|
|
{
|
2013-11-12 22:11:13 +01:00
|
|
|
actual.todo = FALSE;
|
2011-01-27 01:50:10 +01:00
|
|
|
actual.record_type = record->Type;
|
|
|
|
|
|
|
|
check_record(state->count, state->desc, &state->expected[state->count], &actual);
|
|
|
|
|
|
|
|
state->count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0, "%s: Unexpected EMF+ 0x%x record\n", state->desc, record->Type);
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += record->Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(offset == comment->cbData, "%s: truncated EMF+ record data?\n", state->desc);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state->expected[state->count].record_type)
|
|
|
|
{
|
2013-11-12 22:11:13 +01:00
|
|
|
actual.todo = FALSE;
|
2011-01-27 01:50:10 +01:00
|
|
|
actual.record_type = lpEMFR->iType;
|
|
|
|
|
|
|
|
check_record(state->count, state->desc, &state->expected[state->count], &actual);
|
|
|
|
|
|
|
|
state->count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0, "%s: Unexpected EMF 0x%x record\n", state->desc, lpEMFR->iType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
|
|
|
|
{
|
|
|
|
emfplus_check_state state;
|
|
|
|
|
|
|
|
state.desc = desc;
|
|
|
|
state.count = 0;
|
|
|
|
state.expected = expected;
|
|
|
|
|
|
|
|
EnumEnhMetaFile(0, hemf, enum_emf_proc, &state, NULL);
|
|
|
|
|
2016-02-15 23:14:36 +01:00
|
|
|
todo_wine_if (expected[state.count].todo)
|
2011-05-22 01:32:23 +02:00
|
|
|
ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count);
|
2011-01-27 01:50:10 +01:00
|
|
|
}
|
|
|
|
|
2011-05-22 00:22:12 +02:00
|
|
|
static BOOL CALLBACK enum_metafile_proc(EmfPlusRecordType record_type, unsigned int flags,
|
|
|
|
unsigned int dataSize, const unsigned char *pStr, void *userdata)
|
|
|
|
{
|
|
|
|
emfplus_check_state *state = (emfplus_check_state*)userdata;
|
|
|
|
emfplus_record actual;
|
|
|
|
|
2013-11-12 22:11:13 +01:00
|
|
|
actual.todo = FALSE;
|
2011-05-22 00:22:12 +02:00
|
|
|
actual.record_type = record_type;
|
|
|
|
|
|
|
|
if (dataSize == 0)
|
|
|
|
ok(pStr == NULL, "non-NULL pStr\n");
|
|
|
|
|
|
|
|
if (state->expected[state->count].record_type)
|
|
|
|
{
|
|
|
|
check_record(state->count, state->desc, &state->expected[state->count], &actual);
|
|
|
|
|
|
|
|
state->count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0, "%s: Unexpected EMF 0x%x record\n", state->desc, record_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_metafile(GpMetafile *metafile, const emfplus_record *expected, const char *desc,
|
|
|
|
const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
HDC hdc;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
emfplus_check_state state;
|
|
|
|
|
|
|
|
state.desc = desc;
|
|
|
|
state.count = 0;
|
|
|
|
state.expected = expected;
|
2011-07-07 20:31:55 +02:00
|
|
|
state.metafile = metafile;
|
2011-05-22 00:22:12 +02:00
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipEnumerateMetafileSrcRectDestPoints(graphics, metafile, dst_points,
|
|
|
|
3, src_rect, src_unit, enum_metafile_proc, &state, NULL);
|
2011-05-22 00:48:32 +02:00
|
|
|
expect(Ok, stat);
|
2011-05-22 00:22:12 +02:00
|
|
|
|
2016-02-15 23:14:36 +01:00
|
|
|
todo_wine_if (expected[state.count].todo)
|
2011-05-22 01:32:23 +02:00
|
|
|
ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count);
|
2011-05-22 00:22:12 +02:00
|
|
|
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2011-07-07 20:31:55 +02:00
|
|
|
static BOOL CALLBACK play_metafile_proc(EmfPlusRecordType record_type, unsigned int flags,
|
|
|
|
unsigned int dataSize, const unsigned char *pStr, void *userdata)
|
|
|
|
{
|
|
|
|
emfplus_check_state *state = (emfplus_check_state*)userdata;
|
|
|
|
GpStatus stat;
|
|
|
|
|
|
|
|
stat = GdipPlayMetafileRecord(state->metafile, record_type, flags, dataSize, pStr);
|
|
|
|
|
|
|
|
if (state->expected[state->count].record_type)
|
|
|
|
{
|
2016-02-15 23:14:36 +01:00
|
|
|
todo_wine_if (state->expected[state->count].playback_todo)
|
2011-07-07 23:25:25 +02:00
|
|
|
ok(stat == Ok, "%s.%i: GdipPlayMetafileRecord failed with stat %i\n", state->desc, state->count, stat);
|
2011-07-07 20:31:55 +02:00
|
|
|
state->count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-15 23:14:36 +01:00
|
|
|
todo_wine_if (state->expected[state->count].playback_todo)
|
2011-07-07 20:31:55 +02:00
|
|
|
ok(0, "%s: too many records\n", state->desc);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void play_metafile(GpMetafile *metafile, GpGraphics *graphics, const emfplus_record *expected,
|
|
|
|
const char *desc, const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
emfplus_check_state state;
|
|
|
|
|
|
|
|
state.desc = desc;
|
|
|
|
state.count = 0;
|
|
|
|
state.expected = expected;
|
|
|
|
state.metafile = metafile;
|
|
|
|
|
|
|
|
stat = GdipEnumerateMetafileSrcRectDestPoints(graphics, metafile, dst_points,
|
|
|
|
3, src_rect, src_unit, play_metafile_proc, &state, NULL);
|
|
|
|
expect(Ok, stat);
|
|
|
|
}
|
|
|
|
|
2014-01-24 23:22:58 +01:00
|
|
|
static void save_metafile(GpMetafile *metafile, const char *filename)
|
|
|
|
{
|
|
|
|
if (save_metafiles)
|
|
|
|
{
|
|
|
|
GpMetafile *clone;
|
|
|
|
HENHMETAFILE hemf;
|
|
|
|
GpStatus stat;
|
|
|
|
|
|
|
|
stat = GdipCloneImage((GpImage*)metafile, (GpImage**)&clone);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetHemfFromMetafile(clone, &hemf);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
DeleteEnhMetaFile(CopyEnhMetaFileA(hemf, filename));
|
|
|
|
|
|
|
|
DeleteEnhMetaFile(hemf);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)clone);
|
|
|
|
expect(Ok, stat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-27 01:50:10 +01:00
|
|
|
static const emfplus_record empty_records[] = {
|
2011-05-22 01:36:22 +02:00
|
|
|
{0, EMR_HEADER},
|
|
|
|
{0, EmfPlusRecordTypeHeader},
|
|
|
|
{0, EmfPlusRecordTypeEndOfFile},
|
|
|
|
{0, EMR_EOF},
|
2011-01-27 01:50:10 +01:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2011-01-27 00:23:44 +01:00
|
|
|
static void test_empty(void)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpMetafile *metafile;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
HDC hdc;
|
2015-10-30 20:12:49 +01:00
|
|
|
GpRectF bounds;
|
|
|
|
GpUnit unit;
|
|
|
|
REAL xres, yres;
|
2011-01-27 00:23:44 +01:00
|
|
|
HENHMETAFILE hemf, dummy;
|
2015-10-30 20:12:49 +01:00
|
|
|
MetafileHeader header;
|
2011-01-27 00:23:44 +01:00
|
|
|
static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
|
2011-05-22 00:22:12 +02:00
|
|
|
static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
|
2011-01-27 00:23:44 +01:00
|
|
|
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
2011-04-02 00:09:23 +02:00
|
|
|
stat = GdipRecordMetafile(NULL, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, MetafileTypeInvalid, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, MetafileTypeWmf, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, MetafileTypeWmfPlaceable, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, MetafileTypeEmfPlusDual+1, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, NULL);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
2011-01-27 00:23:44 +01:00
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
|
2011-04-02 00:09:23 +02:00
|
|
|
expect(Ok, stat);
|
2011-01-27 00:23:44 +01:00
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &hemf);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &hemf);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
2011-05-22 00:22:12 +02:00
|
|
|
check_metafile(metafile, empty_records, "empty metafile", dst_points, &frame, UnitPixel);
|
|
|
|
|
2014-01-24 23:22:58 +01:00
|
|
|
save_metafile(metafile, "empty.emf");
|
|
|
|
|
2015-10-30 20:12:49 +01:00
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
|
|
|
expectf_(100.0, bounds.Width, 0.05);
|
|
|
|
expectf_(100.0, bounds.Height, 0.05);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
|
|
|
|
stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &xres);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageVerticalResolution((GpImage*)metafile, &yres);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
2011-01-27 00:23:44 +01:00
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &hemf);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &dummy);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
2011-05-22 00:22:12 +02:00
|
|
|
check_emfplus(hemf, empty_records, "empty emf");
|
2011-01-27 01:50:10 +01:00
|
|
|
|
2015-10-30 20:12:49 +01:00
|
|
|
memset(&header, 0xaa, sizeof(header));
|
|
|
|
stat = GdipGetMetafileHeaderFromEmf(hemf, &header);
|
|
|
|
expect(Ok, stat);
|
2015-10-30 19:54:05 +01:00
|
|
|
expect(MetafileTypeEmfPlusOnly, header.Type);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(U(header).EmfHeader.nBytes, header.Size);
|
2015-10-30 19:54:05 +01:00
|
|
|
ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
|
|
|
|
expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
|
2015-10-30 20:28:12 +01:00
|
|
|
expectf(xres, header.DpiX);
|
|
|
|
expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
|
|
|
|
expectf(yres, header.DpiY);
|
|
|
|
expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(0, header.X);
|
|
|
|
expect(0, header.Y);
|
2015-10-30 19:54:05 +01:00
|
|
|
expect(100, header.Width);
|
|
|
|
expect(100, header.Height);
|
|
|
|
expect(28, header.EmfPlusHeaderSize);
|
|
|
|
expect(96, header.LogicalDpiX);
|
|
|
|
expect(96, header.LogicalDpiX);
|
|
|
|
expect(EMR_HEADER, U(header).EmfHeader.iType);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(0, U(header).EmfHeader.rclBounds.left);
|
|
|
|
expect(0, U(header).EmfHeader.rclBounds.top);
|
2015-10-30 19:54:05 +01:00
|
|
|
expect(-1, U(header).EmfHeader.rclBounds.right);
|
|
|
|
expect(-1, U(header).EmfHeader.rclBounds.bottom);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(0, U(header).EmfHeader.rclFrame.left);
|
|
|
|
expect(0, U(header).EmfHeader.rclFrame.top);
|
2015-10-30 20:28:12 +01:00
|
|
|
expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
|
|
|
|
expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
|
2015-10-30 20:12:49 +01:00
|
|
|
|
|
|
|
stat = GdipCreateMetafileFromEmf(hemf, TRUE, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
2015-10-30 20:55:32 +01:00
|
|
|
expectf_(100.0, bounds.Width, 0.05);
|
|
|
|
expectf_(100.0, bounds.Height, 0.05);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(UnitPixel, unit);
|
|
|
|
|
|
|
|
stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &xres);
|
|
|
|
expect(Ok, stat);
|
2015-10-30 20:55:32 +01:00
|
|
|
expectf(header.DpiX, xres);
|
2015-10-30 20:12:49 +01:00
|
|
|
|
|
|
|
stat = GdipGetImageVerticalResolution((GpImage*)metafile, &yres);
|
|
|
|
expect(Ok, stat);
|
2015-10-30 20:55:32 +01:00
|
|
|
expectf(header.DpiY, yres);
|
2015-10-30 20:12:49 +01:00
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
2011-01-27 00:23:44 +01:00
|
|
|
}
|
|
|
|
|
2011-05-22 01:32:23 +02:00
|
|
|
static const emfplus_record getdc_records[] = {
|
2011-07-07 23:25:25 +02:00
|
|
|
{0, EMR_HEADER},
|
|
|
|
{0, EmfPlusRecordTypeHeader},
|
|
|
|
{0, EmfPlusRecordTypeGetDC},
|
|
|
|
{0, EMR_CREATEBRUSHINDIRECT},
|
|
|
|
{0, EMR_SELECTOBJECT},
|
|
|
|
{0, EMR_RECTANGLE},
|
|
|
|
{0, EMR_SELECTOBJECT},
|
|
|
|
{0, EMR_DELETEOBJECT},
|
|
|
|
{0, EmfPlusRecordTypeEndOfFile},
|
|
|
|
{0, EMR_EOF},
|
2011-05-22 01:32:23 +02:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_getdc(void)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpMetafile *metafile;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
HDC hdc, metafile_dc;
|
|
|
|
HENHMETAFILE hemf;
|
|
|
|
BOOL ret;
|
|
|
|
static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
|
|
|
|
static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
|
2011-07-07 20:31:55 +02:00
|
|
|
static const GpPointF dst_points_half[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
|
2011-05-22 01:32:23 +02:00
|
|
|
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
|
|
|
|
HBRUSH hbrush, holdbrush;
|
2011-07-07 20:31:55 +02:00
|
|
|
GpBitmap *bitmap;
|
|
|
|
ARGB color;
|
2011-05-22 01:32:23 +02:00
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &hemf);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetDC(graphics, &metafile_dc);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
{
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
GdipDisposeImage((GpImage*)metafile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hbrush = CreateSolidBrush(0xff0000);
|
|
|
|
|
|
|
|
holdbrush = SelectObject(metafile_dc, hbrush);
|
|
|
|
|
|
|
|
Rectangle(metafile_dc, 25, 25, 75, 75);
|
|
|
|
|
|
|
|
SelectObject(metafile_dc, holdbrush);
|
|
|
|
|
|
|
|
DeleteObject(hbrush);
|
|
|
|
|
|
|
|
stat = GdipReleaseDC(graphics, metafile_dc);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
check_metafile(metafile, getdc_records, "getdc metafile", dst_points, &frame, UnitPixel);
|
|
|
|
|
2014-01-24 23:22:58 +01:00
|
|
|
save_metafile(metafile, "getdc.emf");
|
|
|
|
|
2011-07-07 20:31:55 +02:00
|
|
|
stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
play_metafile(metafile, graphics, getdc_records, "getdc playback", dst_points, &frame, UnitPixel);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
2011-07-07 23:25:25 +02:00
|
|
|
expect(0xff0000ff, color);
|
2011-07-07 20:31:55 +02:00
|
|
|
|
|
|
|
stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
play_metafile(metafile, graphics, getdc_records, "getdc playback", dst_points_half, &frame, UnitPixel);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
2011-07-07 23:25:25 +02:00
|
|
|
expect(0xff0000ff, color);
|
2011-07-07 20:31:55 +02:00
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
2012-10-31 19:24:20 +01:00
|
|
|
stat = GdipBitmapSetPixel(bitmap, 15, 15, 0);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
|
|
|
|
0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
|
2012-10-31 19:36:00 +01:00
|
|
|
expect(Ok, stat);
|
2012-10-31 19:24:20 +01:00
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
2012-10-31 19:36:00 +01:00
|
|
|
expect(0xff0000ff, color);
|
2012-10-31 19:24:20 +01:00
|
|
|
|
2011-07-07 20:31:55 +02:00
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)bitmap);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
2011-05-22 01:32:23 +02:00
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &hemf);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
check_emfplus(hemf, getdc_records, "getdc emf");
|
|
|
|
|
|
|
|
ret = DeleteEnhMetaFile(hemf);
|
|
|
|
ok(ret != 0, "Failed to delete enhmetafile %p\n", hemf);
|
|
|
|
}
|
|
|
|
|
2011-07-07 18:37:07 +02:00
|
|
|
static const emfplus_record emfonly_records[] = {
|
2011-07-07 23:25:25 +02:00
|
|
|
{0, EMR_HEADER},
|
|
|
|
{0, EMR_CREATEBRUSHINDIRECT},
|
|
|
|
{0, EMR_SELECTOBJECT},
|
|
|
|
{0, EMR_RECTANGLE},
|
|
|
|
{0, EMR_SELECTOBJECT},
|
|
|
|
{0, EMR_DELETEOBJECT},
|
|
|
|
{0, EMR_EOF},
|
2011-07-07 18:37:07 +02:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_emfonly(void)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpMetafile *metafile;
|
2012-10-31 20:33:50 +01:00
|
|
|
GpImage *clone;
|
2011-07-07 18:37:07 +02:00
|
|
|
GpGraphics *graphics;
|
|
|
|
HDC hdc, metafile_dc;
|
2015-10-30 20:12:49 +01:00
|
|
|
GpRectF bounds;
|
|
|
|
GpUnit unit;
|
|
|
|
REAL xres, yres;
|
2011-07-07 18:37:07 +02:00
|
|
|
HENHMETAFILE hemf;
|
2015-10-30 20:12:49 +01:00
|
|
|
MetafileHeader header;
|
2011-07-07 18:37:07 +02:00
|
|
|
static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
|
|
|
|
static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
|
|
|
|
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
|
|
|
|
HBRUSH hbrush, holdbrush;
|
2011-07-07 20:31:55 +02:00
|
|
|
GpBitmap *bitmap;
|
|
|
|
ARGB color;
|
2011-07-07 18:37:07 +02:00
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &hemf);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetDC(graphics, &metafile_dc);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
{
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
GdipDisposeImage((GpImage*)metafile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hbrush = CreateSolidBrush(0xff0000);
|
|
|
|
|
|
|
|
holdbrush = SelectObject(metafile_dc, hbrush);
|
|
|
|
|
|
|
|
Rectangle(metafile_dc, 25, 25, 75, 75);
|
|
|
|
|
|
|
|
SelectObject(metafile_dc, holdbrush);
|
|
|
|
|
|
|
|
DeleteObject(hbrush);
|
|
|
|
|
|
|
|
stat = GdipReleaseDC(graphics, metafile_dc);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
check_metafile(metafile, emfonly_records, "emfonly metafile", dst_points, &frame, UnitPixel);
|
|
|
|
|
2014-01-24 23:22:58 +01:00
|
|
|
save_metafile(metafile, "emfonly.emf");
|
|
|
|
|
2015-10-30 20:12:49 +01:00
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
|
|
|
expectf_(100.0, bounds.Width, 0.05);
|
|
|
|
expectf_(100.0, bounds.Height, 0.05);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
|
|
|
|
stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &xres);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageVerticalResolution((GpImage*)metafile, &yres);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
2011-07-07 20:31:55 +02:00
|
|
|
stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
play_metafile(metafile, graphics, emfonly_records, "emfonly playback", dst_points, &frame, UnitPixel);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
2011-07-07 23:25:25 +02:00
|
|
|
expect(0xff0000ff, color);
|
2011-07-07 20:31:55 +02:00
|
|
|
|
2012-10-31 19:24:20 +01:00
|
|
|
stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
|
|
|
|
0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
|
2012-10-31 19:36:00 +01:00
|
|
|
expect(Ok, stat);
|
2012-10-31 19:24:20 +01:00
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
2012-10-31 19:36:00 +01:00
|
|
|
expect(0xff0000ff, color);
|
2012-10-31 19:24:20 +01:00
|
|
|
|
2012-10-31 20:33:50 +01:00
|
|
|
stat = GdipCloneImage((GpImage*)metafile, &clone);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDrawImagePointsRect(graphics, clone, dst_points, 3,
|
|
|
|
0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xff0000ff, color);
|
|
|
|
|
|
|
|
GdipDisposeImage(clone);
|
|
|
|
}
|
|
|
|
|
2011-07-07 20:31:55 +02:00
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)bitmap);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
2011-07-07 18:37:07 +02:00
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &hemf);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
check_emfplus(hemf, emfonly_records, "emfonly emf");
|
|
|
|
|
2015-10-30 20:12:49 +01:00
|
|
|
memset(&header, 0xaa, sizeof(header));
|
|
|
|
stat = GdipGetMetafileHeaderFromEmf(hemf, &header);
|
|
|
|
expect(Ok, stat);
|
2015-10-30 19:54:05 +01:00
|
|
|
expect(MetafileTypeEmf, header.Type);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(U(header).EmfHeader.nBytes, header.Size);
|
2015-10-30 19:54:05 +01:00
|
|
|
expect(0x10000, header.Version);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(0, header.EmfPlusFlags);
|
2015-10-30 20:28:12 +01:00
|
|
|
expectf(xres, header.DpiX);
|
|
|
|
expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
|
|
|
|
expectf(yres, header.DpiY);
|
|
|
|
expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(0, header.X);
|
|
|
|
expect(0, header.Y);
|
2015-10-30 19:54:05 +01:00
|
|
|
expect(100, header.Width);
|
|
|
|
expect(100, header.Height);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(0, header.EmfPlusHeaderSize);
|
|
|
|
expect(0, header.LogicalDpiX);
|
|
|
|
expect(0, header.LogicalDpiX);
|
2015-10-30 19:54:05 +01:00
|
|
|
expect(EMR_HEADER, U(header).EmfHeader.iType);
|
|
|
|
expect(25, U(header).EmfHeader.rclBounds.left);
|
|
|
|
expect(25, U(header).EmfHeader.rclBounds.top);
|
|
|
|
expect(74, U(header).EmfHeader.rclBounds.right);
|
|
|
|
expect(74, U(header).EmfHeader.rclBounds.bottom);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(0, U(header).EmfHeader.rclFrame.left);
|
|
|
|
expect(0, U(header).EmfHeader.rclFrame.top);
|
2015-10-30 20:28:12 +01:00
|
|
|
expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
|
|
|
|
expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
|
2015-10-30 20:12:49 +01:00
|
|
|
|
|
|
|
stat = GdipCreateMetafileFromEmf(hemf, TRUE, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
2015-10-30 20:55:32 +01:00
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
|
|
|
expectf_(100.0, bounds.Width, 0.05);
|
|
|
|
expectf_(100.0, bounds.Height, 0.05);
|
2015-10-30 20:12:49 +01:00
|
|
|
expect(UnitPixel, unit);
|
|
|
|
|
|
|
|
stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &xres);
|
|
|
|
expect(Ok, stat);
|
2015-10-30 20:55:32 +01:00
|
|
|
expectf(header.DpiX, xres);
|
2015-10-30 20:12:49 +01:00
|
|
|
|
|
|
|
stat = GdipGetImageVerticalResolution((GpImage*)metafile, &yres);
|
|
|
|
expect(Ok, stat);
|
2015-10-30 20:55:32 +01:00
|
|
|
expectf(header.DpiY, yres);
|
2015-10-30 20:12:49 +01:00
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
2011-07-07 18:37:07 +02:00
|
|
|
}
|
|
|
|
|
2013-11-20 23:07:26 +01:00
|
|
|
static const emfplus_record fillrect_records[] = {
|
|
|
|
{0, EMR_HEADER},
|
|
|
|
{0, EmfPlusRecordTypeHeader},
|
|
|
|
{0, EmfPlusRecordTypeFillRects},
|
|
|
|
{0, EmfPlusRecordTypeEndOfFile},
|
|
|
|
{0, EMR_EOF},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_fillrect(void)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpMetafile *metafile;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
HDC hdc;
|
|
|
|
HENHMETAFILE hemf;
|
|
|
|
static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
|
|
|
|
static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
|
|
|
|
static const GpPointF dst_points_half[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
|
|
|
|
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
|
|
|
|
GpBitmap *bitmap;
|
|
|
|
ARGB color;
|
|
|
|
GpBrush *brush;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stat = GdipGetHemfFromMetafile(metafile, &hemf);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipFillRectangleI(graphics, brush, 25, 25, 75, 75);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteBrush(brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
check_metafile(metafile, fillrect_records, "fillrect metafile", dst_points, &frame, UnitPixel);
|
|
|
|
|
2014-01-24 23:22:58 +01:00
|
|
|
save_metafile(metafile, "fillrect.emf");
|
|
|
|
|
2013-11-20 23:07:26 +01:00
|
|
|
stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points, &frame, UnitPixel);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xff0000ff, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points_half, &frame, UnitPixel);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xff0000ff, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapSetPixel(bitmap, 15, 15, 0);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
|
|
|
|
0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xff0000ff, color);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)bitmap);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
}
|
|
|
|
|
2016-04-06 21:36:56 +02:00
|
|
|
static void test_nullframerect(void) {
|
|
|
|
GpStatus stat;
|
|
|
|
GpMetafile *metafile;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
HDC hdc, metafile_dc;
|
|
|
|
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
|
|
|
|
GpBrush *brush;
|
|
|
|
HBRUSH hbrush, holdbrush;
|
|
|
|
GpRectF bounds;
|
|
|
|
GpUnit unit;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, NULL, MetafileFrameUnitPixel, description, &metafile);
|
2016-04-06 21:36:57 +02:00
|
|
|
expect(Ok, stat);
|
2016-04-06 21:36:56 +02:00
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
2016-06-06 23:00:49 +02:00
|
|
|
ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
|
|
|
|
"expected 1.0, got %f\n", bounds.Width);
|
|
|
|
ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
|
|
|
|
"expected 1.0, got %f\n", bounds.Height);
|
2016-04-06 21:36:56 +02:00
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipFillRectangleI(graphics, brush, 25, 25, 75, 75);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteBrush(brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
2016-06-06 23:00:49 +02:00
|
|
|
ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
|
|
|
|
"expected 1.0, got %f\n", bounds.Width);
|
|
|
|
ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
|
|
|
|
"expected 1.0, got %f\n", bounds.Height);
|
2016-04-06 21:36:56 +02:00
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitPixel, unit);
|
2016-04-06 21:36:57 +02:00
|
|
|
todo_wine expectf_(25.0, bounds.X, 0.05);
|
|
|
|
todo_wine expectf_(25.0, bounds.Y, 0.05);
|
|
|
|
todo_wine expectf_(75.0, bounds.Width, 0.05);
|
|
|
|
todo_wine expectf_(75.0, bounds.Height, 0.05);
|
2016-04-06 21:36:56 +02:00
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, NULL, MetafileFrameUnitMillimeter, description, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetDC(graphics, &metafile_dc);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
{
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
GdipDisposeImage((GpImage*)metafile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hbrush = CreateSolidBrush(0xff0000);
|
|
|
|
|
|
|
|
holdbrush = SelectObject(metafile_dc, hbrush);
|
|
|
|
|
|
|
|
Rectangle(metafile_dc, 25, 25, 75, 75);
|
|
|
|
|
|
|
|
SelectObject(metafile_dc, holdbrush);
|
|
|
|
|
|
|
|
DeleteObject(hbrush);
|
|
|
|
|
|
|
|
stat = GdipReleaseDC(graphics, metafile_dc);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
expectf_(25.0, bounds.X, 0.05);
|
|
|
|
expectf_(25.0, bounds.Y, 0.05);
|
2016-04-06 21:36:57 +02:00
|
|
|
todo_wine expectf_(50.0, bounds.Width, 0.05);
|
|
|
|
todo_wine expectf_(50.0, bounds.Height, 0.05);
|
2016-04-06 21:36:56 +02:00
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
}
|
|
|
|
|
2014-01-16 21:58:50 +01:00
|
|
|
static const emfplus_record pagetransform_records[] = {
|
|
|
|
{0, EMR_HEADER},
|
|
|
|
{0, EmfPlusRecordTypeHeader},
|
|
|
|
{0, EmfPlusRecordTypeFillRects},
|
|
|
|
{0, EmfPlusRecordTypeSetPageTransform},
|
|
|
|
{0, EmfPlusRecordTypeFillRects},
|
|
|
|
{0, EmfPlusRecordTypeSetPageTransform},
|
|
|
|
{0, EmfPlusRecordTypeFillRects},
|
|
|
|
{0, EmfPlusRecordTypeSetPageTransform},
|
|
|
|
{0, EmfPlusRecordTypeFillRects},
|
|
|
|
{0, EmfPlusRecordTypeSetPageTransform},
|
|
|
|
{0, EmfPlusRecordTypeFillRects},
|
|
|
|
{0, EmfPlusRecordTypeEndOfFile},
|
|
|
|
{0, EMR_EOF},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_pagetransform(void)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpMetafile *metafile;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
HDC hdc;
|
|
|
|
static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
|
|
|
|
static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
|
|
|
|
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
|
|
|
|
GpBitmap *bitmap;
|
|
|
|
ARGB color;
|
|
|
|
GpBrush *brush;
|
|
|
|
GpUnit unit;
|
|
|
|
REAL scale, dpix, dpiy;
|
|
|
|
UINT width, height;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitInch, description, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &dpix);
|
|
|
|
todo_wine expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageVerticalResolution((GpImage*)metafile, &dpiy);
|
|
|
|
todo_wine expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageWidth((GpImage*)metafile, &width);
|
|
|
|
todo_wine expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageHeight((GpImage*)metafile, &height);
|
|
|
|
todo_wine expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
/* initial scale */
|
|
|
|
stat = GdipGetPageUnit(graphics, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitDisplay, unit);
|
|
|
|
|
|
|
|
stat = GdipGetPageScale(graphics, &scale);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expectf(1.0, scale);
|
|
|
|
|
|
|
|
stat = GdipGetDpiX(graphics, &dpix);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expectf(96.0, dpix);
|
|
|
|
|
|
|
|
stat = GdipGetDpiY(graphics, &dpiy);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expectf(96.0, dpiy);
|
|
|
|
|
|
|
|
stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipFillRectangleI(graphics, brush, 1, 2, 1, 1);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteBrush(brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
/* page unit = pixels */
|
|
|
|
stat = GdipSetPageUnit(graphics, UnitPixel);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetPageUnit(graphics, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
|
|
|
|
stat = GdipCreateSolidFill((ARGB)0xff00ff00, (GpSolidFill**)&brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipFillRectangleI(graphics, brush, 0, 1, 1, 1);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteBrush(brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
/* page scale = 3, unit = pixels */
|
|
|
|
stat = GdipSetPageScale(graphics, 3.0);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetPageScale(graphics, &scale);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expectf(3.0, scale);
|
|
|
|
|
|
|
|
stat = GdipCreateSolidFill((ARGB)0xff00ffff, (GpSolidFill**)&brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipFillRectangleI(graphics, brush, 0, 1, 2, 2);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteBrush(brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
/* page scale = 3, unit = inches */
|
|
|
|
stat = GdipSetPageUnit(graphics, UnitInch);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetPageUnit(graphics, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitInch, unit);
|
|
|
|
|
|
|
|
stat = GdipCreateSolidFill((ARGB)0xffff0000, (GpSolidFill**)&brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipFillRectangle(graphics, brush, 1.0/96.0, 0, 1, 1);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteBrush(brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
/* page scale = 3, unit = display */
|
|
|
|
stat = GdipSetPageUnit(graphics, UnitDisplay);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetPageUnit(graphics, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitDisplay, unit);
|
|
|
|
|
|
|
|
stat = GdipCreateSolidFill((ARGB)0xffff00ff, (GpSolidFill**)&brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipFillRectangle(graphics, brush, 3, 3, 2, 2);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteBrush(brush);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
check_metafile(metafile, pagetransform_records, "pagetransform metafile", dst_points, &frame, UnitPixel);
|
|
|
|
|
2014-01-24 23:22:58 +01:00
|
|
|
save_metafile(metafile, "pagetransform.emf");
|
|
|
|
|
2014-01-16 21:58:50 +01:00
|
|
|
stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
play_metafile(metafile, graphics, pagetransform_records, "pagetransform playback", dst_points, &frame, UnitPixel);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 30, 50, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xff0000ff, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 10, 30, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xff00ff00, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 20, 80, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xff00ffff, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 80, 20, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xffff0000, color);
|
|
|
|
|
|
|
|
stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(0xffff00ff, color);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)bitmap);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
}
|
|
|
|
|
2015-07-09 08:10:24 +02:00
|
|
|
static void test_converttoemfplus(void)
|
|
|
|
{
|
|
|
|
GpStatus (WINAPI *pGdipConvertToEmfPlus)( const GpGraphics *graphics, GpMetafile *metafile, BOOL *succ,
|
|
|
|
EmfType emfType, const WCHAR *description, GpMetafile **outmetafile);
|
|
|
|
static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
|
|
|
|
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
|
|
|
|
GpStatus stat;
|
|
|
|
GpMetafile *metafile, *metafile2 = NULL, *emhmeta;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
HDC hdc;
|
|
|
|
BOOL succ;
|
|
|
|
HMODULE mod = GetModuleHandleA("gdiplus.dll");
|
|
|
|
|
|
|
|
pGdipConvertToEmfPlus = (void*)GetProcAddress( mod, "GdipConvertToEmfPlus");
|
|
|
|
if(!pGdipConvertToEmfPlus)
|
|
|
|
{
|
|
|
|
/* GdipConvertToEmfPlus was introduced in Windows Vista. */
|
|
|
|
win_skip("GDIPlus version 1.1 not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, MetafileTypeEmf, &frame, MetafileFrameUnitPixel, description, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &emhmeta);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
/* Invalid Parameters */
|
|
|
|
stat = pGdipConvertToEmfPlus(NULL, metafile, &succ, EmfTypeEmfPlusOnly, description, &metafile2);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = pGdipConvertToEmfPlus(graphics, NULL, &succ, EmfTypeEmfPlusOnly, description, &metafile2);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = pGdipConvertToEmfPlus(graphics, metafile, &succ, EmfTypeEmfPlusOnly, description, NULL);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, MetafileTypeInvalid, NULL, &metafile2);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, MetafileTypeEmfPlusDual+1, NULL, &metafile2);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
/* If we are already an Enhanced Metafile then the conversion fails. */
|
|
|
|
stat = pGdipConvertToEmfPlus(graphics, emhmeta, NULL, EmfTypeEmfPlusOnly, NULL, &metafile2);
|
|
|
|
todo_wine expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, EmfTypeEmfPlusOnly, NULL, &metafile2);
|
|
|
|
todo_wine expect(Ok, stat);
|
|
|
|
if(metafile2)
|
|
|
|
GdipDisposeImage((GpImage*)metafile2);
|
|
|
|
|
|
|
|
succ = FALSE;
|
|
|
|
stat = pGdipConvertToEmfPlus(graphics, metafile, &succ, EmfTypeEmfPlusOnly, NULL, &metafile2);
|
|
|
|
todo_wine expect(Ok, stat);
|
|
|
|
if(metafile2)
|
|
|
|
GdipDisposeImage((GpImage*)metafile2);
|
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)emhmeta);
|
|
|
|
expect(Ok, stat);
|
|
|
|
}
|
|
|
|
|
2016-04-06 21:36:55 +02:00
|
|
|
static void test_frameunit(void)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpMetafile *metafile;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
HDC hdc;
|
|
|
|
static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
|
|
|
|
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
|
|
|
|
GpUnit unit;
|
|
|
|
REAL dpix, dpiy;
|
|
|
|
GpRectF bounds;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitInch, description, &metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
2016-06-06 23:00:49 +02:00
|
|
|
ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
|
|
|
|
"expected 1.0, got %f\n", bounds.Width);
|
|
|
|
ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
|
|
|
|
"expected 1.0, got %f\n", bounds.Height);
|
2016-04-06 21:36:55 +02:00
|
|
|
|
|
|
|
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
2016-06-06 23:00:49 +02:00
|
|
|
ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
|
|
|
|
"expected 1.0, got %f\n", bounds.Width);
|
|
|
|
ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
|
|
|
|
"expected 1.0, got %f\n", bounds.Height);
|
2016-04-06 21:36:55 +02:00
|
|
|
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &dpix);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageVerticalResolution((GpImage*)metafile, &dpiy);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
|
|
|
|
expect(Ok, stat);
|
|
|
|
expect(UnitPixel, unit);
|
|
|
|
expectf(0.0, bounds.X);
|
|
|
|
expectf(0.0, bounds.Y);
|
|
|
|
expectf_(5.0 * dpix, bounds.Width, 1.0);
|
|
|
|
expectf_(5.0 * dpiy, bounds.Height, 1.0);
|
|
|
|
|
|
|
|
stat = GdipDisposeImage((GpImage*)metafile);
|
|
|
|
expect(Ok, stat);
|
|
|
|
}
|
|
|
|
|
2011-01-27 00:23:44 +01:00
|
|
|
START_TEST(metafile)
|
|
|
|
{
|
|
|
|
struct GdiplusStartupInput gdiplusStartupInput;
|
|
|
|
ULONG_PTR gdiplusToken;
|
2014-01-24 23:22:58 +01:00
|
|
|
int myARGC;
|
|
|
|
char **myARGV;
|
2011-01-27 00:23:44 +01:00
|
|
|
|
|
|
|
gdiplusStartupInput.GdiplusVersion = 1;
|
|
|
|
gdiplusStartupInput.DebugEventCallback = NULL;
|
|
|
|
gdiplusStartupInput.SuppressBackgroundThread = 0;
|
|
|
|
gdiplusStartupInput.SuppressExternalCodecs = 0;
|
|
|
|
|
|
|
|
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
|
|
|
|
|
2014-01-24 23:22:58 +01:00
|
|
|
myARGC = winetest_get_mainargs( &myARGV );
|
|
|
|
|
|
|
|
if (myARGC >= 3 && !strcmp(myARGV[2], "save"))
|
|
|
|
save_metafiles = TRUE;
|
|
|
|
|
2011-01-27 00:23:44 +01:00
|
|
|
test_empty();
|
2011-05-22 01:32:23 +02:00
|
|
|
test_getdc();
|
2011-07-07 18:37:07 +02:00
|
|
|
test_emfonly();
|
2013-11-20 23:07:26 +01:00
|
|
|
test_fillrect();
|
2016-04-06 21:36:56 +02:00
|
|
|
test_nullframerect();
|
2014-01-16 21:58:50 +01:00
|
|
|
test_pagetransform();
|
2015-07-09 08:10:24 +02:00
|
|
|
test_converttoemfplus();
|
2016-04-06 21:36:55 +02:00
|
|
|
test_frameunit();
|
2011-01-27 00:23:44 +01:00
|
|
|
|
|
|
|
GdiplusShutdown(gdiplusToken);
|
|
|
|
}
|