UnityTextureOps icon indicating copy to clipboard operation
UnityTextureOps copied to clipboard

Texture is not loading properly while passing the format

Open ragavendranbala opened this issue 1 year ago • 2 comments

public Texture2D tex;

var tex1 = TextureOps.Scale(tex, tex.width / 2, tex.height / 2, tex.format); yield return null; originalImage.sprite = Sprite.Create(tex1, new Rect(0, 0, tex1.width, tex1.height), new Vector2(0.5f, 0.5f), 100f, 0, SpriteMeshType.FullRect);

I tried to scale down the texture by using the above method and tried to apply to a image. But It always show some lines instead of original one

Image used forest

converted Image image

Error : Unable to retrieve image reference UnityEngine.Texture2D:ReadPixels (UnityEngine.Rect,int,int,bool) TextureOps:Scale (UnityEngine.Texture,int,int,UnityEngine.TextureFormat,TextureOps/Options) (at ./Library/PackageCache/com.yasirkula.textureops@66623dae8d/Plugins/TextureOps/TextureOps.cs:467) ImageConvert/<Start>d__6:MoveNext () (at Assets/ImageConvert.cs:35) UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

Import settings image

Unity 2022.3.7

Adding aspect ratio fill/scale will also a good option for this asset!

ragavendranbala avatar Aug 15 '23 08:08 ragavendranbala

I'd like to know if this is Compression related. Can you set it to None for testing purposes?

PS. Does TextureOps.ScaleFill satisfy the aspect ratio fill/scale you've mentioned?

yasirkula avatar Aug 15 '23 16:08 yasirkula

If I didn't pass the format, it is working good

Haven't tested the fill API

ragavendranbala avatar Aug 16 '23 06:08 ragavendranbala