Skip to content

Commit 12e0455

Browse files
committed
Minor fixes (#1008)
1 parent 8d71668 commit 12e0455

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/electron.renderer/data/Project.hx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -920,13 +920,8 @@ class Project {
920920
}
921921

922922

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> {
924924
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-
930925
if( !imageCache.exists(relPath) ) {
931926
// Load it from the disk
932927
App.LOG.add("cache", 'Caching image $relPath...');
@@ -951,8 +946,14 @@ class Project {
951946
pixels: pixels,
952947
tex: texture,
953948
});
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);
956957
var b64 = haxe.crypto.Base64.encode( subPixels.toPNG() );
957958
imageCache.set( thumbnailPath, {
958959
fileName: dn.FilePath.extractFileWithExt(relPath),
@@ -965,7 +966,7 @@ class Project {
965966
relPath = thumbnailPath;
966967
}
967968
}
968-
969+
969970
return imageCache.get(relPath);
970971
}
971972
catch( e:Dynamic ) {

0 commit comments

Comments
 (0)