@@ -54,11 +54,11 @@ public SKBitmap GetBackground()
5454 else if ( BackgroundType == BgType . TEX_CG_DUAL_SCREEN )
5555 {
5656 SKBitmap bitmap = new ( Graphic1 . Width , Graphic1 . Height + Graphic2 . Height ) ;
57- SKCanvas canvas = new ( bitmap ) ;
57+ using SKCanvas canvas = new ( bitmap ) ;
5858
5959 SKBitmap tileBitmap = new ( Graphic2 . Width , Graphic2 . Height ) ;
6060 SKBitmap tiles = Graphic2 . GetImage ( width : 64 ) ;
61- SKCanvas tileCanvas = new ( tileBitmap ) ;
61+ using SKCanvas tileCanvas = new ( tileBitmap ) ;
6262 int currentTile = 0 ;
6363 for ( int y = 0 ; y < tileBitmap . Height ; y += 64 )
6464 {
@@ -85,7 +85,7 @@ public SKBitmap GetBackground()
8585 else
8686 {
8787 SKBitmap bitmap = new ( Graphic1 . Width , Graphic1 . Height + Graphic2 . Height ) ;
88- SKCanvas canvas = new ( bitmap ) ;
88+ using SKCanvas canvas = new ( bitmap ) ;
8989
9090 canvas . DrawBitmap ( Graphic1 . GetImage ( ) , new SKPoint ( 0 , 0 ) ) ;
9191 canvas . DrawBitmap ( Graphic2 . GetImage ( ) , new SKPoint ( 0 , Graphic1 . Height ) ) ;
@@ -124,22 +124,23 @@ public bool SetBackground(SKBitmap image, IProgressTracker tracker, ILogger log,
124124 break ;
125125
126126 case BgType . TEX_CG_DUAL_SCREEN :
127+ {
127128 SKBitmap newTextureBitmap = new ( Graphic1 . Width , Graphic1 . Height ) ;
128129 SKBitmap newTileBitmap = new ( 64 , Graphic2 . Height * Graphic2 . Width / 64 ) ;
129130 SKBitmap tileSource = new ( image . Width , image . Height - Graphic1 . Height ) ;
130131
131132 tracker . Focus ( localize ( "Drawing bottom screen texture..." ) , 1 ) ;
132- SKCanvas textureCanvas = new ( newTextureBitmap ) ;
133+ using SKCanvas textureCanvas = new ( newTextureBitmap ) ;
133134 textureCanvas . DrawBitmap ( image , new ( 0 , image . Height - newTextureBitmap . Height , newTextureBitmap . Width , image . Height ) , new SKRect ( 0 , 0 , newTextureBitmap . Width , newTextureBitmap . Height ) ) ;
134135 textureCanvas . Flush ( ) ;
135136 tracker . Finished ++ ;
136137
137- SKCanvas tileSourceCanvas = new ( tileSource ) ;
138+ using SKCanvas tileSourceCanvas = new ( tileSource ) ;
138139 tileSourceCanvas . DrawBitmap ( image , 0 , 0 ) ;
139140 tileSourceCanvas . Flush ( ) ;
140141
141142 tracker . Focus ( localize ( "Drawing top screen tiles..." ) , newTileBitmap . Height / 64 * newTileBitmap . Width / 64 ) ;
142- SKCanvas tileCanvas = new ( newTileBitmap ) ;
143+ using SKCanvas tileCanvas = new ( newTileBitmap ) ;
143144 int currentTile = 0 ;
144145 for ( int y = 0 ; y < tileSource . Height ; y += 64 )
145146 {
@@ -170,19 +171,24 @@ public bool SetBackground(SKBitmap image, IProgressTracker tracker, ILogger log,
170171 Graphic2 . SetImage ( newTileBitmap ) ;
171172 tracker . Finished ++ ;
172173 break ;
174+ }
173175
174176 default :
177+ {
175178 SKBitmap newGraphic1 = new ( Graphic1 . Width , Graphic1 . Height ) ;
176179 SKBitmap newGraphic2 = new ( Graphic2 . Width , Graphic2 . Height ) ;
177180
178181 tracker . Focus ( localize ( "Drawing textures..." ) , 2 ) ;
179- SKCanvas canvas1 = new ( newGraphic1 ) ;
180- canvas1 . DrawBitmap ( image , new ( 0 , 0 , newGraphic1 . Width , newGraphic1 . Height ) , new SKRect ( 0 , 0 , newGraphic1 . Width , newGraphic1 . Height ) ) ;
182+ using SKCanvas canvas1 = new ( newGraphic1 ) ;
183+ canvas1 . DrawBitmap ( image , new ( 0 , 0 , newGraphic1 . Width , newGraphic1 . Height ) ,
184+ new SKRect ( 0 , 0 , newGraphic1 . Width , newGraphic1 . Height ) ) ;
181185 canvas1 . Flush ( ) ;
182186 tracker . Finished ++ ;
183187
184- SKCanvas canvas2 = new ( newGraphic2 ) ;
185- canvas2 . DrawBitmap ( image , new ( 0 , newGraphic1 . Height , newGraphic2 . Width , newGraphic1 . Height + newGraphic2 . Height ) , new SKRect ( 0 , 0 , newGraphic2 . Width , newGraphic2 . Height ) ) ;
188+ using SKCanvas canvas2 = new ( newGraphic2 ) ;
189+ canvas2 . DrawBitmap ( image ,
190+ new ( 0 , newGraphic1 . Height , newGraphic2 . Width , newGraphic1 . Height + newGraphic2 . Height ) ,
191+ new SKRect ( 0 , 0 , newGraphic2 . Width , newGraphic2 . Height ) ) ;
186192 canvas2 . Flush ( ) ;
187193 tracker . Finished ++ ;
188194
@@ -192,6 +198,7 @@ public bool SetBackground(SKBitmap image, IProgressTracker tracker, ILogger log,
192198 {
193199 texPalette . Insert ( 0 , new ( 0 , 248 , 0 ) ) ;
194200 }
201+
195202 tracker . Finished ++ ;
196203 Graphic1 . SetPalette ( texPalette ) ;
197204 tracker . Finished ++ ;
@@ -202,6 +209,7 @@ public bool SetBackground(SKBitmap image, IProgressTracker tracker, ILogger log,
202209 Graphic2 . SetImage ( newGraphic2 ) ;
203210 tracker . Finished ++ ;
204211 break ;
212+ }
205213 }
206214 return true ;
207215 }
@@ -230,4 +238,4 @@ public SKBitmap GetPreview(Project project)
230238 {
231239 return GetBackground ( ) ;
232240 }
233- }
241+ }
0 commit comments