Windows update KB4040972 / 73 causes black images with WPF classes

I have an application based on images with deep magnification (converting from PNG to JPG pyramid at various scales), for which we use DeepZoomTools.dll. It depends on PresentationCore.dll and works fine for many years.

After deploying KB4040972 and KB4040973, the conversion from PNG to JPG generates (depending on the coordinates) black images instead of the image that should contain.

If the code below runs in a console or desktop application, it works.

It ONLY does not work if it is running under the SYSTEM account with a high privilege (for example, from the task scheduler).

I created a project to reproduce the problem, the code below:

public static void TestConvert2(string strFileName, string strOutFileName) { JpegBitmapEncoder jpegBitmapEncoder = new JpegBitmapEncoder(); jpegBitmapEncoder.QualityLevel = 1 + (int) Math.Round(0.95 * 99.0); BitmapEncoder encoder = jpegBitmapEncoder; Int32Rect inputRect = new Int32Rect(0, 0, 255, 255); Rect outputRect = new Rect(0, 0, 255, 255); Uri bitmapUri = new Uri(strFileName, UriKind.RelativeOrAbsolute); BitmapDecoder bitmapDecoder = BitmapDecoder.Create(bitmapUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad); bitmapDecoder = BitmapDecoder.Create(bitmapUri, BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.None); BitmapSource inputFrame = (BitmapSource) bitmapDecoder.Frames[0]; BitmapSource source1 = (BitmapSource) new CroppedBitmap(inputFrame, inputRect); DrawingVisual drawingVisual = new DrawingVisual(); using(DrawingContext drawingContext = drawingVisual.RenderOpen()) { drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)), null, outputRect); drawingContext.DrawImage((ImageSource) source1, outputRect); drawingContext.Close(); } RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(255, 255, 96.0, 96.0, PixelFormats.Default); renderTargetBitmap.Render((Visual) drawingVisual); source1 = (BitmapSource) new FormatConvertedBitmap((BitmapSource) renderTargetBitmap, PixelFormats.Bgr24, (BitmapPalette) null, 0.0); BitmapFrame frameToCache = BitmapFrame.Create(source1, (BitmapSource) null, null, (ReadOnlyCollection < ColorContext > ) null); encoder.Frames.Add(frameToCache); using(FileStream fileStream = new FileStream(strOutFileName, FileMode.Create)) { encoder.Save((Stream) fileStream); fileStream.Flush(); } } 

Any clues there?

+8
wpf rendertargetbitmap drawingvisual
source share
3 answers

Microsoft has published an article saying that they are aware of this problem and are working on a resolution. They also provide a workaround, mainly to temporarily remove the September 12, 2017 security and quality update.

See: https://support.microsoft.com/en-us/help/4043601/rendering-issues-after-the-september-12-2017-net-security-and-quality

+2
source share
+1
source share

For us, at the end, the recommended update from Microsoft KB4043767 solved this problem. This will be part of the October deployment (currently in Preview).

0
source share

All Articles