Skip to content

Commit

Permalink
fix: Bitmap.setImage need set width&height
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed May 18, 2016
1 parent e192627 commit 7806046
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/view/Bitmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
this.width = rect[2];
this.height = rect[3];
}
else if(!this.width && !this.height){
var rect = this.drawable.rect;
if(rect){
this.width = rect[2];
this.height = rect[3];
}
}
return this;
}
});
4 changes: 2 additions & 2 deletions test/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<script src="mocha.js"></script>
<script src='utils.js'></script>
<script src="../../node_modules/should/should.js"></script>
<script src="../../build/standalone/hilo-standalone.js"></script>
<script src="../../build/flash/hilo-flash.js" data-auto="true"></script>
<script src="../../build/standalone/hilo-standalone.min.js"></script>
<script src="../../build/flash/hilo-flash.min.js" data-auto="true"></script>
<script>
mocha.setup({
ui:'bdd',
Expand Down
10 changes: 9 additions & 1 deletion test/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ describe('view', function() {
});

describe('Bitmap', function() {
var bmp;
var bmp, btnImage;
beforeEach('init bitmap', function(done){
utils.loadImage('images/btn.png', function(img){
btnImage = img;
bmp = new Hilo.Bitmap({
image: img,
rect:[0, 64, 64, 64]
Expand Down Expand Up @@ -59,6 +60,13 @@ describe('view', function() {
utils.diffWithScreenshot('Bitmap-setImage', done);
});
});

it('new Bitmap and setImage', function(){
var bmp = new Hilo.Bitmap();
bmp.setImage(btnImage);
bmp.width.should.equal(256);
bmp.height.should.equal(128);
});
});

describe('BitmapText', function() {
Expand Down

0 comments on commit 7806046

Please sign in to comment.