I needed a way to expire passwords in MVC 5. Unfortunately, most of the ways that I found were no longer relevant, so I cobbled together this [PasswordAuthorize] attribute to use instead of [Authorize].

using Microsoft.AspNet.Identity.Owin;
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.AspNet.Identity;

When displaying bitmap images in WPF, the system wants to display all images in 96 dpi. WPF is one of the few environments where the file’s DPI is used in calculating the display DPI. The images that I was working with had 500 dpi and the images were displaying blurry since they were being downsized to 72.

I haven’t found a way to override the output resolution of an image, so instead, I hack the resolution of the image when it is being read. Bytes 38/39 is the Horizontal DPI and 42/43 is the Vertical DPI.

To set it to 72 DPI, we must first realize that the resolution is in meters. Google’s online conversion app says that 3780 inches = 96 meters. So we set our resolution to 0x0EC4!

This takes the XML file and imports it into SQL as a XML database table. Doing this step separately from the rest of the steps will allow you to rerun the rest of the code without the time overhead. Also, doing this step here reduces the import time considerably.

The following code takes the XML database able and imports it into your Demographics table. The script only imports First, Last, and Photo. Adding the additional fields should be easy enough.

After I discovered that the only device that uses the 1x Universal image asset was the iPad 2, I went back and did a little bit more experimentation. If the 1x image is missing, then the iPad 2 will use the 2x image, scaled down properly for the device. Since it is a easy 50% reduction in the image size, there should be no degradation of the image quality.

The iPhone 6 also adjusted correctly. If the 3x image was missing, it upscaled the 2x image to fit in our screen size properly. Although functional, upsizing the image will cause a bit of blur to occur, so I’ll continue to support adding the 3x images.

So the only assets that need to be used in a Swift SpriteKit application are Universal images 2x & 3x. This let me reduce the overall file size significantly and made my job a whole lot easier.

I’ve been working on SpriteKit in XCode and have finally determined the best way to use the Universal asset files on each device.

In the fantastic game tutorials from Ray Wenderlich’s site recommends 2048 x 1536, with all background images set to the same size. But I wanted to make sure to optimize each of the images with the new Universal asset size collection.

This new asset size allows for 1x – 3x images and are the type that the default app uses when creating a Swift SpriteKit game.

For the asset sizes for your background images (in landscape mode)

1x: 1024 x 768

2x: 2048 x 1536

3x: 3072 x 2304

Most of the different platforms will use the 2x resolution. But the iPad 2 uses the 1x, and the iPhone 6 uses the 3x.