- Home /
Question by
j-washington2 · Jan 15, 2019 at 02:21 AM ·
c#texture
How to create an image from byte array and display it?
I am able to get the pixel information, but nothing ever displays on the screen. How do I actually get the image to display?
pcxFile = File.ReadAllBytes("Assets/5_ImageParser/bagit_icon.pcx");
int startPoint = 128;
int height = 152;
int width = 152;
target = new Texture2D(height, width);
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
timesDone ++;
pixels[x, y] = new Color(pcxFile[startPoint], pcxFile[startPoint+1], pcxFile[startPoint+2]);
startPoint += 4;
target.SetPixel(x, y, pixels[x, y]);
}
}
target.Apply();
target.EncodeToJPG();
Comment
Answer by Grish_tad · Jan 15, 2019 at 09:00 AM
Hi I think you need to do this
pcxFile = File.ReadAllBytes("Assets/5_ImageParser/bagit_icon.pcx");
int startPoint = 128;
int height = 152;
int width = 152;
target = new Texture2D(height, width);
target .LoadRawTextureData(pcxFile);
target.Apply();
target.EncodeToJPG();
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Texture showing in editor but not in game 0 Answers
GST Movie Texture - How to mute video?? 0 Answers
Problem when loading texture from folder 0 Answers