RenderRaster() публичный статический Метод

public static RenderRaster ( SKCanvas canvas, SKBitmap bitmap, SKRect rect, float opacity = 1f ) : void
canvas SkiaSharp.SKCanvas
bitmap SkiaSharp.SKBitmap
rect SkiaSharp.SKRect
opacity float
Результат void
Пример #1
0
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature,
                                IDictionary <object, SKBitmapInfo> skBitmapCache, long currentIteration)
        {
            try
            {
                var raster = (IRaster)feature.Geometry;

                SKBitmapInfo textureInfo;

                if (!skBitmapCache.Keys.Contains(raster))
                {
                    textureInfo           = BitmapHelper.LoadTexture(raster.Data);
                    skBitmapCache[raster] = textureInfo;
                }
                else
                {
                    textureInfo = skBitmapCache[raster];
                }

                textureInfo.IterationUsed = currentIteration;
                skBitmapCache[raster]     = textureInfo;
                var destination = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                BitmapHelper.RenderRaster(canvas, textureInfo.Bitmap, RoundToPixel(destination).ToSkia());
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex.Message, ex);
            }
        }
Пример #2
0
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature,
                                float opacity, IDictionary <object, BitmapInfo> tileCache, long currentIteration)
        {
            try
            {
                var raster = (IRaster)feature.Geometry;

                BitmapInfo bitmapInfo;

                if (!tileCache.Keys.Contains(raster))
                {
                    bitmapInfo        = BitmapHelper.LoadBitmap(raster.Data);
                    tileCache[raster] = bitmapInfo;
                }
                else
                {
                    bitmapInfo = tileCache[raster];
                }

                bitmapInfo.IterationUsed = currentIteration;
                tileCache[raster]        = bitmapInfo;

                var boundingBox = feature.Geometry.GetBoundingBox();

                if (viewport.IsRotated)
                {
                    var priorMatrix = canvas.TotalMatrix;

                    var matrix = CreateRotationMatrix(viewport, boundingBox, priorMatrix);

                    canvas.SetMatrix(matrix);

                    var destination = new BoundingBox(0.0, 0.0, boundingBox.Width, boundingBox.Height);

                    BitmapHelper.RenderRaster(canvas, bitmapInfo.Bitmap, destination.ToSkia(), opacity);

                    canvas.SetMatrix(priorMatrix);
                }
                else
                {
                    var destination = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                    BitmapHelper.RenderRaster(canvas, bitmapInfo.Bitmap, RoundToPixel(destination).ToSkia(), opacity);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex.Message, ex);
            }
        }