Array buffer base64 to texture2D convert

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?

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.

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.

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

Ohh, let me try this. may it resolve my issue.