bitmapdata

Trying to capture stage area using BitmapData

旧街凉风 提交于 2019-11-29 11:09:13
I am trying to grab part of stage area using BitmapData and copyPixels method: bmd = new BitmapData(stage.stageWidth, stage.stageHeight); bmdRect = new BitmapData(320, 240); rectangle = new Rectangle(360, 20, 320, 240); bmdRect.copyPixels(bmd, rectangle, new Point()); bmd.draw(bmp); bmp = new Bitmap(bmdRect); var myEncoder:JPGEncoder = new JPGEncoder(100); var byteArray:ByteArray = myEncoder.encode(bmd); The result i get is an empty .jpg I m pretty sure that the error is in the Bitmap procedure and not the saving one... Dimitree Finally used this solution to copy part of the stage ( I copied

How do you load a bitmap file into a BitmapData object?

假如想象 提交于 2019-11-29 01:25:34
In Flash, the BitmapData object can be used to store bitmaps in RAM, you can later draw them to a MovieClip using the beginBitmapFill() method. How do you load an external bitmap file (.jpg) into a BitmapData object? Even AS3 code would be helpful. Cotton AS3 code to load a PNG and "get" its bitmapData var bitmapData:BitmapData; var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); loader.load(new URLRequest("../lib/img.png")); function onComplete (event:Event):void { bitmapData = Bitmap(LoaderInfo(event.target).content).bitmapData; } Refering

AS3:How to change a colored Bitmap's BitmapData to black and white?

淺唱寂寞╮ 提交于 2019-11-28 20:57:34
How can I change the bitmapdata of a coloured Bitmap to Black and White in AS3 ? I'm developing a simple image editor tool for a CMS in flash. People should be able to switch the colour of the uploaded Bitmap to black and white. I want the bitmapdata itself to change So I can write it to a ByteArray with Adobe's JPGEncoder Class afterwards. this would be the most elegant solution i presume (with source being you BitmapData ): const rc:Number = 1/3, gc:Number = 1/3, bc:Number = 1/3; source.applyFilter(source.bitmapData, source.bitmapData.rect, new Point(), new ColorMatrixFilter([rc, gc, bc, 0,

ByteArray to BitmapData AS3

那年仲夏 提交于 2019-11-28 13:36:21
I'm using com.adobe.images.PNGEncoder to encode bitmapData to a byteArray. Is there a way to convert the byteArray back to bitmapData NOT using a Loader? thanks. EDIT: the reason i don't want to use a Loader is it being Asynchronous, and I don't want to implement eventlisteners. The following is using the loader class but is synchronous. var loader:Loader = new Loader(); loader.loadBytes(byteArray); bmpData.draw(loader); Edit : Nevermind the loadBytes is asynchronous too, the documentation says you need to wait for the init event. What is the reason for not wanting event listeners? They are a

PixelFormat.Format32bppArgb seems to have wrong byte order

笑着哭i 提交于 2019-11-28 07:24:57
I try to get all byte values from a Bitmap(System.Drawing.Bitmap). Therefore I lock the bytes and copy them: public static byte[] GetPixels(Bitmap bitmap){ if(bitmap-PixelFormat.Equals(PixelFormat.Format32.bppArgb)){ var argbData = new byte[bitmap.Width*bitmap.Height*4]; var bd = bitmap.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); System.Runtime.InteropServices.Marshal.Copy(bd.Scan0, argbData, 0, bitmap.Width * bitmap.Height * 4); bitmap.UnlockBits(bd); } } I tested this Image with a very simple 2x2 PNG image with pixels (red, green,

Trying to capture stage area using BitmapData

早过忘川 提交于 2019-11-28 04:47:58
问题 I am trying to grab part of stage area using BitmapData and copyPixels method: bmd = new BitmapData(stage.stageWidth, stage.stageHeight); bmdRect = new BitmapData(320, 240); rectangle = new Rectangle(360, 20, 320, 240); bmdRect.copyPixels(bmd, rectangle, new Point()); bmd.draw(bmp); bmp = new Bitmap(bmdRect); var myEncoder:JPGEncoder = new JPGEncoder(100); var byteArray:ByteArray = myEncoder.encode(bmd); The result i get is an empty .jpg I m pretty sure that the error is in the Bitmap

What is the best way to resize a BitmapData object?

浪子不回头ぞ 提交于 2019-11-28 04:30:31
Say I have a BitmapData of 600x600 and I want to scale it down to 100x100. Iain This works: var scale:Number = 1.0/6.0; var matrix:Matrix = new Matrix(); matrix.scale(scale, scale); var smallBMD:BitmapData = new BitmapData(bigBMD.width * scale, bigBMD.height * scale, true, 0x000000); smallBMD.draw(bigBMD, matrix, null, null, null, true); var bitmap:Bitmap = new Bitmap(smallBMD, PixelSnapping.NEVER, true); Carlo public function drawScaled(obj:IBitmapDrawable, thumbWidth:Number, thumbHeight:Number):Bitmap { var m:Matrix = new Matrix(); m.scale(WIDTH / obj.width, HEIGHT / obj.height); var bmp

AS3:How to change a colored Bitmap's BitmapData to black and white?

允我心安 提交于 2019-11-27 13:20:38
问题 How can I change the bitmapdata of a coloured Bitmap to Black and White in AS3 ? I'm developing a simple image editor tool for a CMS in flash. People should be able to switch the colour of the uploaded Bitmap to black and white. I want the bitmapdata itself to change So I can write it to a ByteArray with Adobe's JPGEncoder Class afterwards. 回答1: this would be the most elegant solution i presume (with source being you BitmapData ): const rc:Number = 1/3, gc:Number = 1/3, bc:Number = 1/3;

How to detect if the area was 100% painted in as3

…衆ロ難τιáo~ 提交于 2019-11-27 08:05:19
问题 I´m making a game that simulates an industry of pan, and one of the process is Painting. What I want to do is to let the player paint the pan, but i don´t want it to be easy using FILL, i want that the player paint the pan with an brush and then the game detects if all the area was painted and let the player advance. For the painting i intend to use that library: http://www.nocircleno.com/graffiti/ But i have no idea how to detect if all the area was painted. Can someone show me some way of

How many ways to convert bitmap to string and vice-versa?

冷暖自知 提交于 2019-11-27 07:58:36
In my application i want to send bitmap image to the server in the form of string, i want to know how many ways are available to convert a bitmap to string. now i am using Base64 format for encoding and decoding, it takes little bit more memory. is there any other possibilities to do the same thing in different ways which takes less memory cosumptions. Now i am using this code. Resources r = ShowFullImage.this.getResources(); Bitmap bm = BitmapFactory.decodeResource(r, R.drawable.col); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos);