Print Page | Close Window

Help with DrawImageMatrix

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2228
Printed Date: 23 Apr 24 at 3:51PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Help with DrawImageMatrix
Posted By: kaiken1987
Subject: Help with DrawImageMatrix
Date Posted: 12 Apr 12 at 7:34PM
I'm trying to use DrawImageMatrix but I can't get the image to display.
I assume that the parameters work so that
x' = x*m11+y*m12+mdx
y' = x*m21+y*m22+mdy
so if run with DrawImageMatrix(1,0,0,1,0,0) is should draw at the origin at its original size and orientation however nothing shows up in the output pdf. If I do a normal DrawImage it displays fine and DrawImageMatrix returns no error.

example code
 
QP->NewDocument();
QP->SetPageDimensions(3900,2400);
QP->SelectPage(1);
QP->SetOrigin(1);
QP->AddImageFromFile(L"test.tif",0);
QP->DrawImageMatrix(1,0,0,1,0,0);
QP->SaveToFile(L"Test.pdf");



Replies:
Posted By: AndrewC
Date Posted: 13 Apr 12 at 11:57AM

The last two parameters are x,y so experiment with those first...  The image will be scaled to 1pt x 1pt so increase the 1 values to width and height values.

  QP.DrawImageMatrix(100, 0, 0, 100, 300, 300);

Here is some code that generates an interesting pattern.  This code is not mine so I cannot tell you how the parameters were created.

            QP.CompressImages(1);
            int ImageID = QP.AddImageFromFile("aldi.bmp", 0);
            QP.SelectPage(1);
            QP.SelectImage(ImageID);

            QP.DrawImageMatrix(100, 0, 0, 100, 300, 300);


            QP.DrawImageMatrix(152.44,
                        60.9762,
                        -1.53974,
                        72.7334,
                        55.8672,
                        543);
            QP.DrawImageMatrix(151.872,
                        63.3877,
                        -124.567,
                        98.8179,
                        179.203,
                        443.602);
            QP.DrawImageMatrix(154.612,
                        63.9774,
                        -125.495,
                        75.8196,
                        179.204,
                        540.918);
            QP.DrawImageMatrix(153.172,
                        63.6644,
                        0,
                        98.6157,
                        178.163,
                        444.123);

            QP.SaveToFile("out.pdf");
            Process.Start(@"out.pdf");



Posted By: fellafoo
Date Posted: 23 May 22 at 4:51PM
In the Adobe PDF Reference, search for Common Transformations.
It's in section 8.3.3 of the PDF 1.7 document:
https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf" rel="nofollow - https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf

For example:

SetMeasurementUnits(0);
Note: I've gotten unexpected results using millimeters or inches.

For Translation (Move X / Move Y from Origin (Left, Bottom))...
DrawImageMatrix(ImageWidth * 1, 0, 0, ImageHeight * 1, MoveX, MoveY)

For Scaling (Enlarge X / Enlarge Y)...
DrawImageMatrix(ImageWidth * Enlargement, 0, 0, ImageHeight * Enlargement, 0, 0)

For Rotations (Counter-clockwise Angle around origin)...
DrawImageMatrix(ImageWidth * Cos(Angle * Pi / 180), ImageWidth * Sin(Angle * Pi / 180), ImageHeight * - Sin(Angle * Pi / 180), ImageHeight * Cos(Angle * Pi / 180), 0, 0)

For Skew (ImageWidth * 1, Tan(AngleX * Pi / 180), Tan(AngleY * Pi / 180), ImageHeight * 1, 0, 0)

FWIW,

MFM


Posted By: Ingo
Date Posted: 23 May 22 at 8:26PM
Hi :)


you should have a look at:

SetOrigin:
https://www.debenu.com/docs/pdf_library_reference/SetOrigin.php
SetGlobalOrigin:
https://www.debenu.com/docs/pdf_library_reference/SetGlobalOrigin.php
SetMeasurementUnits:
https://www.debenu.com/docs/pdf_library_reference/SetMeasurementUnits.php
SetGlobalMeasurementUnits:
https://www.debenu.com/docs/pdf_library_reference/SetGlobalMeasurementUnits.php
 
This are functions from the measurement and coordinate unit:
https://www.debenu.com/docs/pdf_library_reference/SetGlobalMeasurementUnits.php
Think there you'll find a solution for your issues...




-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk