Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Best way to compress non power of 2 image

Discussion in 'iOS and tvOS' started by tyoc213, Apr 6, 2016.

  1. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    Hi there, by some reasons I have a lot of images (histories) that I need to show on device, the images are jpeg 768x1024, the images are normally 40 to 120Kb. But when I use them on unity it shows 0.8 MiB or even 2.2 MiB instead of only some Kb.



    Also I would love to see the final package size of the things because the app size is going up (I think the major part are this images), but would love to know really where the space is going (I think the code are about less than 5Mb compiled).
     
    Last edited: Apr 6, 2016
  2. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    A mistake people commonly make I think - the size on the image file on the file system has no correlation with texture size once imported into Unity. When you import into Unity the texture will be stored in a format that is suitable for the current platform. On iOS the PVRTC format will give you the lowest memory usage (4 or 2 bits per pixel), but only power-of-2 textures are supported. Your 768x1024 will probably be in RGB24 format if it's 2.2Mb. If you pad your image out to 1024x1024 you'll be able to use PVRTC and will use less memory (0.5Mb for non-mipmapped at 4bpp).
     
  3. ChiuanWei

    ChiuanWei

    Joined:
    Jan 29, 2012
    Posts:
    131
    IN my solution,this big image should compress by TinyPNG tool.
    and use Texture2D.LoadImage(bytes) create the big texture. you can get a smallest size of builded and best visu
     
  4. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Note that at runtime your texture will be 32bpp so will use a lot of memory compared to PVRTC.
     
  5. ChiuanWei

    ChiuanWei

    Joined:
    Jan 29, 2012
    Posts:
    131
    dont worry about that, the biggest alpha png is limited amount at the same time. the memory is enough.