Encoding an image as a string

Is there any way I can encode an image as a string? 

I have tried using the following code, but the print statement does not give me a string nearly long enough for an image file:

[lua]path = system.pathForFile(“myfile.jpg”, system.ResourceDirectory)

file = io.open(path, “r”)

image = file:read("*a")

print(image)[/lua]

Well I don’t think you can really print binary data like that.  The best way is to get a base64 encoding routine.  There is one thats part of the mime package that can be required (local mime = require(“mime”). ) you can google around to find out the calls, its something like b64_encode() or something like that.

There are other base64 encoding libraries that you can find.

Well I don’t think you can really print binary data like that.  The best way is to get a base64 encoding routine.  There is one thats part of the mime package that can be required (local mime = require(“mime”). ) you can google around to find out the calls, its something like b64_encode() or something like that.

There are other base64 encoding libraries that you can find.

Is there any way I can encode an image as a string? 

I have tried using the following code, but the print statement does not give me a string nearly long enough for an image file:

[lua]path = system.pathForFile(“myfile.jpg”, system.ResourceDirectory)

file = io.open(path, “r”)

image = file:read("*a")

print(image)[/lua]

Sorry, are you trying to decode an existed image to bitmap and then re-encode bitmap to image? if yes, I think you can google source code for .NET imaging.

Is there any way I can encode an image as a string? 

I have tried using the following code, but the print statement does not give me a string nearly long enough for an image file:

[lua]path = system.pathForFile(“myfile.jpg”, system.ResourceDirectory)

file = io.open(path, “r”)

image = file:read("*a")

print(image)[/lua]

Sorry, are you trying to decode an existed image to bitmap and then re-encode bitmap to image? if yes, I think you can google source code for .NET imaging.