Graphics, Figures & TablesViewport clarification

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
cbkschroeder
Posts: 55
Joined: Sun Nov 09, 2008 7:48 pm

Viewport clarification

Post by cbkschroeder »

Hello,

Thanks for reading in inquiry.

I'm using the \includegraphics command and the viewport argument. I'm trying to include a 128 pixel x 128 pixel .png file. In the current circumstance, I wish to see all of this graphic, though in other cases I may wish to only see select pieces - which I will select using viewport - of a graphic. The following line correctly includes the file:

Code: Select all

\includegraphics[width=3in,clip]{img125.png}
What I've stumbled upon happens with the following line:

Code: Select all

\includegraphics[viewport=0 0 128 128,width=3in,clip]{img125.png}
Only these viewport arguments do not crop the image; running from 0 to 127 or 1 to 128 chops of pixels. Put another way, only running from 0 to 128 in the second line of code produces results identical to the first. Obviously, however, running the cropping index from 0 to 128 represents 129 pixels, though my image is, again, only 128x128. I have examined my image in both xnview (which says the leftmost pixel is pixel 0 and the rightmost is 127) and gimp (similar 1 and 128), so I know my image is 128x128. Why do I need to input this extra pixel of width in the viewport command? What (likely obvious) thing am I missing?

Any thoughts you could contribute would be appreciated by me.

Thanks,

Christian

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply