Posts Tagged ‘Pixel’

Unity: Creating a texture from a XML file

Click here to read Unity: Creating a texture from a XML file

This Unity3D programming tutorial explains how to read a XML file from the Resources folder and use the pixel color data defined there to create a Texture2D object. Basically, it’s the same as creating a texture from an array, but this array will be obtained from a XML file, instead of being defined in the script.

Since even a small image uses a large amount of tags on the XML file, an example project is available for download at the end of the post. This sample project has a XML file with 4096 items, that creates a 64×64 texture.

(more…)

Unity: Scaling Pixel Art

Click here to read Unity: Scaling Pixel Art

This Unity post explains how to prepare images and set the Texture Importer settings to correctly render pixel art in Unity3D. So, this post covers how the different Texture Importer settings affects the pixel art textures in 3D models and in the game’s graphical user interface (GUI).

(more…)

Android: Disabling anti-aliasing for pixel art

Click here to read Android: Disabling anti-aliasing for pixel art

Android is great when it comes to displaying scaled pictures in applications and games since it tries to interpolate the pixels, making the resulting image look as good as possible. That works for almost every case, however, what about pixel art? This behavior isn’t good for that because, after scaling it, the resulting image will be “smoothed out”, invalidating the handcrafted pixel placement.

There are two options in this case: use an image with the correct size and never scale it, or try to disable anything that could be aliasing the image. This post is going to describe how to do the latter. As usual, an example project is available for download at the end of the post. (more…)

Android: How to return RGB values from an image file

Click here to read Android: How to return RGB values from an image file

Surprisingly, it’s quite easy to get the RGB value from an image file in Android. It’s certainly a lot easier than retrieving the pixel values from the Camera Preview. All that is required is to load the image file into a Bitmap object and them call the getPixel() method from the loaded bitmap.

It’s also possible to call this method to create an array of alpha and RGB values (ARGB) without calling the copyPixelsToBuffer() method, avoiding the use of buffers in Android which make things more complicated than it should be. As an example, the following code prints the color values of the pixels from the 4 corners of the image in LogCat and creates a RGBA array that stores each pixel color value:

(more…)