- Home /
Texture2D.LoadImage black pixel border
Hello,
I'm loading a texture in script:
Texture2D t = new Texture2D(2,2);
t.LoadImage(bytesFile.bytes);
Sprite s = Sprite.Create(t, new Rect(0,0,2048,2048),
new Vector2(0.5f,0), 200f);
GetComponent<SpriteRenderer>().sprite = s;
The image is a PNG saved in the resources folder with the filename: tree.png.bytes
The image is a tree and has some alpha on the edge of the tree. The problem is that there are now black pixels around the edge of the tree when displayed in unity. It might be because of the alpha, or possibly it could be related to the filtering mode as it doesn't do all the time in point filtering mode.
Anyone encountered this and fixed it? The only possible solution I can think of is to extend the colour beyond the alpha edge - but that will be a real problem for all the artwork that we have.
Importing the sprite in the normal way (assigning a PNG in the editor's inspector to the spriteRenderer) doesn't create black edging, so what is Unity doing there that we can't do through Texture2D.LoadImage ?
Your answer
![](https://koobas.hobune.stream/wayback/20220613185553im_/https://answers.unity.com/themes/thub/images/avi.jpg)