Share Posted September 22, 2015 I have an RTMP stream that I need to take a screenshot of. I got a security error using bitmapData.draw() since it was coming from AWS S3 so I found a workaround that allows me to take a screenshot of the video: var bitmap = new Bitmap(); var graphicsData : Vector.<IGraphicsData>; graphicsData = container.graphics.readGraphicsData(); //-- container is a sprite that holds my video element bitmap.bitmapData = GraphicsBitmapFill(graphicsData[0]).bitmapData; var image:ByteArray = new JPGEncoder(85).encode(bitmap.bitmapData); At this point, I send the ByteArray to PHP, create a JPG out of the ByteArray and save it to the server. That all works great. The issue is I apply filters real-time to the container sprite which alters the look of the video like brightness, contrast, saturation etc, but when saving to the server, the saved image doesn't contain the filters I had applied. I tried reapplying the filters to bitmap, graphicsData and bitmap.bitmapData before sending it to the server, but nothing has worked yet. How can I either retain the filters applied or re-apply the filters to the above code? Here is how I initially apply the filters: private function applyEffects(effects:Array):void { currentEffects = effects; var props:Object = {}; for (var i:String in effects) { props[effects[i].effect] = effects[i].amount; } TweenLite.to(container,0,{colorMatrixFilter:props}); } props object could look something like: {contrast:0.5,saturation:1} Link to comment Share on other sites More sharing options...
Share Posted September 22, 2015 Sorry, I really don't know. Haven't touched AS3 bitmaps or filter code in quite awhile. These forums are very focused on the GreenSock API and I think you will get much better help on a general AS3 forum or Stack Overflow. Link to comment Share on other sites More sharing options...
Author Share Posted September 22, 2015 Unfortunately, I have already posted to SO and it hasn't received much attention so far: http://stackoverflow.com/questions/32705844/my-bytearray-isnt-retaining-filters I thought of posting here because I am using TweenLite to apply the filters and thought maybe Jack would have some insight Link to comment Share on other sites More sharing options...
Share Posted September 22, 2015 Sorry, I'm in the same boat as Carl. We really try to stay focused on GreenSock-specific questions here. One random thought - maybe try wrapping your Sprite in another Sprite and capture that one instead. 1 Link to comment Share on other sites More sharing options...
Author Share Posted September 22, 2015 Thanks for the suggestion Jack. I tried doing what you said, but it still did not work. I thought more about your suggestion and came up with a working solution! var graphicsData:Vector.<IGraphicsData>; graphicsData = container.graphics.readGraphicsData(); var origBitmap:Bitmap = new Bitmap(); origBitmap.bitmapData = GraphicsBitmapFill(graphicsData[0]).bitmapData; //-- at this point I have a screenshot of the video var props:Object = {}; for (var i:String in currentEffects) { props[currentEffects[i].effect] = currentEffects[i].amount; } TweenLite.to(origBitmap,0,{colorMatrixFilter:props}); //-- at this point I've reapplied the effects. //-- originally, sending bitmap.bitmapData to the encoder didn't retain the filters so I went 1 step further //-- create a new bitmapData and draw the reapplied filter'd bitmap var filteredBitmapData:BitmapData = new BitmapData(640,360); var filteredBitmap:Bitmap = new Bitmap(filteredBitmapData); filteredBitmapData.draw(origBitmap); //-- encode the new bitmap data var image:ByteArray = new JPGEncoder(85).encode(filteredBitmapData); //-- filteredBitmapData is now filtered and I can send this to the server 2 Link to comment Share on other sites More sharing options...
Share Posted September 22, 2015 Great! Thanks for sharing. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now