压缩图片bug解决
This commit is contained in:
parent
3083224ee6
commit
9570334e25
@ -54,7 +54,7 @@ public static class App
|
|||||||
public static IDictionary<string, Texture> TextureCache = new Dictionary<string, Texture>();
|
public static IDictionary<string, Texture> TextureCache = new Dictionary<string, Texture>();
|
||||||
public static Texture CurrentUserHeadTexture;
|
public static Texture CurrentUserHeadTexture;
|
||||||
public static RouteResult routeResult;//骑行记录向骑行场景传值
|
public static RouteResult routeResult;//骑行记录向骑行场景传值
|
||||||
public static Texture DefaultRotateTexture;
|
public static Texture DefaultRotateTexture { get; set; }
|
||||||
//全局用 输入框或者下拉框修改标志位
|
//全局用 输入框或者下拉框修改标志位
|
||||||
public static bool isChanged { get; set; }
|
public static bool isChanged { get; set; }
|
||||||
public static string notifyContent { get; internal set; }
|
public static string notifyContent { get; internal set; }
|
||||||
|
|||||||
@ -611,7 +611,7 @@ public class LoginController : BaseScene
|
|||||||
//}
|
//}
|
||||||
Debug.Log(JsonConvert.SerializeObject(locationInfo));
|
Debug.Log(JsonConvert.SerializeObject(locationInfo));
|
||||||
var i = await ConfigHelper.thirdPartApi.GetMapImage(locationInfo);
|
var i = await ConfigHelper.thirdPartApi.GetMapImage(locationInfo);
|
||||||
var t = new Texture2D(4, 4,TextureFormat.DXT5, false);
|
var t = new Texture2D(2, 2, TextureFormat.DXT5, false);
|
||||||
if (t.LoadImage(Utils.StreamToBytes(i)))
|
if (t.LoadImage(Utils.StreamToBytes(i)))
|
||||||
{
|
{
|
||||||
Debug.Log("成功");
|
Debug.Log("成功");
|
||||||
|
|||||||
@ -432,10 +432,29 @@ namespace Assets.Scripts
|
|||||||
}
|
}
|
||||||
/*获取最顶层对象*/
|
/*获取最顶层对象*/
|
||||||
/*Texture相关*/
|
/*Texture相关*/
|
||||||
|
public static Texture2D DeCompress(this Texture2D source)
|
||||||
|
{
|
||||||
|
RenderTexture renderTex = RenderTexture.GetTemporary(
|
||||||
|
source.width,
|
||||||
|
source.height,
|
||||||
|
0,
|
||||||
|
RenderTextureFormat.Default,
|
||||||
|
RenderTextureReadWrite.Linear);
|
||||||
|
|
||||||
|
Graphics.Blit(source, renderTex);
|
||||||
|
RenderTexture previous = RenderTexture.active;
|
||||||
|
RenderTexture.active = renderTex;
|
||||||
|
Texture2D readableText = new Texture2D(source.width, source.height);
|
||||||
|
readableText.ReadPixels(new Rect(0, 0, renderTex.width, renderTex.height), 0, 0);
|
||||||
|
readableText.Apply();
|
||||||
|
RenderTexture.active = previous;
|
||||||
|
RenderTexture.ReleaseTemporary(renderTex);
|
||||||
|
return readableText;
|
||||||
|
}
|
||||||
public static void WriteTextureToPlayerPrefs(string tag, Texture2D tex)
|
public static void WriteTextureToPlayerPrefs(string tag, Texture2D tex)
|
||||||
{
|
{
|
||||||
// if texture is png otherwise you can use tex.EncodeToJPG().
|
// if texture is png otherwise you can use tex.EncodeToJPG().
|
||||||
byte[] texByte = tex.EncodeToPNG();
|
byte[] texByte = tex.DeCompress().EncodeToJPG();
|
||||||
|
|
||||||
// convert byte array to base64 string
|
// convert byte array to base64 string
|
||||||
string base64Tex = System.Convert.ToBase64String(texByte);
|
string base64Tex = System.Convert.ToBase64String(texByte);
|
||||||
|
|||||||
@ -6,8 +6,8 @@ EditorBuildSettings:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/Scenes/Login-Mobile.unity
|
path: Assets/Scenes/Login.unity
|
||||||
guid: 4be878da00cf764499988cf403faf94d
|
guid: 6dce3e17997730b4492f91dd8fede429
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/Scenes/MainScene.unity
|
path: Assets/Scenes/MainScene.unity
|
||||||
guid: ab586a3c1bacd4a48a55178eb06fe0cc
|
guid: ab586a3c1bacd4a48a55178eb06fe0cc
|
||||||
|
|||||||
@ -180,7 +180,7 @@ PlayerSettings:
|
|||||||
Android: com.ZhiXingPai.PowerFunUnity
|
Android: com.ZhiXingPai.PowerFunUnity
|
||||||
buildNumber:
|
buildNumber:
|
||||||
iPhone: 2.0.7.0
|
iPhone: 2.0.7.0
|
||||||
AndroidBundleVersionCode: 9
|
AndroidBundleVersionCode: 10
|
||||||
AndroidMinSdkVersion: 24
|
AndroidMinSdkVersion: 24
|
||||||
AndroidTargetSdkVersion: 30
|
AndroidTargetSdkVersion: 30
|
||||||
AndroidPreferredInstallLocation: 1
|
AndroidPreferredInstallLocation: 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user