Page 1 of 1

ExportToStream is very blurry

Posted: Mon Aug 03, 2015 6:55 pm
by greggorob64
Hi.

I'm working on getting an image exported from a lightning chart control into a devex report. In order to do that I have to have an 'Image' object. My plan was to use ExportToStream and then Image.FromStream.

However, its so blurry! I can't figure out what kind of configuration I'm going to need to order to get this to export cleanly.

What am I missing?

Thanks!

Code: Select all

      public Image ExportToStream(int width, int height)
      {
         var stream = new MemoryStream();

         var options = new BitmapAntialiasOptions();
         //options.ResolutionDivider = 0;
         //options.BlurRadius = 0;
         //options.ActualPixelWeight = 0;

         this.PrimaryChart.SaveToStream(stream, TargetImageFormat.Bmp, options, width, height);
         var image = Image.FromStream(stream);
         return image;
      }
Image

Re: ExportToStream is very blurry

Posted: Wed Aug 05, 2015 1:02 pm
by ArctionPasi
Hi!

To make a sharp output, use these:

options.ResolutionDivider = 1;
options.BlurRadius = 0;
options.ActualPixelWeight = 1;

Or you can just use the SaveToStream override that doesn't take the antialiasOptions parameter at all. It's faster that way too. ;)

Re: ExportToStream is very blurry

Posted: Wed Aug 05, 2015 2:44 pm
by greggorob64
I'll go for the no-parameters option. I had originally just copypasted someone elses code snippet as my starting point.

As a side-note, the documentation for the antialiasing properties would have helped me a lot more if it indicated some default values.
Hope you don't mind the feedback

Thanks!

Re: ExportToStream is very blurry

Posted: Wed Aug 05, 2015 8:01 pm
by ArctionPasi
Feedback is always welcome and important. :)

We have these in the xml comments that VS shows when you move your mouse over the property in the code.

ActualPixelWeight: Put actualPixelWeigth to higher value to make the actual pixel effect more (not much blurred). Use 1 to get high blur effect.

BlurRadius: Use blur radius >= 1. With 1, blur takes current pixel and one pixel from all directions.

ResolutionDivider: Use resolutionDivider to divide the output bitmap size. If you want every other and column to be in the output bitmap, put 2.

Could you please help us writing better descriptions on these? We'd really appreciate it :|

Re: ExportToStream is very blurry

Posted: Mon Aug 10, 2015 5:19 pm
by greggorob64
This was my workflow before I posted by original forum post.

[*]Copy-pasted someone elses 'export to stream' example with antialiasing options
[*]Commented out all parameters
[*]noticed it was blurry

So i checked the xml documentation for the first two properties, for ActionalPixelWeight and BlurRadius, and said "well, i don't want any blur." So i put zero for both. The documentation just states what to do to increase the blur.

Doing that threw an exception because zero was invalid for one or more of them. At that point i just said "well this is silly, i'll just ask pasi"

The obvious answer should have been to just use the overload without any blur options, but I wasn't thinking clearly.