'Bitmap'에 해당되는 글 1건

  1. 2008.07.30 비트맵 데이터 1
AS3.0 Cookbook/비트맵2008. 7. 30. 23:12

플래시 8버전 이후 벡터데이터 뿐만 아니라 비트맵 데이터도 다룰 수 있게 되었다..이는 더욱 발전하여 AS3에서도 제공을 하는데 포토샵만큼은 아니어도 필터링이라던가 레이어효과 등을 다룰수 있게 되었고 이를 통해 이미지 가공과 제작이 가능해 지게 된 것이다.
이러한 기능을 가지고 있는 클래스가 BitmapData클래스 이다. 이 클래스는 순수 데이터만을 관리하고 이를 디스플레이 리스트에 등록시킬수 있는 객체는 Bitmap이라는 클래스를 이용한다.
즉 이미지 픽셀정보는 BitmapData에 저장 관리하고 이를 화면에 보여줄 수 있는 몸통은 Bitmap인 것이다.

BitmapData( width , height , transparent , fillColor ) 클래스는 생성시 사용할 크기를 생성자에서 설정해야 한다. 현재로서는 생성자에서 반드시 2개의 값을 설정해야 하는데 폭과 높이를 설정하고 그 외 2개의 파라미터를 더 설정할 수있다.
transparent는 비트맵 데이터에 알파채널을 설정하는 Boolean값이다.
fillColor 는 32비트의 색상값을 가지는데 0xAARRGGBB로 앞에 투명도에 관한 AA값이 추가되어있다. 물론 투명한 데이터로 사용하려면 transparent는 true여야 한다.

생성한 BitmapData의 delegate변수에 draw라는 메서드를 사용하여 해당객체의 화면을 가져올 수 있다. 만약 Loader클래스안에 불러온 이미지인 경우 content로 접근하여도 Loader의 delegate로 접근하여도 데이터를 가져올 수있다. 이렇게 데이터를 취득하면 beginBitmapFill나 Bitmap클래스를 통해 화면에 붙이면 된다.

다음은 레나이미지를 불러온 Loader를 화면에 붙이고 BitmapData를 추출하여 화면에 붙여본 무비이다.

사용자 삽입 이미지

[원본 이미지]



왼쪽이 Loader클래스 이고 오른쪽이 비트맵 데이터를 Sprite에 담아 붙인것이다.

[ Public 속성 ]
height : int
[read-only] 비트맵 이미지의 높이(픽셀 단위)입니다.

rect : Rectangle
[read-only] 비트맵 이미지의 크기와 위치를 정의하는 사각형입니다.

transparent : Boolean
[read-only] 비트맵 이미지에서 픽셀별 투명도를 지원하는지 여부를 정의합니다.

width : int
[read-only] 비트맵 이미지의 폭(픽셀 단위)입니다.

[ Public 메서드 ]
BitmapData(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF)
지정된 폭과 높이로 BitmapData 객체를 만듭니다.

applyFilter(sourceBitmapData:BitmapData, sourceRect:Rectangle,
               destPoint:Point, filter:BitmapFilter):void

소스 이미지와 filter 객체를 사용하여 필터링된 이미지를 생성합니다.

clone():BitmapData
원본 인스턴스를 내포된 비트맵까지 똑같이 복제한 새 BitmapData 객체를 반환합니다.

colorTransform(rect:Rectangle, colorTransform:ColorTransform):void
ColorTransform 객체를 사용하여 비트맵 이미지의 지정된 영역에서 색상 값을 조정합니다.

compare(otherBitmapData:BitmapData):Object
두 BitmapData 객체를 비교합니다.

copyChannel(sourceBitmapData:BitmapData, sourceRect:Rectangle,
                  destPoint:Point, sourceChannel:uint, destChannel:uint):void

현재 BitmapData 객체나 다른 BitmapData 객체의 채널에서 현재 BitmapData 객체의 채널로 데이터를 이전합니다.

copyPixels(sourceBitmapData:BitmapData, sourceRect:Rectangle,
               destPoint:Point, alphaBitmapData:BitmapData = null, 
               alphaPoint:Point = null, mergeAlpha:Boolean = false):void

연장 효과나 회전 효과 또는 색상 효과 없이 이미지에서 픽셀을 조작할 수 있는 빠른 경로를 제공합니다.

dispose():void
BitmapData 객체를 저장하는 데 사용된 메모리를 비웁니다.

draw(source:IBitmapDrawable, matrix:Matrix = null,
       colorTransform:ColorTransform = null, blendMode:String = null,
       clipRect:Rectangle = null, smoothing:Boolean = false):void

Flash Player 벡터 렌더러를 사용하여 비트맵 이미지에 소스 표시 객체를 그립니다.

fillRect(rect:Rectangle, color:uint):void
사각형의 픽셀 영역을 지정된 ARGB 색상으로 채웁니다.

floodFill(x:int, y:int, color:uint):void
(x, y) 좌표에서 시작하는 이미지에서 색상 채우기 작업을 수행하여 특정 색상으로 채웁니다.

generateFilterRect(sourceRect:Rectangle, filter:BitmapFilter):Rectangle
지정된 BitmapData 객체와 소스 사각형 및 필터 객체를 기준으로 applyFilter() 메서드 호출이 적용될 대상 사각형을 결정합니다.

getColorBoundsRect(mask:uint, color:uint, findColor:Boolean = true):Rectangle
사각형 영역이 비트맵 이미지 내에서 지정된 색상의 모든 픽셀을 포함할지(findColor 매개 변수가 true로 설정된 경우) 또는 지정된 색상을 제외한 모든 픽셀을 포함할지(findColor 매개 변수가 false로 설정된 경우)를 결정합니다.

getPixel(x:int, y:int):uint
특정 지점(x, y)에서 BitmapData 객체의 RGB 픽셀 값을 나타내는 정수를 반환합니다.

getPixel32(x:int, y:int):uint
알파 채널 데이터와 RGB 데이터를 포함하는 ARGB 색상 값을 반환합니다.

getPixels(rect:Rectangle):ByteArray
픽셀 데이터의 사각형 영역에서 바이트 배열을 생성합니다.

hitTest(firstPoint:Point, firstAlphaThreshold:uint, secondObject:Object,  
          secondBitmapDataPoint:Point = null, secondAlphaThreshold:uint = 1):Boolean

하나의 비트맵 이미지와 특정한 점, 사각형 또는 다른 비트맵 이미지 간의 픽셀 수준 히트 감지를 수행합니다.

lock():void
이 BitmapData 객체를 변경할 때 BitmapData 객체를 참조하는 어떤 객체(예: Bitmap 객체)도 업데이트되지 않도록 이미지를 잠급니다.

merge(sourceBitmapData:BitmapData, sourceRect:Rectangle,
         destPoint:Point,
         redMultiplier:uint, greenMultiplier:uint, blueMultiplier:uint, alphaMultiplier:uint):void

소스 이미지에서 대상 이미지로 채널별 블렌드를 수행합니다.

noise(randomSeed:int, low:uint = 0, high:uint = 255, channelOptions:uint = 7,        
        grayScale:Boolean = false):void

임의의 노이즈를 나타내는 픽셀로 이미지를 채웁니다.

paletteMap(sourceBitmapData:BitmapData, sourceRect:Rectangle, destPoint:Point,         
                redArray:Array = null, greenArray:Array = null, blueArray:Array = null,
                alphaArray:Array = null):void

각 채널에 하나씩 최대 네 개까지의 색상 팔레트 데이터 배열이 있는 이미지에서 색상 채널 값을 다시 매핑합니다.

perlinNoise(baseX:Number, baseY:Number, numOctaves:uint, randomSeed:int,
                stitch:Boolean, fractalNoise:Boolean, channelOptions:uint = 7,
                grayScale:Boolean = false, offsets:Array = null):void

Perlin 노이즈 이미지를 생성합니다.

pixelDissolve(sourceBitmapData:BitmapData, sourceRect:Rectangle,
                  destPoint:Point, randomSeed:int = 0, numPixels:int = 0, fillColor:uint = 0):int

소스 이미지에서 대상 이미지로, 혹은 같은 이미지를 사용하여 픽셀 디졸브(dissolve)를 수행합니다.

scroll(x:int, y:int):void
특정 (x, y) 픽셀 양만큼 이미지를 스크롤합니다.

setPixel(x:int, y:int, color:uint):void
BitmapData 객체의 단일 픽셀을 설정합니다.

setPixel32(x:int, y:int, color:uint):void
BitmapData 객체의 단일 픽셀에 대한 색상 및 알파 투명도 값을 설정합니다.

setPixels(rect:Rectangle, inputByteArray:ByteArray):void
바이트 배열을 픽셀 데이터의 사각형 영역으로 변환합니다.

threshold(sourceBitmapData:BitmapData, sourceRect:Rectangle, destPoint:Point,
             operation:String, threshold:uint, color:uint = 0, mask:uint = 0xFFFFFFFF,
             copySource:Boolean = false):uint
이미지의 픽셀 값을 지정된 임계값 기준으로 테스트하고 그 테스트를 통과한 픽셀을 새 색상 값으로 설정합니다.

unlock(changeRect:Rectangle = null):void
이 BitmapData 객체를 변경할 때 BitmapData 객체를 참조하는 임의의 객체(예: Bitmap 객체)도 업데이트되도록 이미지 잠금을 해제합니다.

 

Posted by 버터백통