拍摄加载程序的快照
我正在尝试从网络摄像机获取图像并将其存储为位图。 我发现闪光灯不支持 MJPEG,因此我发现有人编写了一个类,可以与相机对话并在屏幕上输出。然后我对其进行了编辑,以便我可以随时请求当前图像并将其存储在 ByteArray 中。 我已经设法使用加载器类加载该 ByteArray 并将其放置在舞台上,但我不确定如何将其另存为位图? 谢谢
编辑:很抱歉要说清楚,我想将其存储到 FLA 中,以便我可以继续操作它
I'm attempting to take an image from a networked camera and store it as a bitmap.
I discovered that flash didn't support MJPEG so I found a class someone had written that could talk to the camera and output on the screen. Then I edited it so that I could request the current image at any time and store it in a ByteArray.
I've managed to load that ByteArray with a loader class and place it on the stage, but I'm not sure how to save that as a Bitmap?
Thanks
Edit: Sorry to be clear I want to store it inside to FLA so that I can carry on manipulating it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过“将其存储在 FLA 中”,如果您的意思是您想要从加载器中提取该位图图像,以便您可以访问位图数据等,那么我们就可以:
此处非常重要的信息:
如果您想要使用加载器对象加载图像后将图像保存到磁盘或其他任何地方,请注意,通过 LoaderInfo().bytes 访问二进制数据将在保存时提供损坏的数据。这是因为闪存虚拟机实际上稍微修改了二进制数据以在加载器对象中以图形方式显示它。如果您想加载并显示图像+能够保存它,您需要使用普通 URLLoader 对象加载原始二进制数据并将 URLLoader.data 的内容转换为字节数组,然后使用 Loader.loadBytes(bytes, LoaderContext ),同时将提供给第二个参数的 LoaderContext 对象内的allowLoadBytesCodeExecution 设置为 TRUE(仅当您从字节数组加载 swf 时)。希望这有帮助。
By "store it in the FLA", if you mean you want to extract that bitmap image from the Loader so you can access the bitmap data etc then here we go:
VERY IMPORTANT INFORMATION HERE:
If you want to save the image to the disk or anywhere else after loading it with the loader object, BEWARE that by accessing the binary data via LoaderInfo().bytes will give you CORRUPTED DATA WHEN YOU SAVE. This is because the flash VM actually slightly modifies the binary data to display it graphically within the loader object. If you want to load and show your image + be able to save it you need to load the raw binary data using a plain URLLoader object and casting the contents of URLLoader.data as a byte array, then use Loader.loadBytes(bytes, LoaderContext), while setting allowLoadBytesCodeExecution inside the LoaderContext object supplied to the second argument to TRUE (only if you are loading a swf from a bytearray). Hope this helps.
如果您的应用程序在线,您将需要一个服务器端脚本来创建和保存图像。
基本上代码可能如下:
在服务器端,php代码:
您可以检查阅读此内容以获取更多信息:
[编辑]
捕获位图数据:
If your app is online, you would need a server side script to create and save the image.
Basically the code could be as follows:
On the server side, php code:
You can check read this to get more info:
[EDIT]
Capturing the bitmapdata:
感谢您的所有回复,但这些似乎都不适用于我想做的事情,但我不能说这不是由于我的经验不足。这对我有用:
一开始我遇到了麻烦,因为我没有意识到加载器没有调度完整的事件,而是调度了 loaderinfo。
感谢大家的帮助。
Thanks for all the responses but none of these seemed to work for what I was trying to do, I can't say that isn't down to my inexperience though. This is what worked for me:
I was having trouble at first because I didn't realise the loader didn't dispatch the complete event but the loaderinfo.
Thanks for the help everyone.