Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
break;
case 'src':
if (!value) {
return;
}
getLoadedPixmap(value as string)
.then(pixmap => this.setPixmap(pixmap))
.catch(console.warn);
// TODO: not set current aspect size
// const size = this.size();
// this.scalePixmap(size.width, size.height);
break;
case 'buffer':
const pixMap = new QPixmap();
pixMap.loadFromData(value as Buffer);
this.setPixmap(pixMap);
break;
case 'aspectRatioMode':
this.setAspectRatioMode(value as AspectRatioMode);
break;
default:
break;
}
}
setSrc(url: string) {
const pixMap = new QPixmap(url);
//if (isUrl(url)) {
// not implemented *facepalm*
// pixMap.native.loadFromData(url);
//} else {
// pixMap.load(url);
//}
this.setPixmap(pixMap);
const size = this.size();
this.scalePixmap(size.width, size.height);
}
set buffer(imageBuffer: Buffer) {
const pixMap = new QPixmap();
pixMap.loadFromData(imageBuffer);
widget.setPixmap(pixMap);
},
set aspectRatioMode(mode: AspectRatioMode) {
async function getLoadedPixmap(imageUrlOrPath: string): Promise {
const pixMap = new QPixmap();
if (isValidUrl(imageUrlOrPath)) {
const res = await phin(imageUrlOrPath);
const imageBuffer = Buffer.from(res.body);
pixMap.loadFromData(imageBuffer);
} else {
pixMap.load(imageUrlOrPath);
}
return pixMap;
}
async function getLoadedPixmap(imageUrlOrPath: string): Promise {
const pixMap = new QPixmap();
if (isValidUrl(imageUrlOrPath)) {
const res = await phin(imageUrlOrPath);
const imageBuffer = Buffer.from(res.body);
pixMap.loadFromData(imageBuffer);
} else {
pixMap.load(imageUrlOrPath);
}
return pixMap;
}