@@ -920,13 +920,8 @@ class Project {
920
920
}
921
921
922
922
923
- public function getOrLoadImage (relPath : String ,x = - 1 , y = - 1 , w = - 1 , h = - 1 ) : Null <data. DataTypes . CachedImage > {
923
+ public function getOrLoadImage (relPath : String , x = - 1 , y = - 1 , w = - 1 , h = - 1 ) : Null <data. DataTypes . CachedImage > {
924
924
try {
925
- var thumbnailPath = " " ;
926
- if (x != - 1 && y != - 1 && w != - 1 && h != - 1 ) {
927
- thumbnailPath = relPath + " _" + Std .string (x ) + " _" + Std .string (y ) + " _" + Std .string (w ) + " _" + Std .string (h );
928
- }
929
-
930
925
if ( ! imageCache .exists (relPath ) ) {
931
926
// Load it from the disk
932
927
App .LOG .add (" cache" , ' Caching image $relPath ...' );
@@ -951,8 +946,14 @@ class Project {
951
946
pixels : pixels ,
952
947
tex : texture ,
953
948
});
954
- if (thumbnailPath != " " ) {
955
- var subPixels = pixels .sub (x , y , w , h );
949
+
950
+ // Store thumbnail to cache
951
+ var thumbnailPath = " " ;
952
+ if ( x != - 1 && y != - 1 && w != - 1 && h != - 1 )
953
+ thumbnailPath = relPath + " _" + Std .string (x ) + " _" + Std .string (y ) + " _" + Std .string (w ) + " _" + Std .string (h );
954
+
955
+ if ( thumbnailPath != " " ) {
956
+ var subPixels = pixels .sub (x , y , w , h );
956
957
var b64 = haxe.crypto. Base64 .encode ( subPixels .toPNG () );
957
958
imageCache .set ( thumbnailPath , {
958
959
fileName : dn. FilePath .extractFileWithExt (relPath ),
@@ -965,7 +966,7 @@ class Project {
965
966
relPath = thumbnailPath ;
966
967
}
967
968
}
968
-
969
+
969
970
return imageCache .get (relPath );
970
971
}
971
972
catch ( e : Dynamic ) {
0 commit comments