- Home /
Why images in Android project are blurry?
I am writing comic viewer for Android. But there is one problem - images of the pages extracted from .cbr or .cbz files are blurry (the blur isn't big, but is noticeable) in the editor and in the phone when I am working on Android project. But when I change project type to desktop app, the images are sharp, why?
Here is how I extract images, I use SharpCompress library:
using System.IO;
using SharpCompress.Archive;
using UnityEngine;
class SharpCompressPage : IPage
{
private IArchiveEntry entry;
public SharpCompressPage(IArchiveEntry iae)
{
entry = iae;
}
public Texture2D PageTexture
{
get
{
if (_pageTexture == null)
{
_pageTexture = new Texture2D(1, 1);
_pageTexture.LoadImage(ExtractBytes());
}
return _pageTexture;
}
}
private Texture2D _pageTexture = null;
private byte[] ExtractBytes()
{
byte[] result;
MemoryStream output = null;
try
{
output = new MemoryStream();
entry.WriteTo(output);
output.Position = 0;
result = output.ToArray();
}
finally
{
if(output != null)
output.Dispose();
}
return result;
}
}
Answer by robert_d · Jun 02, 2012 at 07:36 PM
The problem was that I messed something in Project Quality Settings, resetting them repaired this problem
Answer by alpaca of zion · May 12, 2012 at 09:28 PM
Make sure your images are in powers of two.
http://unity3d.com/support/documentation/Manual/Textures.html#texturesizes
If the image isn't in a power of 2 it has to be resized for mobile GPUs which looses quality.
Answer by robert_d · May 12, 2012 at 10:21 PM
I can't control the size of the images, as I wrote those are comic book pages. How can I resize the texture?
You would need to resize them using a separate program like Photoshop or Paint.net. You may be running into a separate issue of the image being scaled for the screen. Getting a pixel perfect representation on an Android device may be impossible because of the differences in screen resolutions.
You can also use the Texture2D class to change the dimensions at runtime to make each image power-of-two. It has various Get/SetPixel functions that you can use to copy the original texture into a new POT texture.
Fighting the hardware is like fighting city hall - you'll never win. That assumes that the blurriness actual does come from non-POT textures, btw - it's is a good theory, but you need to verify that. It could also be that the engine picks a lower mipmap for whatever reason, and a myriad of other weird circumstances.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071415im_/https://answers.unity.com/themes/thub/images/avi.jpg)