Skip to content

166. Why Codea saves 2 images sometimes (and what @2x means)

September 25, 2014

If you save an image in Codea, you may find you actually have two copies of it, one of them with @2x added on the end of the name

pic.png

pic@2x.png

Here is the way it works, from one of the developers, Simeon:

"saveImage: This looks at the scale factor of the device you are using. If your device has a scale factor of “2”, then it will save an @2x version of the image at full resolution, then a regular version of the image at half resolution.

readImage (sprite, etc): Codea will look for an @2x version of the file if you are on a retina device. If not, it will load the regular version, but this may look blurry. What happened in your situation was you imported a file as retina, moved it to dropbox, and re-imported it by just downloading it. Codea no longer knew that it was supposed to be treated as a “retina” file and so it appeared to be twice as large (but probably blurry).

Retina switch during import: When you import photos via the sprite picker (i.e., from your photo library). There is a switch to toggle “retina”. When you activate it you should notice that the reported dimensions of the image are halved (this simply means that 2×2 pixels in the image will be used to represent 1×1 logical point on your retina sized device).

The purpose of this “switch” is to tell Codea whether you are importing an image you would like to be treated as retina. If the switch is off, Codea will import only the regular file at its original resolution. This means the image will look “blurry” on a retina iPad. If the switch is on, Codea will treat the image you are importing as the “@2x” version, meaning that the image will render at half the size its actual resolution dictates, but will look crisp on retina iPad. Codea will also save out a regular version of the image for non-retina use.”

It’s going to get worse with the higher pixel resolution of the iPhone 6, which may require a @3x copy of images!

Advertisements

From → Programming

One Comment

Trackbacks & Pingbacks

  1. Index of posts | coolcodea

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: