Hello
When a user uploads an image (png or jpg) on my game I convert it at runtime as per below to a sprite but it renders washed off, particularly noticeable for blacks and whites.
Original image:
Converted image:
I develop on URP but I’ve tested the pipeline and it’s not the problem - I manually assigned the image as Sprite (2D and UI) in the inspector to the UI and it looks fine.
This is the code I use:
private void FileWasOpenedEventHandler(byte[] data)
{
string path = UnityEditor.EditorUtility.OpenFilePanelWithFilters(title,localImagePath,filters);
byte[] fileContent = File.ReadAllBytes(path);
//bytes to texture2D
Texture2D thisTex2d = GetTexture2D(data, name);//placeholder rawimage component
//create sprite to attach to image component
Sprite thisSprite = Sprite.Create(thisTex2D, new Rect(0.0f, 0.0f, RGBTexture2d.width, RGBTexture2d.height), Vector2.one);
Hero.GetComponent<Image>().sprite = thisPropSprite;
}
public Texture2D GetTexture2D(byte[] data, string name)
{
var texture = new Texture2D(2, 2, TextureFormat.ARGB32, false, true);
texture.LoadImage(data);
texture.Apply();
return texture;
}
Can someone please shed some light as to what I may be doing wrong or considerations?
Thanks a bunch

