开发者

Fastest way to take a Screenshot in Flex 3?

开发者 https://www.devze.com 2022-12-07 23:46 出处:网络
What\'s the fastest way to get a screen capture in flex?I am curren开发者_运维知识库tly using: (I currently encode it to Base64 for upload to a webserver, but this is not necessarily required.All I wa

What's the fastest way to get a screen capture in flex? I am curren开发者_运维知识库tly using: (I currently encode it to Base64 for upload to a webserver, but this is not necessarily required. All I want is an image file to appear on the server).

  ImageSnapshot.defaultEncoder = JPEGEncoder;
  var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(<< flex component >>);
  var screenshotData:String = ImageSnapshot.encodeImageAsBase64(imageSnap);

It currently holds up the entire application for almost a second as it actually captures the image. The Base64 encoding happens essentially instantaneously.


Check out the fllowing URL, it is an open source JPEG encoder which is over 4 times faster than the one in corelibs.

http://www.bytearray.org/?p=775


Take a look at the answer to this: Thumbnails of components

I've used a very similar function and it was pretty fast, so hopefully you'll have no problem doing it that way.


The open-source JPEG encoder is not any faster than the mx.codecs one, unfortunately. However, the build in PNG encoder is about 6x as fast as the JPEG encoder. This solves the problem that I was currently having, i.e. too slow compression.

The "thumbnails of components" answer from CookieOfFortune solves another problem, that of taking the snapshot separately from compression, (snapshotting takes ~5ms for me, compression, now, <500ms).

0

精彩评论

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