Skip to content

Commit

Permalink
encodeToBytes / imageToBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Nov 25, 2024
1 parent bc9f0e7 commit 9af5eeb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions haxe/ui/backend/AssetsBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions haxe/ui/components/Image.hx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
}

//***********************************************************************************************************
Expand Down
5 changes: 5 additions & 0 deletions haxe/ui/core/ImageDisplay.hx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9af5eeb

Please sign in to comment.