bitmapdata

Applying blur filter to BitmapData

≯℡__Kan透↙ 提交于 2019-12-24 01:19:51
问题 Here's the code I am using to blur an image using BitmapData. The function is called on a Slider_changeHandler(event:Event):void event and the value of the slider is passed to the function as blurvalue. The problem is the function works but seems to be cummalative (if that's the correct word!), that is, suppose I slide it to the maximum and after that try to reduce the blur by sliding it back towards the front the blur still keeps increasing. How do I make it to work so when I will slide it

AS3 - Scale BitmapData

半城伤御伤魂 提交于 2019-12-23 09:49:47
问题 I'd like to scale a BitmapData to different sizes such as 200, 400, 600 and 800. What is a good way to do that? 回答1: You can't directly scale a BitmapData but you can make a scaled clone of it. Here is a quick example for scaling a BitmapData : package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.geom.Matrix; import mx.core.BitmapAsset; public class Test extends Sprite { [Embed(source="test.jpg")] private var Image:Class; public

How do I set a certain color to be transparent?

懵懂的女人 提交于 2019-12-23 03:26:08
问题 I'm using copyPixels to copy a parts of a larger Bitmap to smaller Bitmaps to use for individual MovieClips. However, around there is still some extra space white space and corners around the Bitmaps' edges left over. How do I set the color white in the Bitmap to be transparent so I won't see these unsightly edges? 回答1: You can use the BitmapData.threshold method. This code creates a BitmapData with a red square on a blue background, then uses the threshold method to make the red pixels

Sending ByteArray through as3 to PHP

送分小仙女□ 提交于 2019-12-13 04:55:29
问题 The BLOB field (pic) is turning out as 0 Bytes when trying to send ByteArray through as3 to PHP, so i assume the PHP script or the HTTP_RAW_POST_DATA isn't working. I think the Flash part is working, I have set a trace() to see if the bitmapdata is coming through and it seems it is, so I'm assuming its my php side. I'll post both parts of the code in hope someone here can fix it for me. Thanks. AS3 private function export():void { var bmd:BitmapData = new BitmapData(600, 290); bmd.draw(board)

Get a ByteArray from BitmapData in AS3

若如初见. 提交于 2019-12-13 04:45:21
问题 I would like to get a ByteArray from a BitmapData in AS3. I tried the following: var ba:ByteArray = myBitmapData.getPixels(0,0); It didn't work and I got this error ArgumentError: Error #1063: Argument count mismatch on flash.display::BitmapData/getPixels(). Expected 1, got 2. : 回答1: As Adobe said about BitmapData.getPixels : " Generates a byte array from a rectangular region of pixel data... ", so your parameter should be a Rectangle object. Take this example from Adobe.com : import flash

Comparing two BitmapData in ActionScript 3

烂漫一生 提交于 2019-12-12 03:23:36
问题 I'd like to know if there's anyway I can compare two BitmapData and get a "similarity percentage" (knowing how look-alike they are). I've done a bit of research and came across bitmapData.compare(otherBmd), but that only returns if they differ in size, or pixel, and not how much they differ. The point of this was to compare some Bmd obtained through a camera with a library image (so this is what I got so far): import flash.display.Bitmap; import flash.display.BitmapData; var img1:BitmapData =

BitmapData lock and unlock not working on android

此生再无相见时 提交于 2019-12-12 01:03:42
问题 The following code will erase a bitmap (brush akk droplet) from another bitmap (akka The code works great on PC and pretty ok performacewise. When i test it on more android devices, it doesn't work. No matter if is a high end device or a slower one. I've made some tests and found out the problem is lock() and unlock() functions from BitmapData. It simply doesn't update the image on device, only once. I've tried to remove them, but the then it lags alot. Also the performace drop is noticeable

How can I work with 1-bit and 4-bit images?

断了今生、忘了曾经 提交于 2019-12-11 14:53:52
问题 BitmapLocker class is intended for fast read/write of pixels in a Bitmap image file. But, Color GetPixel(int x, int y) and void SetPixel(int x, int y, Color c) cannot handle 1-bit and 4-bit images. public class BitmapLocker : IDisposable { //private properties Bitmap _bitmap = null; BitmapData _bitmapData = null; private byte[] _imageData = null; //public properties public bool IsLocked { get; set; } public IntPtr IntegerPointer { get; private set; } public int Width { get { if (IsLocked ==

Converting 24bpp to 8bpp - How can I fix this method so it returns a Bitmap with positive stride

元气小坏坏 提交于 2019-12-11 14:04:24
问题 I'm looking for a fast way to convert a Bitmap from 24bpp to 8bpp. I found a solution at this site Programmer » 1bpp in C#. It works, but the resulting Bitmap stride is negative! How can I fix the stride of the image? I've already tried this: Bitmap.Clone: stride still negative new Bitmap(b0): Creates a 32bpp image... ¬¬ EDIT: Save to a file, read it back and make a deep copy (Marshal.Copy or memcopy) of pixel data to detach the Bitmap from the file works.. But is "kind of" ugly... The code

AS3 - Find the most abundant pixel colour in BitmapData

元气小坏坏 提交于 2019-12-11 05:56:07
问题 Basically, I want to get the most common ARGB value that appears in a BitmapData . That is, I want to know which exact pixel colour is the most abundant in the image. I tried going through every pixel of the image and counting whenever a colour that already exists comes up, but that's way too slow, even with relatively small images. Does anybody know a faster method for this, maybe using the BitmapData.histogram() function or something? Ideally the process should be near instantaneous for