Images from Data-URI

Monkey Forums/Monkey Code/Images from Data-URI

Indiepath(Posted 2011) [#1]
I've made some little modifications to the mojo.graphics gxtkSurface class, specifically the load method to enable loading of an image from a Data-URI (basically a string representation of an image)

This is particularly useful in Flash and HTML5 when you may want to cache images client side or want to embed them within the application.

You can convert images to Data-URI's here : http://datauri.com/

Here's the changes (Flash and HTML only) - I don't particularly like the fact that I had to mess with core code. Extending classes with prototype is pretty simple with Javascript, shame AS3 doesn't see it that way :(

mojo.flash.as


mojo.html5.js


There is one small caveat with Flash - the image size is essentially ignored so you need to set your own handles...




wmaass(Posted 2011) [#2]
Indie,

Trying this out.

I see a loaded function in mojo.html5.js but no load method.

gxtkSurface.prototype.Loaded=function(){
	return this.image.complete;
}


EDIT: I am using v38 - I see that back in v31 there is a load method.


Indiepath(Posted 2011) [#3]
Hmmn, I've not used Monkey for a while - it's possible Mark made lots of changes... I'll have a look when I have time..