Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

bug:mouse wheel to zoom out in HeatmapSample #37

@07012220

Description

@07012220

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

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions