A way to loadimage from databuffer?
Monkey Forums/Monkey Programming/A way to loadimage from databuffer?
| ||
other than saving a giant pixel array and pasting them to a new image? |
| ||
have a looky here http://www.monkey-x.com/Community/posts.php?topic=9549 I had the same idea :) |
| ||
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. |
| ||
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. |
| ||
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 |
| ||
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) :) |
| ||
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. |
| ||
yes please mark! +1 |
| ||
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... |
| ||
Are we talking about an image in 'png' etc format, or just raw image data? |
| ||
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 :) |
| ||
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. |
| ||
Yeah adding that as a official thing will add loads to the whole system providing its fast enough :) |
| ||
Hmm mark, with your example, the data must be saved in raw pixel format... |
| ||
Hmm maybe a SaveBufferPNG, LoadBufferPNG etc |
| ||
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. |
| ||
@EdzUp Absolut true.. Please mark, this would be an powerup for monkey! |