This question is locked. New answers and comments are not allowed.
I am using the 2011 Q3 Telerik Silverlight controls. I'm trying to implement a screenshot functionality by saving the root element of my page to a PNG, using the PngBitmapEncoder class. When I try to use it on some large images, though, (like the full screen of a large screen resolution) I get an error in the Telerik code.
Here is the error:
Index was outside the bounds of the array.
at Telerik.Windows.Media.Imaging.Zip.DeflateManager.Tally(Int32 dist, Int32 lc)
at Telerik.Windows.Media.Imaging.Zip.DeflateManager.ProcessSlowDeflate(Int32 flush, Int32& num)
at Telerik.Windows.Media.Imaging.Zip.DeflateManager.SlowDeflate(Int32 flush)
at Telerik.Windows.Media.Imaging.Zip.DeflateManager.Deflate(ZipBaseStream strm, Int32 flush)
at Telerik.Windows.Media.Imaging.Zip.ZipBaseStream.Deflate(Int32 flush)
at Telerik.Windows.Media.Imaging.Zip.ZipOutputStream.FinishWriting()
at Telerik.Windows.Media.Imaging.Zip.ZipOutputStream.Close()
at System.IO.Stream.Dispose()
at Telerik.Windows.Media.Imaging.PngBitmapEncoder.WriteDataChunks()
at Telerik.Windows.Media.Imaging.PngBitmapEncoder.Encode(WriteableBitmap image)
at Telerik.Windows.Media.Imaging.PngBitmapEncoder.Save(Stream stream)
at Telerik.Windows.Media.Imaging.ImageExporter.Export(FrameworkElement element, Stream stream, BitmapEncoder encoder)
at Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(FrameworkElement element, Stream stream, BitmapEncoder encoder)
at RadControlsSilverlightApp2.MainPage.myImage_ImageOpened(Object sender, RoutedEventArgs e)
And here is some example XAML/CS that create the error, using the attached image.
Am I doing anything wrong? Is this simply a bug in the Telerik ZIP/PNG code?
Here is the error:
Index was outside the bounds of the array.
at Telerik.Windows.Media.Imaging.Zip.DeflateManager.Tally(Int32 dist, Int32 lc)
at Telerik.Windows.Media.Imaging.Zip.DeflateManager.ProcessSlowDeflate(Int32 flush, Int32& num)
at Telerik.Windows.Media.Imaging.Zip.DeflateManager.SlowDeflate(Int32 flush)
at Telerik.Windows.Media.Imaging.Zip.DeflateManager.Deflate(ZipBaseStream strm, Int32 flush)
at Telerik.Windows.Media.Imaging.Zip.ZipBaseStream.Deflate(Int32 flush)
at Telerik.Windows.Media.Imaging.Zip.ZipOutputStream.FinishWriting()
at Telerik.Windows.Media.Imaging.Zip.ZipOutputStream.Close()
at System.IO.Stream.Dispose()
at Telerik.Windows.Media.Imaging.PngBitmapEncoder.WriteDataChunks()
at Telerik.Windows.Media.Imaging.PngBitmapEncoder.Encode(WriteableBitmap image)
at Telerik.Windows.Media.Imaging.PngBitmapEncoder.Save(Stream stream)
at Telerik.Windows.Media.Imaging.ImageExporter.Export(FrameworkElement element, Stream stream, BitmapEncoder encoder)
at Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(FrameworkElement element, Stream stream, BitmapEncoder encoder)
at RadControlsSilverlightApp2.MainPage.myImage_ImageOpened(Object sender, RoutedEventArgs e)
And here is some example XAML/CS that create the error, using the attached image.
<UserControl x:Class="RadControlsSilverlightApp2.MainPage" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot"> <Image Name="myImage" Source="cant encode.png" Stretch="None" ImageOpened="myImage_ImageOpened" /> </Grid></UserControl>using System;using System.IO;using System.Windows;using System.Windows.Controls;using Telerik.Windows.Media.Imaging;namespace RadControlsSilverlightApp2{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void myImage_ImageOpened(object sender, RoutedEventArgs e) { try { ExportExtensions.ExportToImage(myImage, new MemoryStream(), new PngBitmapEncoder()); } catch (Exception ex) { MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace); } } }}Am I doing anything wrong? Is this simply a bug in the Telerik ZIP/PNG code?