shrink Image element by image size.
This commit is contained in:
parent
c365c937e2
commit
5a4ddda37d
|
@ -6623,15 +6623,14 @@ Image.prototype.setImage = function(img, callback) {
|
|||
});
|
||||
|
||||
// XXX Move below code to callback.
|
||||
if (self.shrink) {
|
||||
if (self.shrink || self.options.autofit) {
|
||||
delete self.shrink;
|
||||
delete self.options.shrink;
|
||||
self.options.autofit = true;
|
||||
self.imageSize(img, function(err, size) {
|
||||
if (err) return;
|
||||
if (self.position.width == null) {
|
||||
self.position.width = size.width / tw | 0;
|
||||
}
|
||||
if (self.position.height == null) {
|
||||
self.position.height = size.height / th | 0;
|
||||
}
|
||||
self.position.width = size.width / tw | 0;
|
||||
self.position.height = size.height / th | 0;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ var img = blessed.image({
|
|||
parent: screen,
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
width: 20,
|
||||
height: 20,
|
||||
width: 'shrink',
|
||||
height: 'shrink',
|
||||
bg: 'green',
|
||||
file: process.argv[2] || __dirname + '/test-image.png'
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue