setImage from ASHIT-AXAR

This commit is contained in:
Adam D. Ruppe 2018-02-14 10:04:55 -05:00
parent 9af7a4fb94
commit d1efce1e33
1 changed files with 9 additions and 1 deletions

View File

@ -5133,6 +5133,14 @@ int[2] getChildPositionRelativeToParentHwnd(Widget c) nothrow {
class ImageBox : Widget { class ImageBox : Widget {
private MemoryImage image_; private MemoryImage image_;
///
public void setImage(MemoryImage image){
this.image_ = image;
if(this.parentWindow && this.parentWindow.win)
sprite = new Sprite(this.parentWindow.win, Image.fromMemoryImage(image_));
redraw();
}
/// How to fit the image in the box if they aren't an exact match in size? /// How to fit the image in the box if they aren't an exact match in size?
enum HowToFit { enum HowToFit {
center, /// centers the image, cropping around all the edges as needed center, /// centers the image, cropping around all the edges as needed
@ -5156,7 +5164,7 @@ class ImageBox : Widget {
} }
private void updateSprite() { private void updateSprite() {
if(this.parentWindow && this.parentWindow.win) if(sprite is null && this.parentWindow && this.parentWindow.win)
sprite = new Sprite(this.parentWindow.win, Image.fromMemoryImage(image_)); sprite = new Sprite(this.parentWindow.win, Image.fromMemoryImage(image_));
} }