/hx-astcenc

Create ASTC format texture file. And OpenFl Target ASTCBitmapData.

Primary LanguageHaxeApache License 2.0Apache-2.0

hx-astcenc

Create ASTC format texture file.

About

Current only mac support now. About window, Need do haxe build-window.hxml to build window target.

Use

haxelib run hx-astcenc c -cl ./ChristGiftViewAtlas.png ./texture_zilb.astc 4x4 -exhaustive -pp-premultiply

Json Config

Use Json data create all ASTC file.

[
    {
        "zlib": true,
        "mode": "-cl",
        "defaultBlock": "6x6",
        "quality": "-exhaustive",
        "alphaPremultiply": true,
        "path": "Assets",
        "output": "Assets_astc",
        "igroneError": true
    },
    {
        "zlib": true,
        "mode": "-cl",
        "defaultBlock": "4x4",
        "quality": "-exhaustive",
        "alphaPremultiply": true,
        "path": "../../Assets2",
        "output": "Assets_astc",
        "igroneError": true
    }
]

Command:

haxelib run hx-astcenc file.json

OpenFL Target ASTC Texture Support

import openfl.display.ASTCBitmapData;

// Create from Bytes
ASTCBitmapData.fromBytes(bytes);
if (ASTCBitmapData.isSupportASTCConfig()) {
    trace("Support ASTC Config");
}
// Create from url or local path
ASTCBitmapData.loadFromFile("assets/4x4.astc").onComplete(data -> {
    var bitmap = new Bitmap(data);
    this.addChild(bitmap);
}).onError(err -> {
    trace("Load fail", err);
});
// Create from a BitmapData
ASTCBitmapData.fromBitmapData(bitmapData);
// Create from local path .png format, But it only IOS support.
ASTCBitmapData.loadFromPngFile("assets/4x4.png");
Display ASTCBitmapData
var bitmap = new Bitmap();
bitmap.bitmapData = ASTCBitmapData.fromBytes(bytes);
this.addChild(bitmap);

IOS Runtime ASTC Texture encode support

# You need to support IOS runtime install hx-ios-uikit
haxelib install hx-ios-uikit
OpenFL

Include to project.xml:<haxelib name="hx-ios-uikit"/>

Support API:
  • ASTCBitmapData.fromBitmapData(bitmapData);
  • ASTCBitmapData.loadFromPngFile("assets/4x4.png");