-
Notifications
You must be signed in to change notification settings - Fork 270
bug:mouse wheel to zoom out in HeatmapSample #37
Description
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;
}
}
`