Awesome
hxPixels
An hxperimental (cross-target/cross-lib) Pixels abstract, in Haxe 3.1+
Simple interface to access/manipulate pixel values among different targets and libs, having a way to get/set individual pixels (or bytes), and be able to apply them back to the original source (taking care of framework-specific details under the hood).
API
For the supported libs the following methods are implemented (note that all color values are in ARGB format):
get
/setPixel32()
: get/set pixel value (with alpha) atx
,y
get
/setPixel()
: get/set pixel value (without alpha) atx
,y
get
/setByte()
: get/set byte value ati
clone()
: make a duplicate of thePixels
instancefillRect()
: fill a rect area with pixel value (with alpha)convertTo()
: convert to specifiedPixelFormat
bytes
: access to the raw underlying bytes (in source-specific format)format
: change internal color mapping
Supported classes/libs
BitmapData
: flash, openfl and nme (and flambe flash)Texture
: flambe (applyToFlambeTexture()
only for html - not flash -, due to limitations imposed by Stage3d)BufferedImage
: javaImageData
: plain jsTexture
andAssetImage
: snow/luxe- png, bmp and gif: format lib
Implementation
Pixels
is an abstract over haxe.io.Bytes
. It stores the raw bytes in the underlying bytes
var (in source-specific color format), providing an ARGB API over them.
Usage
See the src folder for examples on how to use it, and please file an issue if you have problems or spot a bug.
Warning
The code abstracting bitmaps from the above-mentioned libs is strictly coupled with their internal implementations, so it can easily break when they update. It may still be useful to work with pixels on a generic bitmap structure.
License (MIT)
See LICENSE file.