开发者

AS3 Bitmap storage

Hey, I need some advice so I'll explain what I'm trying to accomplish, how I think I want to do it and I hope someone can tell me if this a good idea or if I'm over-thinking it.

What I want to do it take a bitmap image from an as3/Flash IDE project and save it on a database server. This is a permanent installation that has 4 flash apps running and they all link开发者_运维知识库 to a MySQL database.

I found this tutorial that shows me how to serialize bitmapdata and then store it on the local computer but what I'd instead like to do is store that compressed bitmap data in the database in a blob field. Is this a good idea? If not can I send it to php to store the bitmapdata into a folder on the server and store a reference to it in the database? I can convert it to jpeg to email from the server at the moment but I need a copy that is still in bitmap format to be picked up by a 5th app and printed out. If I do store it as a file should I then use PHP to grab the file and stream the bytes back to Flash? Is there a better way of doing it?

Any tutorials or code snippets would be greatly appreciated. If not just a push towards the right subject to read up on.

Thanks guys. Ben


There has been great debate over the years about whether or not to store images in the DB itself. I think most of that is over and the consensus is rapidly heading to 'store it on the filesystem with a link'... you can scale that up easily, but scaling up a DB is much much harder. All of that's fine by me, because I always thought the DB guys were nuts.

For transfer over the wire, I'd suggest PNGing the image, depending on what kind of image it is (PNG is both compressed and lossless).

How to store the file will depend on how your app is structured. You can probably get by with large folders full of MD5 generated filenames to prevent collision. You probably don't want to store anything serially, as that makes it easy for somebody to come in and just take the entire set. You can also store autogenerated filenames in user id'd folders... that's up to you.

Unless high security is needed, you can just keep them all on a Web server and shoot back a URL, which makes the files readily available. If you need to keep them private, then you can stream them back with PHP. Make sure you use Etags or some other caching mechanism.


Added:
Btw, the PHP/MySql part is actually pretty easy. All in all, a seasoned pro could do it in a couple of days -- week tops.

And here's the AS3 PNG encoder, which is part of AS3CoreLib


i answered a similar question about saving bitmap into jpg file using as3 and php

Save image from Flash, send it to PHP and return a URL string to Flash

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜