More iPhone 4 resolution scaling fun - ios4

So I have two images set to fill the screen - one at 320x480 (iPhone 3) and the other at 640x960 (iPhone 4).
img.png (320x480)
img#2x.png (640x960)
In Interface Builder, I have img.png set to fill the view (it shouldn't be filling the iPhone 4 view, though, right?), and when I build and run, it is notably too small.
So, when I do the opposite, setting img#2x.png as the img, a giant blue question mark fills the view. The project still builds and the image fills the screen, but is very pixelated as if it has been rescaled. It shouldn't have been rescaled, though, as it is the higher resolution.
Now using...
img.png (640x960)
img#2x.png (320x480)
I've also tried switching which file takes the #2x suffix, but that has not helped either. With the smaller file taking the #2x suffix, and setting the image view to img.png, it shows up way larger than the view canvas, but way too small when on the phone. With the smaller file still having the #2x suffix, I tried switching the view to the new img#2x.png and once again got the oversized, pixelated question mark in IB and a low res full-screen image when deployed to the phone.
I also made sure that my view size was set to 640x960 in the size inspector. What else should I be doing?

Don't use #2x when specifying the image name. Just use the base name of the image (so in your case, just img). iOS will do the magic behind the scenes to use the 2x version if it's on a retina display and the regular version otherwise (including when you use a xib to lay out your interface).
The displayed dimensions of the image will always be the dimensions of the non-2x image. The retina display just displays 2 pixels for every 1 which is why the scale is 2.0 and you have to double the dimensions of the original image. So your view size in IB should be 320x480.
Edit
If IB is being finicky, especially in Xcode 4, just try deleting the xib and starting over. Sometimes it gets a bit corrupted and doesn't know what to do with itself. I've had to do this on one or two occasions, and it seems that it worked for the OP as well.

Related

How Can I Fix Inconsistent Text Downscaling with a Rich Text Label In Godot?

I have a rich text label that works fine under a resolution of 1920x1080. However, when scaled down to the resolution on my laptop, which has a 1366x768 resolution, the text on said label becomes janky and malformed.
Some lines are cut off at the top or the bottom, and others are squished (as you can see in the image at lines 3, 6, and 13).
I'm using Godot v3.5.1 and the text font is Noto Sans Regular from here
I tried enabling mipmaps, using the filter, disabling anti aliasing, disabling font oversampling and enabling GPU pixel snap under Project Settings > Rendering > 2D > Snapping. And out of all of those, only the pixel snap setting worked. Completely fixes the issue and the text is rendered properly.
However, this completely breaks an animation of a spinning circle that plays at basically all times during the actual gameplay. It becomes stuttered and shakes instead of the normally smooth animation it has otherwise. I realize this may possibly be fixed by using SVG instead of PNG sprites, but I feel like that's not an ideal solution in case other sprites get added. Especially since my game will also allow community members to add their own sprites for their own game play.
So is there any way to fix the text without breaking the animations, or make it so that the animations don't break with pixel snap enabled?

Cbuilder XE3 scales (expands) form when edited in RAD IDE

I have some applications, but not all, that "magically" scale up forms by a factor of 1.23 when I open the forms in the RAD IDE. For example, a form width of 947 pixels suddenly jumps to 1166 pixels. It is suspiciously-close to a pixel ratio of 120/96 (a ratio of 1.25), but the scaling is consistently closer to 1.23 (as judged by larger integer ratios derived from, for example, the form width and height).
I can look at the .dfm file and see the original numbers, whereas in the IDE, the values have been altered (e.g. height and width expanded, control positions adjusted, and font sizes increased).
I know that scaling and dpi is a minefield, but I've not (to my knowledge) changed any related settings.
For both the affect and non-affected projects, forms have the Scaled property set to "true" and the PixelsPerInch property is set to 96. My development machine has its screen resolution set to 100%. This is the setup that is supposed to avoid these issues.
I have searched through the project and IDE configuration files in a fruitless effort to find out what might be different about a project that has this issue, vs one that does not.
The affected (and unaffected) projects are all ones that have been in development for years - it is only in the last week that I have observed this behaviour. To my knowledge (I am sole developer), I have not made any code/configuration changes that relate to scaling, dpi, etc.
Does anyone have any idea what might be happening?
Although I am using CBuilder XE3, I've tagged this question with Delphi XE3 as well since I'm thinking that this is a RAD Studio issue.
EDIT 1: I've also noticed that for each modified control, the IDE throws in the following additional lines (i.e. in addition to modifying Top, Left, Width, Height, and Font.Height):
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
and for TImages, it also adds
ExplicitWidth = <nnn>
ExplicitHeight = <nnn>
EDIT 2: Curiously, when the IDE scales the form it does not flag the form as modified - i.e. the form appears unmodified until a "real" change is made (for example, repositioning a control). If the form is opened a second time after saving with the modified scale, no further scaling occurs - it seems to be a one-time effect, but there does not seem to be a "unasked-for-scaling-accomplished" flag in any configuration file :)

Accommodating Smaller Screen Sizes

I have an application that looks fantastic on a Galaxy 4 which is 360dp wide. When I run the application on a Gingerbread device that is 320dp wide, the text overlaps adjacent buttons.
I tried creating a separate layout for the Gingerbread devices entitled layout-sw320dp and another for the Galaxy entitled layout-sw360dp. Unfortunately, both devices defaulted to the sw320dp layout. I also tried layout-normal, but had the same experience.
Let me know if you have any suggestions for smaller android screens when it comes to fonts.
To solve the problem, just set up a font style for each font size. Use a dimension to set the font size. Then set multiple dimension files by including these files in different directories based on the font size. For instance values-sw300dp would be for files greater than 300dp in width. Your standard values file would apply for other layouts.
Hope this helps.

IE10 does not scale background SVG correctly when zoomed (on Surface/Windows 8 phone)

Does anyone know if there is a workaround for this? Internet Explorer 10 and Window phone 8 are not able to correctly scale background SVG images when a user zooms. Looks like IE rasterizes the SVG on load.
Here is an example: The first image is the SVG as a background image. Zoom in on a MS Surface or Windows 8 phone and you'll see it blurs horribly.
The second image is the same SVG as an img tag. Zoom this on a Surface or Windows 8 mobile phone and it scales as you would expect (nice and clean).
Is there any property that can be added to make IE10 behave? Or is it merely a case of waiting for the folks at Redmond to fix it?
The problem is that IE, and other browsers such as Firefox rasterise the SVG before displaying it, so it will become blocky when zoomed.
The easiest way to fix this is to make the SVG file larger than is needed. For example double the size, or more if the user is likely to zoom in further. You can then resize the SVG image with CSS to display it at the correct size. This way the image will be naturally larger, so wont become blocky, unless you zoom in even further. At default zoom level the image is scaled down rather than up, which browsers usually handle better.
Edit: You can find further info on this issue under the “SVG and CSS Backgrounds” heading at http://dbushell.com/2012/03/11/svg-all-fun-and-games/

how to make a Sprite

ive used an online srpite service http://spritegen.website-performance.org/ but i want to know how to make them by myself.
How can i save an image that it should be so small but when used on my web site it comes out normal size?
Sprites aren't about making the image itself small, it's about decreasing filesize by packing several images into one.
Take a look at Yahoo's icon sprite. Notice that they have all their section icons stacked vertically in one large image. They then use CSS to position the background to only show a small window of the sprite image, thus giving you just the icon.
In the end, it's up to you how you arrange your sprite. Check out the bottom of Amazon's sprite.
Either way, hopefully that helps gives you a better idea of the concept of sprites.
From the very site you link:
CSS sprites are a way to reduce the
number of HTTP requests made for image
resources referenced by your site.
Images are combined into one larger
image at defined X and Y coorindates.
Having assigned this generated image
to relevant page elements the
background-position CSS property can
then be used to shift the visible area
to the required component image.
So there is nothing magical involved: you simply need to pack all your pictures into a single giant image with your favourite graphics tool and insert them as CSS background. Just look at this CSS sprite by Google:

Resources