Hello everyone,
I have data of Images as Array Buffer base64 encoded. need to convert it in Texture2D. is there any way to do this?
JSON Editor Online is the original and most copied JSON Editor on the web. Use it to view, edit, format, repair, compare, query, transform, validate, and share your JSON data.
Here is sample data that i have, need to convert data[ ] in Texture2D so i can use it as Sprite or save on local device.
Adrian
February 18, 2021, 11:28am
2
base64 is a text-based encoding, what you’ve got looks more like bytes encoded as numbers? First you need to know what the data actually represents. What are the image dimensions? How is the pixel data encoded?
Depending on the data, you can use any of the SetPixel/SetPixelData/SetPixels methods on Texture2D to convert/feed the data into a texture.
there are jpeg image data, 1280 * 720 image resolution, data encoded using base64.
Adrian
February 18, 2021, 3:09pm
4
As I said, this is not base64. Base 64 encodes binary data into letters, numbers and +/=. This is json containing an array of bytes.
You want to deserialize the json and then pass the data byte array to ImageConversion.LoadImage , which will turn the jpeg data into a Texture2D.
1 Like
Adrian:
As I said, this is not base64. Base 64 encodes binary data into letters, numbers and +/=. This is json containing an array of bytes.
You want to deserialize the json and then pass the data byte array to ImageConversion.LoadImage , which will turn the jpeg data into a Texture2D.
Ohh, let me try this. may it resolve my issue.