From 9af5eeb911a1c9d4faa173281a92dc3542ec2dd8 Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Mon, 25 Nov 2024 12:14:43 +0100 Subject: [PATCH] encodeToBytes / imageToBytes --- haxe/ui/backend/AssetsBase.hx | 4 ++++ haxe/ui/components/Image.hx | 5 +++++ haxe/ui/core/ImageDisplay.hx | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/haxe/ui/backend/AssetsBase.hx b/haxe/ui/backend/AssetsBase.hx index 12fb23d46..a76046b42 100644 --- a/haxe/ui/backend/AssetsBase.hx +++ b/haxe/ui/backend/AssetsBase.hx @@ -25,6 +25,10 @@ class AssetsBase { callback(null); } + public function imageToBytes(format:String, imageInfo:ImageInfo, callback:Bytes->Void) { + callback(null); + } + public function imageFromFile(filename:String, callback:ImageInfo->Void) { #if sys diff --git a/haxe/ui/components/Image.hx b/haxe/ui/components/Image.hx index 6da4b8245..802081c14 100644 --- a/haxe/ui/components/Image.hx +++ b/haxe/ui/components/Image.hx @@ -1,5 +1,6 @@ package haxe.ui.components; +import haxe.io.Bytes; import haxe.ui.behaviours.DataBehaviour; import haxe.ui.behaviours.DefaultBehaviour; import haxe.ui.behaviours.InvalidatingBehaviour; @@ -77,6 +78,10 @@ class Image extends Component { * The value to multiply the images size by when drawing the image to the screen. */ @:clonable @:behaviour(DefaultBehaviour, 1) public var imageScale:Float; + + public function encodeToBytes(format:String, callback:Bytes->Void) { + getImageDisplay().encodeToBytes(format, callback); + } } //*********************************************************************************************************** diff --git a/haxe/ui/core/ImageDisplay.hx b/haxe/ui/core/ImageDisplay.hx index b81e4bc7c..a346ed2d7 100644 --- a/haxe/ui/core/ImageDisplay.hx +++ b/haxe/ui/core/ImageDisplay.hx @@ -1,5 +1,6 @@ package haxe.ui.core; +import haxe.io.Bytes; import haxe.ui.assets.ImageInfo; import haxe.ui.backend.ImageDisplayImpl; import haxe.ui.geom.Rectangle; @@ -104,6 +105,10 @@ class ImageDisplay extends ImageDisplayImpl { return value; } + public function encodeToBytes(format:String, callback:Bytes->Void) { + ToolkitAssets.instance.imageToBytes(format, _imageInfo, callback); + } + public function isComponentInvalid(flag:String = InvalidationFlags.ALL):Bool { if (_isAllInvalid == true) { return true;