Matrix stuff - some inner info  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Matrix stuff - some inner info

Post by zarkogajic »

Hi Support,

I've seen code samples using matrix manipulation do to various stuff.

Example: ConvertToImage function in CoreSamples to save a PDF page as an image.

I have the code running and that is all ok.

What bothers me is that I have no clue what and more importantly why are matrices used how they are used.

Example (coming from ConvertToImage function):

Code: Select all

PXC_Matrix matrix = Page.GetMatrix(PXC_BoxType.PBox_PageBox);

// this part ??
matrix = auxInst.MathHelper.Matrix_Scale(ref matrix, cx / nWidth, -cy / nHeight);
matrix = auxInst.MathHelper.Matrix_Translate(ref matrix, 0, cy);

Page.DrawToIXCPage(ixcPage, ref rc, ref matrix, param);
Having

Code: Select all

Page.GetDimension(out nWidth, out nHeight);
uint cx = (uint)(nWidth * 150 / 72.0);
uint cy = (uint)(nHeight * 150 / 72.0);

The part with a big "?" on top of my head is:

Code: Select all

matrix = auxInst.MathHelper.Matrix_Scale(ref matrix, cx / nWidth, -cy / nHeight);
matrix = auxInst.MathHelper.Matrix_Translate(ref matrix, 0, cy);
What is really happening here? Why those 2 code lines?

Further, there's even more complex code here: https://forum.pdf-xchange.com/viewtopic.php?f=66&t=30710&p=122842&hilit=Page_CreateEmpty#p122842

In that code, Matrix_Multiply is also used.

Is this (Matrices and how/when used) explained somewhere in detail?

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Matrix stuff - some inner info

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

You can read the PDF Specification to understand the matrices more:
8.3 Coordinate systems
8.9 Images

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Matrix stuff - some inner info  SOLVED

Post by zarkogajic »

Hi Alex,

Ok, thanks. That will have to do it ...

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Matrix stuff - some inner info

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply