Texture file is all alpha when resizing
Hi all , I'm creating a texture :
Texture2D takeScreenShotImage(string filePath)
{
Texture2D texture = null;
byte[] fileBytes;
if (File.Exists(filePath))
{
fileBytes = File.ReadAllBytes(filePath);
texture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
texture.LoadImage(fileBytes);
}
texture.Resize(texture.width / 2, texture.height / 2, TextureFormat.ARGB32, false);
Debug.Log (texture.width + " texture width" + texture.height + " texture height");
return texture;
}
and then turning it to sprite :
Sprite sp1 = Sprite.Create(texture1, new Rect(0, 0, texture1.width, texture1.height), new Vector2(0.5f, 0.5f), 100, 0, SpriteMeshType.FullRect);
Without the resizing line ("texture.resize"), its works great , with the resize line, my texture is looking like that :
The file size was changed , but it all alpha ! Why ? How can I resize the texture correctly ?
capture111.png
(38.8 kB)
Comment
Your answer
Follow this Question
Related Questions
How to load a folder of textures automatically to an array of Raw Images? 2 Answers
RawImage.texture to Texture2D 3 Answers
How can I reset the score counter? 0 Answers
Unity WebCamTexture looks squashed in RawImage 0 Answers
Better way to edit RawImage texture data?,Better way to edit a RawImage texture? 0 Answers