@@ -120,9 +120,15 @@ private void CheckRefresh()
120120
121121 protected virtual void OnRender ( DrawingContext drawingContext , double scaleX , double scaleY )
122122 {
123- drawingContext . PushTransform ( new ScaleTransform ( scaleX , scaleY ) ) ;
123+ if ( scaleX != 1d || scaleY != 1d )
124+ {
125+ drawingContext . PushTransform ( new ScaleTransform ( scaleX , scaleY ) ) ;
126+ }
124127 OnRender ( drawingContext ) ;
125- drawingContext . Pop ( ) ;
128+ if ( scaleX != 1d || scaleY != 1d )
129+ {
130+ drawingContext . Pop ( ) ;
131+ }
126132 }
127133
128134
@@ -152,7 +158,7 @@ private void UpdateTransform()
152158 /// <param name="drawingContext"></param>
153159 /// <param name="image"></param>
154160 /// <param name="imageRectangle"></param>
155- private void RenderEffect ( DrawingContext drawingContext , ImageSource image , Rect imageRectangle )
161+ private void RenderEffect ( DrawingContext drawingContext , DrawingVisual image , Rect imageRectangle )
156162 {
157163 // ShaderEffect can be deleted in Profile Editor so we always need to get it from ProfileManager
158164 if ( ! _designTimeChecked )
@@ -174,19 +180,12 @@ private void RenderEffect(DrawingContext drawingContext, ImageSource image, Rect
174180 _effect = ConfigManager . ProfileManager . CurrentEffect as Effects . ColorAdjustEffect ;
175181 }
176182
177- System . Windows . Controls . Image imageControl = new System . Windows . Controls . Image
178- {
179- Source = image ,
180- Width = image != null ? image . Width : 0 ,
181- Height = image != null ? image . Width : 0 ,
182-
183- } ;
184183 if ( ! Visual . EffectsExclusion )
185184 {
186- imageControl . Effect = _effect ;
185+ image . Effect = _effect ;
187186 }
188- VisualBrush visualBrush = new VisualBrush ( imageControl ) ;
189- drawingContext . DrawRectangle ( visualBrush , null , imageRectangle ) ;
187+
188+ drawingContext . DrawRectangle ( new VisualBrush ( image ) , null , imageRectangle ) ;
190189 }
191190
192191 /// <summary>
@@ -197,16 +196,12 @@ private void RenderEffect(DrawingContext drawingContext, ImageSource image, Rect
197196 /// <param name="rectangle"></param>
198197 protected void RenderVisual ( DrawingContext drawingContext , DrawingVisual visual , Rect rectangle )
199198 {
200- if ( visual . ContentBounds . IsEmpty || rectangle . Width == 0 || rectangle . Height == 0 ) { return ; }
201- RenderTargetBitmap rtb = new RenderTargetBitmap ( Convert . ToInt32 ( rectangle . Width ) , Convert . ToInt32 ( rectangle . Height ) , 96 , 96 , PixelFormats . Pbgra32 ) ;
202- rtb . Render ( visual ) ;
203- //drawingContext.DrawImage(rtb, rectangle);
204- RenderEffect ( drawingContext , rtb , rectangle ) ;
205-
206- // Address MILERR_WIN32ERROR (Exception from HRESULT: 0x88980003 in PresentationCore
207- ( rtb . GetType ( ) . GetField ( "_renderTargetBitmap" , BindingFlags . Instance | BindingFlags . NonPublic ) ?
208- . GetValue ( rtb ) as IDisposable ) ? . Dispose ( ) ; // from https://github.com/dotnet/wpf/issues/3067
199+ if ( visual . ContentBounds . IsEmpty || rectangle . Width == 0 || rectangle . Height == 0 )
200+ {
201+ return ;
202+ }
209203
204+ RenderEffect ( drawingContext , visual , rectangle ) ;
210205 }
211206
212207 #region Draw Proxies
0 commit comments