Android and iOS have a concept of a "density independent pixel" so your layouts look the same on devices with different densities and screen sizes.
Up until now I've written code to manually space elements using pixels (i.e. I want this button to be 10 pixels from the left side of the screen). This is great on a Curve, but when I load it up on a Bold the resolution is much higher, so 10 pixels is a much smaller physical space.
What are the best practices for multiple screen sizes on BlackBerry? Is there any easy way to define a density independent pixel? RIM seems to not offer much in terms of documentation or APIs to make this easy.
Points are density independent pixels (to a good degree of accuracy).
For BlackBerry, the most relevant class is net.rim.device.api.ui.Ui which defines a UNITS_pt constant (and a UNITS_px constant), a convertSize method to convert between points and pixels (since operations on Graphics take pixels instead of points).
A useful methodology for BlackBerry apps is to take everything in relation to your font sizes, which you define in points - there's a version of net.rim.device.api.ui.Font.derive that takes a units parameter and makes it easy to get fonts with a particular point size.
Of course, you can't take anything for granted - defining things in points will make things easier, but with BlackBerry you deal with lots of different pixel densities and aspect ratios so test thoroughly, at least on the simulators.
Related
The smallest QR-Codes to my knowledge are 25x25 blocks and thus if I want to detect the QR-Code in an image the part containing it needs to be at least 25x25 pixels.
Is there a smaller alternative (with a library implementation in python)?
The code should be able to encode at least 8 Bit of information.
No information encoding with different colors should be used, the code should only use black and white.
Assume that you have a square shaped and red coloured paper with a length of 5 centimetres.
I can detect it's (good enough) size (bounding box) in pixels on the image that camera takes.
I know the physical size.
On the other hand,
I do not know how to use the camera image's pixel size in the formula with the actual physical size of the paper. To do this, I would perhaps need a constant that will come from the specifications of the camera.
I believe mobile each iOS model has different calibration (and probably even the same models may be different than each other slightly?).
I think, if somehow I can get that information from the camera, I can map certain things and use the ratio to find the distance to a specific object.
Do you see any problems in the above ideas?
What would be the best way to get that constant from the camera? iOS Camera API? Announced specifications of the lens? Individually measuring and comparing size of the box on the image at the same camera distance on different iOS device models and saving those values per model type?
If all of these do not make any sense, what would you recommend me to look into? I appreciate the time taken by you to read this question and comment on it.
How does sceneKit deal with various screen sizes? Do geometries become bigger on larger screens? Does camera angle become bigger and wider? Do physics simulations look exactly the same on various phones? Thanks for help.
Do geometries become bigger on larger screens?
Nope, geometry size will be the same size, in the arbitrary unit you use (Meters by default). They will however appear bigger/smaller on screen but the size is the same (see next answer).
Does camera angle become bigger and wider?
Slightly. The FOV adapts on an axis to fit the aspect of the screen. You can try that out by running your app on the resizable simulator and see how it reacts.
Do physics simulations look exactly the same on various phones?
Yes and no. Overall, the simulation will feel the same (weight, speed, behaviour), but in details the randomness of the physics engine and the differences in hardware will make the simulations slightly different and random every time.
I have a game that is extremely procedural and because of this one of the textures in the games can end up covering the space of (113 x 10) to (682 x 768) on iPad retina. Furthermore it isn't always even in the same aspect ratio. Furthermore the unscaled texture has to be at an aspect ratio of about 2:11 making things awkward.
I can not figure out how Xcode perceives pdf vector files.
For example the first time I made my svg into a pdf and followed all the instructions for making a single vector slot it ended up being all pixelated/anti-aliased on some devices. And I know that .pdf vectors can be rasterized to any resolution without loosing quality! So I am pretty sure Xcode compiles vectors into bitmaps for the SKTexture. And as far as I can tell the amount of pixels that it rasterizes from the vector is not even variable on a device.
For example after that one I scaled up the svg to double the pts of its dimensions and exported it. Now on some devices the texture looked perfect yet on others it looked like a rasterized mess! And it didn't seem to happen because of one device resolution being bigger then the other.
So then I decided to scale the vector one more time so at this point it had 4x more points then the vector started as. Things worked wonderfully, until I tested on the iPhone 6 and instead of being beautiful the texture got blacked out, I am fairly certain this is because the texture was to big for Spritekit. There is no happy medium I can find.
My goal is to get this vector file looking great on every device regardless of how it is scaled.
I have looked around to see what SpriteKit uses for its pt to pixel conversions and I haven't found any numbers that check out. How I can make my texture work for this project? How does Spritekit decide how many pixels to rasterize a vector as when I make an SKTexture.
Edit:
Here are some hypothetical questions.
H1. How many points wide and tall would a pdf vector need to be for it to be able to be up to these dimensions on any device. width = width of device, height = height of device / 2. So basically if I had a vector I knew was going to occupy that space what should its dimensions (in points) be?
H2. Is the amount of pixels rasterized for every point directly proportionate to the amount of pixels on the display or is their more then just pixels on a screen?
Are there libraries, scripts or any techniques to increase image size in height and width....
or you must need to have a super good resolution image for it?.....
Bicubic interpolation is pretty much the best you're going to get when it comes to increasing image size while maintaining as much of the original detail as possible. It's not yet possible to work the actual magic that your question would require.
The Wikipedia link above is a pretty solid reference, but there was a question asked about how it works here on Stack Overflow: How does bicubic interpolation work?
This is the highest quality resampling algorithm that Photoshop (and other graphic software) offers. Generally, it's recommended that you use bicubic smoothing when you're increasing image size, and bicubic sharpening when you're reducing image size. Sharpening can produce an over-sharpened image when you are enlarging an image, so you need to be careful.
As far as libraries or scripts, it's difficult to recommend anything without knowing what language you're intending to do this in. But I can guarantee that there's an image processing library including this algorithm already around for any of the popular languages—I wouldn't advise reimplementing it yourself.
Increasing height & width of an image means one of two things:
i) You are increasing the physical size of the image (i.e. cm or inches), without touching its content.
ii) You are trying to increase the image pixel content (ie its resolution)
So:
(i) has to do with rendering. As the image physical size goes up, you are drawing larger pixels (the DPI goes down). Good if you want to look at the image from far away (sau on a really large screen). If look at it from up close, you are going to see mostly large dots.
(ii) Is just plainly impossible. Say your image is 100X100 pixels and you want to make 200x200. This means you start from 10,000 pixels, end up with 40,000... what are you going to put in the 30,000 new pixels? Whatever your answer, you are going to end up with 30,000 invented pixels and the image you get is going to be either fuzzier, or faker, and usually both. All the techniques that increase an image size use some sort of average among neighboring pixel values, which amounts to "fuzzier".
Cheers.