Creating video snapshot with BitmapData and…

This evening I’d like to share with you a little trick on how to create a simple snapshot of a Flash video.
It’s easy, isn’t it?! NO, it’s not so easy!!!

if you have your Video object on the stage that is bigger than real video dimensions and you try to make a snapshot you’ll have something like this:

So I think to create an utility class that solve this problem; I start to think how to get only image pixels and not the white one.
I add transparent pixels instead of white pixels and I check on image which is the first transparent pixel I can find in my image.
I use those coordinates to make a new bitmapData with only image pixels and I draw again and scale it with video width and height.
This is final result:

You can download source code from this link.
When I’ll have enough time, I’d like to optimize it maybe with bitwise operations, but meanwhile you can start from this scratch!

Bye bye


Published by

luca mezzalira

Being associated with the industry since 2004, I have lent my expertise predominantly in the solution architecture field. I have gained accolades for revolutionising the scalability of frontend architectures with micro-frontends, from increasing the efficiency of workflows, to delivering quality in products. My colleagues know me as an excellent communicator who believes in using an interactive approach for understanding and solving problems of varied scopes. I helped DAZN becoming a global streaming platform in just 5 years, now as Principal Architect at AWS, I'm helping our customers in the media and entertainment space to deliver cost-effective and scalable cloud solutions. Moreover, I'm sharing with the community the best practices to develop cloud-native architectures solving technical and organizational challenges. My core industry knowledge has been instrumental in resolving complex architectural and integration challenges. Working within the scopes of a plethora of technical roles such as tech lead, solutions architect and CTO, I have developed a precise understanding of various technicalities which has helped me in maximizing value of my company and products in my current leadership roles.

4 thoughts on “Creating video snapshot with BitmapData and…”

  1. If you know the original video dimensions, can you just snap those pixels and then draw the bitmapdata with an upscaled transform matrix?

    1. It’s a good point of view, I think that it works, I’ll try it and then I update the post.
      Thank Aran for share your idea with me, I really appreciate a lot 😀

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s