2017-09-18 19 views
8

Tôi có một ứng dụng dựa vào các hình ảnh thu phóng sâu (chuyển từ PNG sang kim tự tháp JPG ở các mức khác nhau) mà chúng tôi sử dụng DeepZoomTools.dll cho. Điều này phụ thuộc vào PresentationCore.dll và đã hoạt động tốt trong nhiều năm.Cập nhật Windows KB4040972/73 khiến ảnh đen với các lớp WPF

Sau khi giới thiệu KB4040972 và KB4040973, chuyển đổi từ PNG sang JPG tạo (tùy thuộc vào tọa độ) hình ảnh đen thay vì hình ảnh cần chứa.

Nếu mã bên dưới được chạy trong bảng điều khiển hoặc ứng dụng dành cho máy tính để bàn, nó hoạt động.

CHỈ CHỈ không hoạt động nếu chạy trong tài khoản SYSTEM có đặc quyền cao (ví dụ: từ Trình lập lịch tác vụ).

Tôi đã tạo ra một dự án để tạo lại vấn đề, mã bên dưới:

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(); 
} 
} 

Bất kỳ manh mối out there?

+0

có lẽ đây không phải là câu hỏi hay cho SO, chỉ đơn giản là lỗi trong cửa sổ, – zowers

+0

xem https://social.msdn.microsoft.com/Forums/vstudio/en-US/0f14f14c-5cd3-4505-9168-2ef9dc1f7031/kb-4041083-kb-4040973-has-broken-wpf-rendering-in-services? forum = wpf – zowers

+0

Cùng một vấn đề ở đây. –

Trả lời

2

Microsoft đã xuất bản một bài viết nơi họ tuyên bố rằng họ nhận thức được vấn đề này và đang làm việc trên một giải pháp. Họ cũng cung cấp giải pháp tạm thời, về cơ bản tạm thời xóa bản cập nhật Ngày 12 tháng 9 năm 2017, Bảo mật và Chất lượng.

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

+0

Giải pháp có sẵn với bản cập nhật ".NET Framework tháng 10 năm 2017 về Bảo mật và Chất lượng". Xem: https://blogs.msdn.microsoft.com/dotnet/2017/10/10/net-framework-october-2017-security-and-quality-rollup/ –

0

Đối với chúng tôi vào cuối bản cập nhật được đề nghị từ Microsoft KB4043767 giải quyết vấn đề này. Đây sẽ là một phần của bản giới thiệu tháng 10 (hiện đang trong Xem trước).

Các vấn đề liên quan