bright-gpu-74537
01/16/2022, 12:21 PMbright-gpu-74537
01/16/2022, 12:22 PMorange-van-60470
01/16/2022, 12:22 PMbright-gpu-74537
01/16/2022, 12:23 PMunsigned char* wxImage::GetData ( ) const
Returns the image data as an array.
This is most often used when doing direct image manipulation. The return value points to an array of characters in RGBRGBRGB... format in the top-to-bottom, left-to-right order, that is the first RGB triplet corresponds to the first pixel of the first row, the second one — to the second pixel of the first row and so on until the end of the first row, with second row following after it and so on.
You should not delete the returned pointer nor pass it to SetData().bright-gpu-74537
01/16/2022, 12:23 PMorange-van-60470
01/16/2022, 12:24 PMorange-van-60470
01/16/2022, 12:24 PMbright-gpu-74537
01/16/2022, 12:25 PMbright-gpu-74537
01/16/2022, 12:25 PMunsigned char* wxImage::GetAlpha ( ) const
Returns pointer to the array storing the alpha values for this image.
This pointer is NULL for the images without the alpha channel. If the image does have it, this pointer may be used to directly manipulate the alpha values which are stored as the RGB ones.orange-van-60470
01/16/2022, 12:29 PMbright-gpu-74537
01/16/2022, 1:14 PMorange-van-60470
01/16/2022, 1:47 PMHaxe
private var imageRef(get, null):Pointer<WxImage>;
private function get_imageRef():Pointer<WxImage> {
return _ref.reinterpret();
}
but there is no access route via hx.Image. Really there needs a property rgbArray and alphaArray and perhaps even rgbPixel and alphaPixel for individual access.
Haxe
public var rgbArray(get, set):Array<UInt8>;
inline function get_rgbArray():Array<UInt8> {
var p = this.imageRef.getData();
var l = Std.int( this.width() * this.height );
return [ for( i in 0...l ) p[ i ] ]; // or similar.
}
inline function set_rgbArray( v: Array<UInt8>):Array<UInt8> {
var p = this.imageRef.getData();
var l = Std.int( this.width() * this.height );
for( i in 0...l ) p[ i ] = v[ i ];
return v;
}
Still confused to understand how Alpha would relate to UInt8, would alphaArray be best defined as and just convert it within the function to be most compatible with normal use.
if you think it would work, I could pull the rgbArray but suspect to actually test it maybe extra.orange-van-60470
01/16/2022, 1:47 PMHaxe
public static function createImage( w: Int, h: Int, rgb: Null<Int> = null, alpha: Float = 1., isAlpha: Bool = false ){
var l = Std.int( w*h );
var hasAlpha = Bool( alpha != 1. ) || isAlpha;
// very unsure on this part or anything bytee!
var bytes = ( hasAlpha )? Bytes.alloc( l ): Bytes.alloc( l << 2 );
var stream = hx.widgets.MemoryInputStream( bytes );
var image = new Image( stream );
// initialize color
if( rgb != null ){
image.rgbArray = [ for( i in 0...l ) rgb ];
if( hasAlpha ) image.alphaArray = for( i in 0...l ) alpha );
}
return image;
}
Thoughts... I am not sure I have hxWidget setup on mac and setting up test maybe tricky but think this maybe required for image manipulation.orange-van-60470
01/16/2022, 1:49 PMbright-gpu-74537
01/16/2022, 1:49 PMbright-gpu-74537
01/16/2022, 1:49 PMorange-van-60470
01/16/2022, 1:49 PMorange-van-60470
01/16/2022, 1:50 PMorange-van-60470
01/16/2022, 1:50 PMbright-gpu-74537
01/16/2022, 1:50 PMorange-van-60470
01/16/2022, 1:50 PMbright-gpu-74537
01/16/2022, 1:51 PMorange-van-60470
01/16/2022, 1:52 PMorange-van-60470
01/16/2022, 1:52 PMorange-van-60470
01/16/2022, 1:52 PMbright-gpu-74537
01/16/2022, 1:53 PMvar p = @:privateAccess myImage.imageRef.ptr.getData()orange-van-60470
01/16/2022, 1:53 PMbright-gpu-74537
01/16/2022, 1:53 PMbright-gpu-74537
01/16/2022, 1:54 PM