Search Unity

How can I get a RGB24 format image via http?

Discussion in 'Scripting' started by umiringo73, Jul 15, 2020.

  1. umiringo73

    umiringo73

    Joined:
    Apr 18, 2017
    Posts:
    13
    Hi, guys

    In my game, I need download some images from remote server.
    In my script, I want those images be RGB24, which is smaller than ARGB32.
    I used UnityWebRequestTexture.GetTexture to fetch those images from server, but no matter "JPG" or "PNG" I used, when I get the texture via uwr.downloadHandler.texture, the fomat always be ARGB32.

    May I ask is there any way to get a RGB24 format texture from remote server?

    Thanks !
     
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    I believe that it's not a question of the server, but how you read and convert the file once it is downloaded. You can easily figure this out locally: open any png or jpg file, and then make sure that you correctly convert the resulting ARGB to RGB. Since 24 bits is a rarely used internal format, I think you should stick to 32 bits and simply ignore A, or overwrite it with a fixed value (probably 255).