Esempio n. 1
0
 public static string ToBase64(Texture2D texture, TextureEncoding encoding)
 {
     byte[] bytes;
     switch (encoding)
     {
         case TextureEncoding.JPG:
             bytes = texture.EncodeToJPG();
             break;
         default:
         case TextureEncoding.PNG:
             bytes = texture.EncodeToPNG();
             break;
     }
     return Convert.ToBase64String(bytes);
 }
Esempio n. 2
0
        public static byte[] Encode(this Texture2D texture, TextureEncoding encoding)
        {
            switch (encoding)
            {
            case TextureEncoding.PNG: return(texture.EncodeToPNG());

            case TextureEncoding.JPG: return(texture.EncodeToJPG());

            case TextureEncoding.TGA:
#if UNITY_2018_3_OR_NEWER
                return(texture.EncodeToTGA());
#else
                Debug.LogError("TGA encoding is available on Unity2018.3 or newer version, PNG encoding will be used");
                break;
#endif
            }
            return(texture.EncodeToPNG());
        }
        public static byte[] Encode(this Texture2D texture, TextureEncoding encoding)
        {
            switch (encoding)
            {
            case TextureEncoding.PNG: return(texture.EncodeToPNG());

            case TextureEncoding.JPG: return(texture.EncodeToJPG());

            case TextureEncoding.TGA:
#if UNITY_2018_3_OR_NEWER
                return(texture.EncodeToTGA());
#else
                Debug.LogWarning("TGA encoding is not supported on Unity2018.2 or earlier version, PNG encoding will be used");
                break;
#endif
            }
            return(texture.EncodeToPNG());
        }
Esempio n. 4
0
 public ImageAttachment(string name, Texture2D content, TextureEncoding encoding)
 {
     this.name     = name;
     this.image    = content;
     this.encoding = encoding;
 }