Skip to content

Commit 017ef51

Browse files
committed
Calculate MD5 if it's null
1 parent d0a7c28 commit 017ef51

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/scratch/ScratchCostume.as

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public class ScratchCostume {
257257

258258
private static var shapeDict:Object = {};
259259
public function getShape():Shape {
260+
if (!baseLayerMD5) prepareToSave();
260261
var id:String = baseLayerMD5;
261262
if(id && textLayerMD5) id += textLayerMD5;
262263
else if(textLayerMD5) id = textLayerMD5;
@@ -372,6 +373,7 @@ public class ScratchCostume {
372373
H[i++] = R[j]; //right part;
373374

374375
R.length = L.length = 0;
376+
image.dispose();
375377

376378
//trace('found bounds: '+new Rectangle(minX, minY, maxX - minX, maxY - minY));
377379
return H;
@@ -392,16 +394,16 @@ public class ScratchCostume {
392394
dup.rotationCenterY = rotationCenterY;
393395

394396
dup.baseLayerBitmap = baseLayerBitmap;
395-
dup.baseLayerMD5 = baseLayerMD5;
396397
dup.baseLayerData = baseLayerData;
398+
dup.baseLayerMD5 = baseLayerMD5;
397399

398400
dup.svgRoot = svgRoot;
399401
dup.svgWidth = svgWidth;
400402
dup.svgHeight = svgHeight;
401403

402404
dup.textLayerBitmap = textLayerBitmap;
403-
dup.textLayerMD5 = textLayerMD5;
404405
dup.textLayerData = textLayerData;
406+
dup.textLayerMD5 = textLayerMD5;
405407

406408
dup.text = text;
407409
dup.textRect = textRect;
@@ -481,9 +483,10 @@ public class ScratchCostume {
481483
var centerX:Number = r.x + (r.width / 2);
482484
var centerY:Number = r.y + (r.height / 2);
483485
var bm:BitmapData = new BitmapData(w, h, true, 0x00FFFFFF); // transparent fill color
484-
var scale:Number = Math.min(1, w / r.width, h / r.height);
486+
var scale:Number = Math.min(w / r.width, h / r.height);
487+
if (bitmap) scale = Math.min(1, scale);
485488
var m:Matrix = new Matrix();
486-
if (scale < 1) m.scale(scale, scale); // scale down a large image
489+
if (scale < 1 || !bitmap) m.scale(scale, scale); // don't scale up bitmaps
487490
m.translate((w / 2) - (scale * centerX), (h / 2) - (scale * centerY));
488491
bm.draw(dispObj, m);
489492
return bm;

0 commit comments

Comments
 (0)