Search Unity

RenderTexture memory size when converted to PNG

Discussion in 'Editor & General Support' started by raghadalghonaim, Jun 23, 2020.

  1. raghadalghonaim

    raghadalghonaim

    Joined:
    Apr 22, 2020
    Posts:
    54
    I'm using unity to capture 128x128 png images from the scene. What I noticed is that the captured images are having different sizes. Some of them are too small while others are too large.

    From my understanding that png images are affected by the resolution, am I missing something here? why are the sizes vary? is there a way to make it the same?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    What do you mean by size? First you said they are all 128x128, then you said they have different sizes. Which is it?
     
  3. raghadalghonaim

    raghadalghonaim

    Joined:
    Apr 22, 2020
    Posts:
    54
    Sorry if that wasn't clear, I mean their size in memory when exported using EncodeToPNG. (in bytes)
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    PNG data sizes will vary because PNG is a compressed image format. Depending on the characteristics of the image, that compression will be more or less effective, resulting in more or less space savings, e.g. different file sizes.
     
  5. raghadalghonaim

    raghadalghonaim

    Joined:
    Apr 22, 2020
    Posts:
    54

    Thanks!!

    is there a way to avoid it? like by encoding to different format?
     
  6. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
  7. raghadalghonaim

    raghadalghonaim

    Joined:
    Apr 22, 2020
    Posts:
    54