DynaPDF Manual - Page 669
Previous Page 668 Index Next Page 670
Function Reference
Page 669 of 860
// Now you can allocate the image buffer or check whether the existing
// one is large enough.
if (w != lastWidth || h != lastHeight)
{
}
Calculating the size of the image buffer is easy, and scrolling is easy too when the zoom factor is
100%. The handling of other zoom factors is the most complex part in a viewer application. For
zoom factors between 10% and 200% it is usually best to render the entire page as described above
but larger zoom factors cannot be handled in this way because at some point the image becomes too
large and the rendering time would become too long.
For larger zoom factors it is mostly better to render the page directly with the required zoom factor
into the client rectangle since the rasterizer can then skip invisible objects to speed up processing.
The Transformation Matrix
The transformation matrix can be used to scroll the page up and down, and to scale it with an
arbitrary zoom factor, or to rotate it if necessary. The matrix must be defined in device space, that is
the coordinate space of the image buffer. This makes it very easy to scroll and zoom into the page
since you don't need to consider the coordinate space of the PDF page.
The coordinate space of the rendering engine is top down and not bottom up like the native PDF
coordinate space. So, negative y-coordinates move the PDF image to the top direction of the
window and positive values move it to the opposite direction.
Example:
// This matrix scrolls the PDF image 120 pixels down
img.Matrix.a = 1.0;
img.Matrix.b = 0.0;
img.Matrix.c = 0.0;
img.Matrix.d = 1.0;
img.Matrix.x = 0.0;
img.Matrix.y = -120.0;
Zooming into the page is very easy too. Simply set the zoom factor to the a and d coefficients of the
transformation matrix:
img.Matrix.a = m_Zoom;
img.Matrix.b = 0.0;
img.Matrix.c = 0.0;
img.Matrix.d = m_Zoom;
img.Matrix.x = m_x;
img.Matrix.y = m_y;
Previous topic: Blending Color Spaces, Rendering PDF Pages
Next topic: The OnUpdateWindow Event, The update area, UpdateOnPathCount limit