A way to loadimage from databuffer?

Monkey Forums/Monkey Programming/A way to loadimage from databuffer?

Landon(Posted 2015) [#1]
other than saving a giant pixel array and pasting them to a new image?


EdzUp(Posted 2015) [#2]
have a looky here http://www.monkey-x.com/Community/posts.php?topic=9549

I had the same idea :)


Richard Betson(Posted 2015) [#3]
I have to +1 this as a future feature in Monley-X. I need it. :)

Is there a packing mod available for Monkry-X? That would be target specific with file streams but possible.


nullterm(Posted 2015) [#4]
How about for sound data too? ; )

I've been itching to build a sound effect synthesizer, be great if I could upload direct from memory, without a temporary WAV file in between. And I'm not even sure how I'd do an HTML5 version not being able to save to file directly.


Nobuyuki(Posted 2015) [#5]
audio streams / buffers would be great for a number of reasons, not the least of which would be making it easier to add support for some better music formats :V


EdzUp(Posted 2015) [#6]
With access to byte data we could do anything with anything providing the loaders are there for images, audio, meshes etc (meshes for 3d as a future expansion) :)


Richard Betson(Posted 2015) [#7]
With access to byte data we could do

Also useful for networking especially UDP. Even though some targets do not like bytes it should be available as not having it is a problem for efficient online gaming.


k.o.g.(Posted 2015) [#8]
yes please mark! +1


Nobuyuki(Posted 2015) [#9]
With access to byte data we could do anything with anything providing the loaders are there for images, audio, meshes etc (meshes for 3d as a future expansion) :)


We can write our own loaders in Monkey already. But to access the OpenAL / AudioPool / whatever's stream requires externs...


marksibly(Posted 2015) [#10]
Are we talking about an image in 'png' etc format, or just raw image data?


EdzUp(Posted 2015) [#11]
I think raw image data then it can be edited before loading, the same for audio etc

Once its it, it will bring monkey closer to max in capabilities as we can manipulate data in the same way and will allow for things like colour changing, palette switching and audio sample editing :)


marksibly(Posted 2015) [#12]
How about something like this (untested) for images:

Function LoadImageWithData:Image( width:Int,height,Int,data:DataBuffer,dataOffset:Int )

	Local pixels:=New Int[width*height]
	For Local y:=0 Until height
		Local p:=y*width
		For Local x:=0 Until width
			pixels[p+x]=data.PeekInt( dataOffset+p+x )
		Next
	Next
	
	Local image:=CreateImage( width,height )
	image.WritePixels pixels,0,0,width,height
	
	Return image
End


You could cache a max sized pixels array for less memory thrashing.

I'll have a look at audio, but that's weird on some targets. Desktop targets should be doable though.


EdzUp(Posted 2015) [#13]
Yeah adding that as a official thing will add loads to the whole system providing its fast enough :)


k.o.g.(Posted 2015) [#14]
Hmm mark, with your example, the data must be saved in raw pixel format...


EdzUp(Posted 2015) [#15]
Hmm maybe a SaveBufferPNG, LoadBufferPNG etc


EdzUp(Posted 2015) [#16]
Thinking about it if we could have media loading as well it would be brilliant something like Max's incbin system or loading from buffers would be excellent so we could just read all the bytes of a png into a buffer then pass it to the LoadImage command and it would then load it from the buffer.


k.o.g.(Posted 2015) [#17]
@EdzUp
Absolut true.. Please mark, this would be an powerup for monkey!