@@ -77,8 +77,16 @@ public GraphicsElementFlags Flags
7777 [ Reactive , Browsable ( false ) ]
7878 public Bitmap DisplayedImage { get ; private set ; }
7979
80- [ Reactive , Browsable ( false ) ]
81- public Image < Rgba32 > UnderlyingImage { get ; set ; }
80+ [ Browsable ( false ) ]
81+ public Image < Rgba32 > UnderlyingImage
82+ {
83+ get => Model . Image ! ;
84+ set
85+ {
86+ Model . Image = value ;
87+ this . RaisePropertyChanged ( nameof ( UnderlyingImage ) ) ;
88+ }
89+ }
8290
8391 [ Browsable ( false ) ]
8492 public Avalonia . Rect SelectedBitmapPreviewBorder
@@ -98,7 +106,7 @@ public ImageViewModel(GraphicsElement graphicsElement)
98106
99107 _ = this . WhenAnyValue ( o => o . UnderlyingImage )
100108 . Where ( x => x != null )
101- . Subscribe ( _ => UnderlyingImageChanged ( ) ) ;
109+ . Subscribe ( _ => DisplayedImage = UnderlyingImage ! . ToAvaloniaBitmap ( ) ) ;
102110
103111 _ = this . WhenAnyValue ( o => o . DisplayedImage )
104112 . Subscribe ( _ => this . RaisePropertyChanged ( nameof ( SelectedBitmapPreviewBorder ) ) ) ;
@@ -133,9 +141,6 @@ public void RecolourImage(ColourSwatch primary, ColourSwatch secondary, PaletteM
133141 DisplayedImage = image ! . ToAvaloniaBitmap ( ) ;
134142 }
135143
136- void UnderlyingImageChanged ( )
137- => DisplayedImage = UnderlyingImage ! . ToAvaloniaBitmap ( ) ;
138-
139144 public void CropImage ( )
140145 {
141146 var cropRegion = FindCropRegion ( UnderlyingImage ) ;
@@ -153,7 +158,7 @@ public void CropImage()
153158 YOffset += ( short ) cropRegion . Top ;
154159 }
155160
156- UnderlyingImageChanged ( ) ;
161+ this . RaisePropertyChanged ( nameof ( UnderlyingImage ) ) ;
157162
158163 static Rectangle FindCropRegion ( Image < Rgba32 > image )
159164 {
0 commit comments