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).
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) at x
,y
get
/setPixel()
: get/set pixel value (without alpha) at x
,y
get
/setByte()
: get/set byte value at i
clone()
: make a duplicate of the Pixels
instancefillRect()
: fill a rect area with pixel value (with alpha)convertTo()
: convert to specified PixelFormat
bytes
: access to the raw underlying bytes (in source-specific format)format
: change internal color mappingBitmapData
: 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
and AssetImage
: snow/luxePixels
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.
See the src folder for examples on how to use it, and please file an issue if you have problems or spot a bug.
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.
See LICENSE file.