Пример #1
0
        public void Update(CanvasBitmap bitmap, bool redraw = true)
        {
            Clear();

            if (bitmap == null)
            {
                this.measureBitmap.Dispose();
                this.measureBitmap = null;
                this.canvas.Width  = this.canvas.Height = 0;
                CanMeasure         = false;
                return;
            }

            var contentSize = bitmap.SizeInPixels;
            var width       = (int)contentSize.Width + StartX * 2;
            var height      = (int)contentSize.Height + StartY * 2;

            measureBitmap = CreateEmptyBitmap(width, height);
            measureBitmap.CopyPixelsFromBitmap(bitmap, StartX, StartY);

            this.canvas.Width  = width;
            this.canvas.Height = height;

            magnifier        = magnifier ?? new Magnifier(this.canvas);
            magnifier.Source = measureBitmap;

            if (redraw)
            {
                this.canvas.Invalidate();
            }
            CanMeasure = true;
        }