Load image from memory
Monkey Forums/Monkey Beginners/Load image from memory
| ||
Hi, I want to load my game resources, including graphics, from an encrypted binary container file. I just found that mojo LoadImage only supports loading from a file directly, so I am wondering what the correct way of initializing an image from memory is. Would I have to use CreateImage and WritePixels? I did not test this yet, but I have a feeling that this would be kind of slow? Are there any best practices in this regard (except not encrypting the assets)? Thanks |
| ||
There is a mod to support loading images from memory, but it requires a trans recompile iirc. You'd be going through a lot of trouble just to support this. It is possible to use CreateImage but then you'd probably want to use it to create an atlas at runtime because of the way texture rendering works (there's a performance hit every time you switch textures). My suggestion is probably to not bother, or only provide the most basic of munging routines (like glass block mosaics) to thwart casual rippers, or whoever else you're trying to thwart. You're not going to keep out anyone serious from peeking at the raw assets. |
| ||
Thanks for the info. I guess in this case I am going to use monkey only for some quick prototyping and then port everything over to either blitzmax or c#/XNA. I spent $15.000 on the art assets of my game and I am not going to have them just sit there in a folder for anyone to copy with one mouse click. I know that when I store them encrypted someone can still copy them by screen capture but at least then that person has to put some real effort into it in order to digest the animation frames and remove background pixels from foreground sprites and so on. Having my assets just sit there unprotected is like leaving my house door wide open and then saying "Well, if someone really wants to steal my stuff he will find a way to break into my house anyways and I should not worry about it in the first place because taking my stuff is illegal non the less." Is there a techincal reason to not allow loading images from memory in monkey? Something todo with restrictions of some build targets? Or is there still hope for it in the future (mojo/monkey 2..)? Thanks. |
| ||
Having my assets just sit there unprotected is like leaving my house door wide open and then saying "Well, if someone really wants to steal my stuff he will find a way to break into my house anyways and I should not worry about it in the first place because taking my stuff is illegal non the less." They don't have to copy by screen capture; Using an OpenGL or DirectX dumper they can grab your assets from memory unencrypted the same way your game does, they only have to wait for the game to unencrypt the graphics for them. Conversely, I could tell you that the illusion of security seems more important to your peace of mind towards protecting that 15k investment than the actual security you will be able to get, but that is all a matter of attitude and personal opinion. I gave you some suggestions on how to minimally thwart casual opportunists; if you don't think that's good enough then here is the thread I mentioned earlier, so do what you think you must: http://www.monkey-x.com/Community/posts.php?topic=9549 Alternatively, if you use Mojo2 you can munge your graphics and use a custom shader to fix them at runtime (or again blit to a surface before using). If I had to guess a reason that mojo doesn't allow loading images directly from memory, it's possibly due to target restrictions. Or, perhaps the need for the functionality is overstated and can be inserted anyway (at somewhat increased difficulty) for niche applications, as evidenced by the linked thread. |
| ||
Thanks for the link. I will definitly test this. Can i just modify the monkey source files and then I am good to go or do i need to recompile monkey somehow after making the changes to the soruce code? Thanks for your help. |
| ||
You could turn your images into RAW data (literally a pixel by pixel RGB dump), load it into memory and then use CreateImage and WritePixels to generate the final image. A lot of work, for something that can still be broken if someone really wants to. |