Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion flixel/system/FlxAssets.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import haxe.Json;
import haxe.xml.Access;
import openfl.Assets;
import openfl.utils.ByteArray;
import haxe.io.Path;
#if hxWebP
import webp.WebP;
#end

using StringTools;

Expand Down Expand Up @@ -260,7 +264,17 @@ class FlxAssets
public static inline function getBitmapData(id:String):BitmapData
{
if (Assets.exists(id))
return Assets.getBitmapData(id, false);
{
switch (Path.extension(id))
{
#if hxWebP
case 'webp':
return WebP.getBitmapDataFromBytes(Assets.getBytes(id)); // WebP.getBitmapData(id); is broken as of rn
#end
default:
return Assets.getBitmapData(id, false);
}
}
FlxG.log.error('Could not find a BitmapData asset with ID \'$id\'.');
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions include.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<haxelib name="openfl" unless="create" />
<haxelib name="hscript" unless="create || coverage2" optional="true" />

<haxelib name="hxWebP" optional="true" if="cpp || web"/>

<haxeflag name="--macro" value="flixel.system.macros.FlxDefines.run()" />

<section if="setup">
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/FlxAssert.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FlxAssert
&& areNearHelper(expected.y, actual.y, margin)
&& areNearHelper(expected.width, actual.width, margin)
&& areNearHelper(expected.height, actual.height, margin);

if (areNear)
Assert.assertionCount++;
else
Expand Down