My netbook has a monitor with 10.1 inch length and 1024*600 solution. I think 1pt is about 1/72inch - is the following computation right?
Since the resolution is 1024*600, the
diagonal has about 1186.83 pixels,
thus 1 inch is about 1186.83/10.1 =
117.51 pixels, and thus 1pt is about 117.51/72 = 1.63 pixels, or 1 pixel is about 0.6127 pt.
Using this relationship, I've inserted an image into a LaTeX document, converting pixels to pt, and take the result as a parameter to includegraphics, but the figure in the resulting document is rather blurred.
Is the computation correct? if
not, how or
where am I wrong?
How can I insert an image into a LaTeX document
with precisely the same dimensions as the
original?
Updated:
I'm using pdflatex to compile the document and the image is a png file, and the reason why I do such a stupid computation is that with no width parameter set, the image shown in the document is larger than the actual size, and I can't work out why.
LaTeX is for creating paper documents. The units it uses refer to distance on the paper output, not on the screen. So if you ask for a distance of 72pts in LaTeX, you'll get 1 inch on your printout, but the distance you get on your screen depends on the zoom-level of your pdf or ps reader, which probably doesn't know how big your screen is.
If you simply want to get the raster grid of your image to fit to the screen grid, I'd say the best thing to do is get a higher-quality graphic if you can.
(PS there's a TeX stack exchange site where you could ask your question too...)
I don't know if it will make any difference, but TeX actually uses 72.27 points to the inch (as it predates PostScript, which set the standard 72 points to the inch).
Related
I have a bunch of auto-scanned slides using a slide scanner (Hamamatsu), which I can export from the NDPview software at different magnifications. So far, I have been zooming in to where I get the best resolution of my region on interest and add a scale bar for 1mm (as 1000 um) using the native scale bar option in the NDP view software. I then export the "view" from NDPview to TIFF. This TIFF is then imported into ImageJ (Fiji) where I set the scale using the scale bar I drew. This has been working well, but with over 500 images to do it's a bit of a pain.
Since the TIFF imports to ImageJ with inchxinch dimensions, I figured I can go to Image -> Properties and just change the unit of length to um. To test this, I selected an area to measure. I then compared this to my old method... and the values are completely different. Any idea why? 1 is the old method, 2 is the new method.
I made certain to "remove scale" in the scale bar window between each test. The whole image dimensions are different too:
If the images are all the same magnification and resolution, then as long as you know a measured distance (in pixels) and the physical distance (in microns or mm), you can set it using Analyze > Set Scale...
To do this in a macro you can use
run("Set Scale...", "distance=255 known=1 pixel=1 unit=micron");
where 255 is the distance in pixels for your known unit (1 micron). This can be applied to all TIFFs in a folder if you wrap that line in a loop operating on all TIFFs and save each resulting image.
I am displaying a grid of images (3rows x 3 columns) in collection view. Each image is a square and its width is determined to be 1/3 of collectionView's width. Collection view is pinned to left and right margin of the mainView.
I do not know what the image height and width will be at runtime, because of different screen sizes of various iPhones. For example each image will be 100x100 display pixels on 5S, but 130x130 on 6+. I was advised to supply images that exactly matches the size on screen. Bigger images often tend to become pixelate and too sharp when downsized. How does one tackle such problem?
The usual solution is to supply three versions, for single-, double-, and triple-resolution screens, and downsize in real time by redrawing with drawInRect into a graphics context when the image is first needed.
I do not know what the image height and width will be at runtime, because of different screen sizes of various iPhones. For example each image will be 100x100 display pixels on 5S, but 130x130 on 6+
Okay, so your first sentence is a lie. The second sentence proves that you do know what the size is to be on the different screen sizes. Clearly, if I tell you the name of a device, you can tell me what you think the image size should be. So, if you don't want to downscale a larger image at runtime because you don't like the resulting quality, simply supply actual images at the correct size and resolution for every device, and use the correct image on the actual device type you find yourself running on.
If your images are photos or raster type images created using a raster drawing tool, then somewhere you will have to scale the original to the sizes you want. You can either do this while running in iOS, or create sets up front using a tool which can give you better scaling results. Unfortunately, the only perfect image will be the original with everything else being a distortion of the truth.
For icons, the only accurate rendering solution is to use vector graphics. Tools like Adobe Illustrator will let you create images which you can scale to different sizes without losing clarity. Unfortunately this still leaves you generating images up front. You can script this generation using most tools and given you said your images were all square, then the total number needed is not huge. At most you need 3 for iPhone (4/5 are same width, 6 and 6+) and 2 for iPad (#1 for mini/ipad1 and #2 for retina).
Although iOS has no direct support I know of for vector image rendering, there are some 3rd party tools. http://www.paintcodeapp.com/ is an example which seems to let you import vector images or draw vector images and then generate image code to run in your app. This kind of tool would give you what you want as the images are now vector drawings drawn at the scale you choose at run time. $99 though.
There is also the SVGKit (https://github.com/SVGKit/SVGKit), but not sure how good/bad this is. It seems to let you simply load and render direct from SVG files. Might be worth trying.
So in summary, I think you either generate the relatively small subset up front using a tool you can control the output from, take the hit in iOS and let it scale the images or use a 3rd party vector to image rendering kit which would give you what you want.
When I add a model to my content and run the program I get the following error
Invalid texture. face 0 is sized 522X360 , but textures using DXT
compressed formats must be multiples of four
Can anyone can help me?
Thanks in Advance
The answer is exactly what it says: the dimensions of your texture image aren't multiples of four (should ideally be powers of two) - just resize your texture images.
Set the width and height both to 512 for best results. (Use an image editor like GIMP instead of MSPaint to get a clean scale that doesn't look weird)
We are currently working with a design who is supplying Retina images to us with odd dimensions i.e. 28 x 15 px which I believe is incorrect as when you divide it you get an odd number like 14 x 7.5 px.
This is a rule I have always worked on but the designer is not getting the point and I thought I should double check what the exact rules are.
I've had add look on the web but cannot seem to find any references on this so it would be great to hear what everyone thinks on this matter.
Thanks
Yes you can, but NOT recommend.
For example, if you have an #2x image with 28 x 15px , your normal image will be 14 x 8px.
If you look close into the normal image, the pixels are not aligned well.
It is always recommended to use even number of pixel in dimension.
The #2x image needs to be exactly twice the width and twice the height of the standard image, or the automatic loading of it won't happen - your app will load and pixel-double the non-Retina image.
The standard image file will as a matter of course be a whole number of pixels wide and high, so you'll need the #2x to be even in its dimensions.
Tell your designer to catch on ;)
It's not possible because in Xcode you design your application with classic resolution pictures, and you can't use a float for width or height. So, you will have a one pixel gap difference between your classic and retina design. Maybe the easiest way to solve your problem is to add a transparent line of pixels in your high resolution picture.
Sorry, this may or may not be a programming question directly, but I am trying to resize screenshots with Imagemagick and Gimp to include in a Beamer presentation, but it comes out even blurrier than the resizing done by LaTeX.
For instance, in Beamer I might have a command to rescale the image \includegraphics[width=.5\textwidth]{fig.png}. Using something like
\begin{frame}
\message{width = \the\textwidth}
\message{height = \the\textheight}
\end{frame}
I have gotten the \textwidth and \textheight parameters in points (345.69548, 261.92444). So I have a script (in Python) that sends a system call to Imagemagick:
'convert %s -resize %.6f# resized_%s' % (f,a,f)
where a is calculated as \textwidth*\textheight*0.5**2 and f is the file name. When I then go back into my Beamer presentation and include the resized figure, \includegraphics{resized_fig.png}, the size looks approximately correct but it's super-blurry. I also tried resizing in Gimp (using the GUI) but no luck either... help? Thanks...
If you want to preserve pixel sharpness, i.e. do not scale and interpolate pixels, but represent them as small squares, I suggest this approach:
Convert you PNG image to EPS/PDF with sam2p.
Include converted EPS or PDF in your document as usual. Every pixel will be just a small rectangular box, it will look crisp and sharp, and will scale without interpolation.
For example, let's assume we have a small raster image, that we want to show:
We can convert it to vector PDF with this command:
sam2p 10x10.png PDF: 10x10.pdf
Now as we have a vector version (where every pixel is a rectangular), we can include it in whatever LaTeX document and scale freely. All pixels will scale, but will not be interpolated.
For example,
\documentclass[12pt]{article}
\usepackage[papersize={4cm,4cm},margin=2pt]{geometry}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=0.8\linewidth]{10x10.pdf}
\end{document}
This will look like this:
Drawbacks:
PDF version of the image is likely to be several times bigger than its original PNG version.