Just a collection of BitmapData utility methods. Just for cross-platform stuff, since not all methods are implemented across all targets.
Static methods
staticaddSpacesAndBorders(bitmapData:BitmapData, ?frameSize:FlxPoint, ?spacing:FlxPoint, ?border:FlxPoint, ?region:FlxRect):BitmapData
Gets image without spaces between tiles and generates new one with spaces and adds borders around them.
Parameters:
bitmapData | original image without spaces between tiles. |
---|---|
frameSize | the size of tile in spritesheet. |
spacing | spaces between tiles to add. |
border | how many times to copy border of tiles. |
region | region of image to use as a source graphics for spritesheet. Default value is null, which means that whole image will be used. |
Returns:
Image for spritesheet with inserted spaces between tiles.
staticcompare(Bitmap1:BitmapData, Bitmap2:BitmapData):Dynamic
Compares two BitmapData objects.
Parameters:
Bitmap1 | The source BitmapData object to compare with. |
---|---|
Bitmap2 | The BitmapData object to compare with the source BitmapData object. |
Returns:
If the two BitmapData objects have the same dimensions (width and height), the method returns a new BitmapData object that has the difference between the two objects. If the BitmapData objects are equivalent, the method returns the number 0. If the widths of the BitmapData objects are not equal, the method returns the number -3. If the heights of the BitmapData objects are not equal, the method returns the number -4.
staticcopyBorderPixels(bitmapData:BitmapData, frameWidth:Int, frameHeight:Int, spaceX:Int, spaceY:Int, borderX:Int, borderY:Int, horizontalFrames:Int, verticalFrames:Int):BitmapData
Helper method for copying border pixels around tiles. It modifies provided image, and assumes that there are spaces between tile images already.
Parameters:
bitmapData | image with spaces between tiles to fill with border pixels |
---|---|
frameWidth | tile width |
frameHeight | tile height |
spaceX | horizontal spacing between tiles |
spaceY | vertical spacing between tiles |
borderX | how many times to copy border of tiles on horizontal axis. |
borderY | how many times to copy border of tiles on vertical axis. |
horizontalFrames | how many columns of tiles on provided image. |
verticalFrames | how many rows of tiles on provided image. |
Returns:
Modified spritesheet with copied pixels around tile images.
4.1.0
.staticgenerateRotations(brush:BitmapData, rotations:Int = 16, antiAliasing:Bool = false, autoBuffer:Bool = false):BitmapData
Generates BitmapData with prerotated brush stamped on it
Parameters:
brush | The image you want to rotate and stamp. |
---|---|
rotations | The number of rotation frames the final sprite should have. For small sprites this can be quite a large number (360 even) without any problems. |
antiAliasing | Whether to use high quality rotations when creating the graphic. Default is false. |
autoBuffer | Whether to automatically increase the image size to accommodate rotated corners. Default is false. Will create frames that are 150% larger on each axis than the original frame or graphic. |
Returns:
Created BitmapData with stamped prerotations on it.
staticinlinegetMemorySize(bitmapData:BitmapData):Float
Returns the amount of bytes a bitmapData occupies in memory.
staticmerge(sourceBitmapData:BitmapData, sourceRect:Rectangle, destBitmapData:BitmapData, destPoint:Point, redMultiplier:Int, greenMultiplier:Int, blueMultiplier:Int, alphaMultiplier:Int):Void
Performs per-channel blending from a source image to a destination image.
Parameters:
sourceBitmapData | The input bitmap image to use. The source image can be a different BitmapData object, or it can refer to the current BitmapData object. |
---|---|
sourceRect | A rectangle that defines the area of the source image to use as input. |
destBitmapData | The output bitmap image to use. |
destPoint | The point within the destination image (the current BitmapData instance) that corresponds to the upper-left corner of the source rectangle. |
redMultiplier | A hexadecimal uint value by which to multiply the red channel value. |
greenMultiplier | A hexadecimal uint value by which to multiply the green channel value. |
blueMultiplier | A hexadecimal uint value by which to multiply the blue channel value. |
alphaMultiplier | A hexadecimal uint value by which to multiply the alpha transparency value. |
staticreplaceColor(bitmapData:BitmapData, color:FlxColor, newColor:FlxColor, fetchPositions:Bool = false, ?rect:FlxRect):Array<FlxPoint>
Replaces all BitmapData's pixels with specified color with newColor pixels. WARNING: very expensive (especially on big graphics) as it iterates over every single pixel.
Parameters:
bitmapData | BitmapData to change |
---|---|
color | Color to replace |
newColor | New color |
fetchPositions | Whether we need to store positions of pixels which colors were replaced |
rect | area to apply color replacement. Optional, uses whole image area if the rect is null |
Returns:
Array replaced pixels positions