libgdiplus icon indicating copy to clipboard operation
libgdiplus copied to clipboard

Respect current transformation matrix and page unit in GdipDrawImagePoints* functions

Open shibaev opened this issue 6 years ago • 0 comments

These functions do not respect current transformation matrix and page unit: GdipDrawImagePoints GdipDrawImagePointsI GdipDrawImagePointsRect GdipDrawImagePointsRectI

Take a look at the following test (place in tests/testgraphicsdraw.c):

static void test_drawImagePoints_customPageUnitAndTransformation ()
{
	GpStatus status;
	GpImage *image;
	GpGraphics *graphics;
	GpImage *bitmapImage;
	PointF points[] = {
		{10, 20},
		{160, 10},
		{50, 120}
	};

	GdipLoadImageFromFile (bitmapFile, &bitmapImage);

	createImageGraphics (500, 500, &image, &graphics);

	status = GdipSetPageUnit (graphics, UnitPoint);
	assertEqualInt (status, Ok);

	status = GdipTranslateWorldTransform (graphics, 100, 100, MatrixOrderPrepend);
	assertEqualInt (status, Ok);

	status = GdipDrawImagePoints (graphics, bitmapImage, points, 3);
	assertEqualInt (status, Ok);

	CLSID png_clsid = { 0x557cf406, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } };
	WCHAR *filePath = createWchar ("test_drawImagePoints_customPageUnitAndTransformation.png");
	status = GdipSaveImageToFile (image, filePath, &png_clsid, NULL);

	GdipDeleteGraphics (graphics);
	GdipDisposeImage (image);
	GdipDisposeImage (bitmapImage);
}

Currently, it produces the following output (incorrect image position and size): test_drawImagePoints_customPageUnitAndTransformation

Note that you can comment this call and the result won't change: status = GdipTranslateWorldTransform (graphics, 100, 100, MatrixOrderPrepend);

Expected result: test_drawImagePoints_customPageUnitAndTransformation_expected

Two points to fix:

  1. Scale input points from current page units to Cairo coordinates
  2. Concatenate matrix produced from input points with the current transformation matrix

shibaev avatar May 29 '19 09:05 shibaev