A Beginners guide to PDF Lattice Shading

At IDR Solutions Ive spent a lot of time working with the development of the JPedal Java PDF Library and PDF to HTML5 Converter I thought about writing an article on PDF lattice shading to illustrate how to achieve Lattice shading in PDF files.

Where can I get shading information ?

BitsPerCoordinate : This entry is used to represent the number of bits required to find x,y vertex coordinates.

BitsPerComponent : Entry used to represent number of bits required to define color components.

VerticesPerRow : This is the unique entry in lattice shading compared to free-form. Vertices per row defines how many vertices are located in a single row.

Decode : An array of number specifies how to map vertex coordinates and color components to appropriate ranges. [xmin xmax ymin ymax c1,min c1,max … cn,min cn,max]

You can find above information in the PDF reference, where it will be in more detail.

Mapping : In many PDF files large coordination space are defined with small coordination space and it will then map to large domain using decode array.

For example : the xy coordinates can be defined as x:0.50109 and y:0.52197 and use -16384.0 16384.0 -16384.0 16384.0 as array values in decode array entry in order to obtain x= 36.0, y= 720.0.

Data Representation : Triangle data in PDF files looks defined similar to below order if it contains 5 vertices per row:

x1y1c1…cn x2y2c1…cn x3y3c1…cn x4y4c1…cn x5y5c1…cn
x6y6c1…cn x7y7c1…cn x8y8c1…cn x9y9c1…cn x10y10c1…cn

lattice

Triangles are formulated connecting vertices points and color interpolation is used to define colors in triangular space. More information on color interpolation on freeform triangle mesh can be found in this article I wrote called ‘PDF Gouraud shading (Free-Form) Color Interpolation

I Hope you find this information useful and in the future I will investigate coons shading in my next article.

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (Twitter,FacebookandGoogle+) or theBlog RSS.

Related Posts:

The following two tabs change content below.

suda

Java EE developer at IDRSolutions
Suda is the Senior Java EE Developer at IDR Solutions, and specialises in XFA, Fonts, True-Type Fonts, application servers and conversions. He is a keen science-fiction fan in his spare time.
suda

About suda

Suda is the Senior Java EE Developer at IDR Solutions, and specialises in XFA, Fonts, True-Type Fonts, application servers and conversions. He is a keen science-fiction fan in his spare time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>