microsoft / InteractiveDataDisplay.WPF

Interactive Data Display for WPF is a set of controls for adding interactive visualization of dynamic data to your application. It allows to create line graphs, bubble charts, heat maps and other complex 2D plots which are very common in scientific software. Interactive Data Display for WPF integrates well with Bing Maps control to show data on a geographic map in latitude/longitude coordinates. The controls can also be operated programmatically.
Other
970 stars 265 forks source link

bug:mouse wheel to zoom out in HeatmapSample #37

Open 07012220 opened 4 years ago

07012220 commented 4 years ago

I just found a bug. when zooming out in heatmatpsample. ` private void OnTaskCompleted(RenderResult r, RenderTaskState state) { if (r != null && !state.IsCanceled) {

            WriteableBitmap wr = new WriteableBitmap((int)r.Output.Width, (int)r.Output.Height, 96, 96, PixelFormats.Bgra32, null);// **bug here when zoom out**
            // Calculate the number of bytes per pixel. 
            int bytesPerPixel = (wr.Format.BitsPerPixel + 7) / 8;
            // Stride is bytes per pixel times the number of pixels.
            // Stride is the byte width of a single rectangle row.
            int stride = wr.PixelWidth * bytesPerPixel;
            wr.WritePixels(new Int32Rect(0, 0, wr.PixelWidth, wr.PixelHeight), r.Image, stride, 0);

            outputImage.Source = wr;
            Canvas.SetLeft(outputImage, r.Output.Left);
            Canvas.SetTop(outputImage, r.Output.Top);
            imageCartesianRect = r.Visible;
            imageSize = new Size(r.Output.Width, r.Output.Height);
            outputImage.RenderTransform = null;
        }

        RaiseTaskCompletion(state.Id);

        runningTasks.Remove(state);

        while (tasks.Count > 1)
        {
            long id = tasks.Dequeue();
            RaiseTaskCompletion(id);
        }
        if (tasks.Count > 0 && runningTasks.Count < maxTasks)
        {
            EnqueueTask(tasks.Dequeue());
        }

        InvalidateMeasure();
    }

` 捕获

if should be chang to following

` if (r != null && !state.IsCanceled) { int width = (int)r.Output.Width; int heitht = (int)r.Output.Height; if (width!=0&& heitht!=0) { WriteableBitmap wr = new WriteableBitmap(width, heitht, 96, 96, PixelFormats.Bgra32, null); // Calculate the number of bytes per pixel. int bytesPerPixel = (wr.Format.BitsPerPixel + 7) / 8; // Stride is bytes per pixel times the number of pixels. // Stride is the byte width of a single rectangle row. int stride = wr.PixelWidth * bytesPerPixel; wr.WritePixels(new Int32Rect(0, 0, wr.PixelWidth, wr.PixelHeight), r.Image, stride, 0);

            outputImage.Source = wr;
            Canvas.SetLeft(outputImage, r.Output.Left);
            Canvas.SetTop(outputImage, r.Output.Top);
            imageCartesianRect = r.Visible;
            imageSize = new Size(r.Output.Width, r.Output.Height);
            outputImage.RenderTransform = null;
            }
        }

`