Forum Discussion

squirreltown's avatar
squirreltown
Roku Guru
11 years ago

BuhByteArray

I am trying to send the contents of a bitmap as as byte array to a server to be re-constituted as a jpeg. The php file creates a jpg from known good data and it's also receiving my bad data fine. so the problem seems to be the data format i'm outputting from the roku.

so we start here:
thispainting= screen.GetByteArray(0, 0, 5, 5)
strx=thispainting.ToBase64String()
? strx
SendPaintingPost(strx)
The code the Roku outputs looks like this:
$data ='q6ur/6urq/+rq6v/q6ur/6urq/+rq6v/q6ur/6urq/+rq6v/q6ur/6urq/+rq6v/q6ur/6urq/+rq6v/q6ur/6urq/+rq6v/q6ur/6urq/+rq6v/q6ur/6urq/+rq6v/q6ur/w==';
and the good sample code i have looks like this:
$data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'  //works
. 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
. 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
. '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
See how one of these things is not like the other?
This is the PHP thats making the jpeg.
$data = base64_decode($data);
$im = imagecreatefromstring($data);
Any ideas would be appreciated. Thanks