예제 #1
0
        public void ImmutableBitmapsAreNotCopied()
        {
            // create "pixel data"
            var pixelData = new SKBitmap(100, 100);

            pixelData.Erase(SKColors.Red);

            // create text bitmap
            var bitmap = new SKBitmap();

            bitmap.InstallPixels(pixelData.PeekPixels());

            // mark it as immutable
            bitmap.SetImmutable();

            // create an image
            var image = SKImage.FromBitmap(bitmap);

            Assert.Equal(SKColors.Red, image.PeekPixels().GetPixelColor(50, 50));

            // modify the "pixel data"
            pixelData.Erase(SKColors.Blue);

            // ensure that the pixels are modified
            Assert.Equal(SKColors.Blue, image.PeekPixels().GetPixelColor(50, 50));
        }
예제 #2
0
        private static SKShader CreateCheckerboardShader(SKColor c1, SKColor c2, int size)
        {
            SKBitmap bm = new SKBitmap(new SKImageInfo(size * 2, size * 2));

            bm.Erase(c1);
            bm.Erase(c2, new SKRectI(0, 0, size, size));
            bm.Erase(c2, new SKRectI(size, size, 2 * size, 2 * size));
            return(SKShader.CreateBitmap(bm, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat));
        }
예제 #3
0
        public void MutableBitmapsAreCopied()
        {
            var bitmap = new SKBitmap(100, 100);

            bitmap.Erase(SKColors.Red);

            var image = SKImage.FromBitmap(bitmap);

            Assert.Equal(SKColors.Red, image.PeekPixels().GetPixelColor(50, 50));

            bitmap.Erase(SKColors.Blue);
            Assert.Equal(SKColors.Red, image.PeekPixels().GetPixelColor(50, 50));
        }
예제 #4
0
        public void ImmutableBitmapsAreNotCopied()
        {
            // this is a really weird test as it is a mutable bitmap that is marked as immutable

            var bitmap = new SKBitmap(100, 100);

            bitmap.Erase(SKColors.Red);
            bitmap.SetImmutable();

            var image = SKImage.FromBitmap(bitmap);

            Assert.Equal(SKColors.Red, image.PeekPixels().GetPixelColor(50, 50));

            bitmap.Erase(SKColors.Blue);
            Assert.Equal(SKColors.Blue, image.PeekPixels().GetPixelColor(50, 50));
        }
예제 #5
0
        public static void EmptyBitmap(this SKBitmap bmp)
        {
            var pn = new SKPaint();

            pn.BlendMode = SKBlendMode.Dst;
            bmp.Erase(SKColors.Beige);
        }
예제 #6
0
        /// <summary>
        /// Clear canvas
        /// </summary>
        public override void Clear()
        {
            CreateCanvas();

            _bmp.Erase(SKColors.Transparent);
            _canvas.Clear(SKColors.Transparent);
        }
예제 #7
0
        protected static SKBitmap CreateTestBitmap(byte alpha = 255)
        {
            var bmp = new SKBitmap(40, 40);

            bmp.Erase(SKColors.Transparent);

            using (var canvas = new SKCanvas(bmp))
                using (var paint = new SKPaint())
                {
                    var x = bmp.Width / 2;
                    var y = bmp.Height / 2;

                    paint.Color = SKColors.Red.WithAlpha(alpha);
                    canvas.DrawRect(SKRect.Create(0, 0, x, y), paint);

                    paint.Color = SKColors.Green.WithAlpha(alpha);
                    canvas.DrawRect(SKRect.Create(x, 0, x, y), paint);

                    paint.Color = SKColors.Blue.WithAlpha(alpha);
                    canvas.DrawRect(SKRect.Create(0, y, x, y), paint);

                    paint.Color = SKColors.Yellow.WithAlpha(alpha);
                    canvas.DrawRect(SKRect.Create(x, y, x, y), paint);
                }

            return(bmp);
        }
예제 #8
0
        private async Task <SKBitmap> GetVehiculeHeadingBitmap(string ligne, int heading)
        {
            bool flag = _config.Lignes.First((InfosLigne x) => x.Ligne == ligne).Mode == "T";

            using (Stream stream = await _fileManager.GetBundleBinaryFile(flag ? "Symboles/FlecheTram.png" : "Symboles/FlecheBus.png"))
            {
                using (SKBitmap sKBitmap = SKBitmap.Decode(stream))
                {
                    SKBitmap sKBitmap2 = new SKBitmap(sKBitmap.Width, sKBitmap.Height);
                    sKBitmap2.Erase(SKColors.Transparent);
                    using (SKPaint paint = new SKPaint
                    {
                        FilterQuality = SKFilterQuality.High,
                        IsAntialias = true
                    })
                    {
                        using (SKCanvas sKCanvas = new SKCanvas(sKBitmap2))
                        {
                            sKCanvas.RotateDegrees(heading, (float)sKBitmap.Width / 2f, (float)sKBitmap.Height / 2f);
                            sKCanvas.DrawBitmap(sKBitmap, 0f, 0f, paint);
                            return(sKBitmap2);
                        }
                    }
                }
            }
        }
예제 #9
0
        public static SKBitmap FromColor(SKImageInfo imageInfo, SKColor color)
        {
            var bitmap = new SKBitmap(imageInfo, SKBitmapAllocFlags.ZeroPixels);

            bitmap.Erase(color);
            return(bitmap);
        }
예제 #10
0
        public BitmapImpl(int width, int height, Vector dpi, PixelFormat?fmt = null)
        {
            PixelHeight = height;
            PixelWidth  = width;
            _dpi        = dpi;
            var colorType       = fmt?.ToSkColorType() ?? SKImageInfo.PlatformColorType;
            var runtimePlatform = AvaloniaLocator.Current?.GetService <IRuntimePlatform>();
            var runtime         = runtimePlatform?.GetRuntimeInfo();

            if (runtime?.IsDesktop == true && runtime?.OperatingSystem == OperatingSystemType.Linux)
            {
                colorType = SKColorType.Bgra8888;
            }

            if (runtimePlatform != null)
            {
                Bitmap = new SKBitmap();
                var nfo  = new SKImageInfo(width, height, colorType, SKAlphaType.Premul);
                var plat = AvaloniaLocator.Current.GetService <IRuntimePlatform>();
                var blob = plat.AllocBlob(nfo.BytesSize);
                Bitmap.InstallPixels(nfo, blob.Address, nfo.RowBytes, null, ReleaseDelegate, blob);
            }
            else
            {
                Bitmap = new SKBitmap(width, height, colorType, SKAlphaType.Premul);
            }
            Bitmap.Erase(SKColor.Empty);
        }
예제 #11
0
        /// <summary>
        /// Returns Texture Atlas' Bitmap
        /// </summary>
        /// <param name="colorType">The color type of the resulting bitmap</param>
        /// <returns>The texture atlas' bitmap</returns>
        private SKBitmap GetBitmap(SKColorType colorType = SKColorType.Rgba8888)
        {
            using (SKBitmap bmp = new SKBitmap(Width, Height, colorType, SKAlphaType.Premul)) //Premul needed for transparency !
            {
                bmp.Erase(SKColors.Transparent);                                              //DIDNT WORK WITHOUT THIS !!!! ctor of SKBitmap sometimes returned bitmap that was not clear ..
                                                                                              //When clicked several times on Generate atlas (with for example genetic, maxIterations 12300)

                using (SKCanvas canvas = new SKCanvas(bmp))
                {
                    foreach (var img in Rects)
                    {
                        canvas.DrawBitmap(img.Image.Bitmap, img.Rect);
                    }
                }

                //It may return Null, if SKColorType == Unknown, as it is not supported now
                var res = bmp.Copy();  //We have to return copy because we do not want to allow someone who got the bitmap to write into it
                if (res == null)
                {
                    res = new SKBitmap(Width, Height);
                    res.Erase(SKColors.Transparent);
                }

                return(res);
            }
        }
예제 #12
0
        public void DecodeImageScanlines()
        {
            var path        = Path.Combine(PathToImages, "CMYK.jpg");
            var imageHeight = 516;

            var fileData      = File.ReadAllBytes(path);
            var correctBitmap = SKBitmap.Decode(path);

            var stream = new SKFileStream(path);

            using (var codec = SKCodec.Create(stream))
            {
                var info = new SKImageInfo(codec.Info.Width, codec.Info.Height);
                using (var scanlineBitmap = new SKBitmap(info))
                {
                    scanlineBitmap.Erase(SKColors.Fuchsia);

                    var result = codec.StartScanlineDecode(info);
                    Assert.Equal(SKCodecResult.Success, result);

                    Assert.Equal(SKCodecScanlineOrder.TopDown, codec.ScanlineOrder);
                    Assert.Equal(0, codec.NextScanline);

                    // only decode every second line
                    for (int y = 0; y < info.Height; y += 2)
                    {
                        Assert.Equal(1, codec.GetScanlines(scanlineBitmap.GetAddress(0, y), 1, info.RowBytes));
                        Assert.Equal(y + 1, codec.NextScanline);
                        if (codec.SkipScanlines(1))
                        {
                            Assert.Equal(y + 2, codec.NextScanline);
                        }
                        else
                        {
                            Assert.Equal(imageHeight, codec.NextScanline);                             // reached the end
                        }
                    }

                    Assert.False(codec.SkipScanlines(1));
                    Assert.Equal(imageHeight, codec.NextScanline);

                    for (var x = 0; x < info.Width; x++)
                    {
                        for (var y = 0; y < info.Height; y++)
                        {
                            if (y % 2 == 0)
                            {
                                Assert.Equal(correctBitmap.GetPixel(x, y), scanlineBitmap.GetPixel(x, y));
                            }
                            else
                            {
                                Assert.Equal(SKColors.Fuchsia, scanlineBitmap.GetPixel(x, y));
                            }
                        }
                    }
                }
            }
        }
예제 #13
0
        private void ReleaseOverlayBitmap(SKBitmap tileBitmap)
        {
            tileBitmap.Erase(SKColor.Empty);

            lock (_overlayBitmapPool)
            {
                _overlayBitmapPool.Enqueue(tileBitmap);
            }
        }
예제 #14
0
 static void RenderIntoBitmap(int size, VoxelData voxelData, SKBitmap bitmap)
 {
     using (var canvas = new SKCanvas(bitmap)) {
         bitmap.Erase(SKColors.Transparent);
         RenderTriangles(voxelData, size, canvas, new MeshSettings {
             FrontFaces   = true,
             FakeLighting = true,
             FloorShadow  = true,
             MeshType     = MeshType.Triangles,
         });
     }
 }
예제 #15
0
        public void ReadPixelCopiesData()
        {
            var info = new SKImageInfo(10, 10);

            using (var bmp1 = new SKBitmap(info))
                using (var pix1 = bmp1.PeekPixels())
                    using (var bmp2 = new SKBitmap(info))
                        using (var pix2 = bmp2.PeekPixels())
                        {
                            bmp1.Erase(SKColors.Blue);
                            bmp1.Erase(SKColors.Green);

                            Assert.NotEqual(Marshal.ReadInt64(pix1.GetPixels()), Marshal.ReadInt64(pix2.GetPixels()));

                            var result = pix1.ReadPixels(pix2);

                            Assert.True(result);

                            Assert.Equal(Marshal.ReadInt64(pix1.GetPixels()), Marshal.ReadInt64(pix2.GetPixels()));
                        }
        }
예제 #16
0
        protected static SKBitmap CreateTestBitmap(byte alpha = 255)
        {
            var bmp = new SKBitmap(40, 40);

            bmp.Erase(SKColors.Transparent);

            using (var canvas = new SKCanvas(bmp))
            {
                DrawTestBitmap(canvas, 40, 40, alpha);
            }

            return(bmp);
        }
예제 #17
0
 public Bitmap(int width, int height, SKColorType colorType = (SKColorType.Bgra8888))
 {
     if (width <= 0)
     {
         throw new ArgumentOutOfRangeException(nameof(width));
     }
     if (height <= 0)
     {
         throw new ArgumentOutOfRangeException(nameof(height));
     }
     nativeSkBitmap = new SKBitmap(new SKImageInfo(width, height, colorType));
     nativeSkBitmap.Erase(SKColor.Empty);
 }
예제 #18
0
        public BitmapImpl(int width, int height, PixelFormat?fmt = null)
        {
            PixelHeight = height;
            PixelWidth  = width;
            var colorType = fmt?.ToSkColorType() ?? SKImageInfo.PlatformColorType;
            var runtime   = AvaloniaLocator.Current?.GetService <IRuntimePlatform>()?.GetRuntimeInfo();

            if (runtime?.IsDesktop == true && runtime?.OperatingSystem == OperatingSystemType.Linux)
            {
                colorType = SKColorType.Bgra8888;
            }
            Bitmap = new SKBitmap(width, height, colorType, SKAlphaType.Premul);
            Bitmap.Erase(SKColor.Empty);
        }
예제 #19
0
 public Bitmap(int clientSizeWidth, int clientSizeHeight, Graphics realDc)
 {
     if (clientSizeHeight < 1)
     {
         clientSizeHeight = 1;
     }
     if (clientSizeWidth < 1)
     {
         clientSizeWidth = 1;
     }
     nativeSkBitmap = new SKBitmap(new SKImageInfo(clientSizeWidth, clientSizeHeight, SKColorType.Bgra8888));
     nativeSkBitmap.Erase(SKColor.Empty);
     //nativeSkBitmap.SetPixels(realDc._surface.);
 }
예제 #20
0
        public void SwizzleRedBlueTest()
        {
            var info = new SKImageInfo(1, 1);

            using (var bmp = new SKBitmap(info))
            {
                bmp.Erase((uint)0xFACEB004);

                Assert.Equal((uint)0xFACEB004, (uint)bmp.GetPixel(0, 0));

                SKSwizzle.SwapRedBlue(bmp.GetPixels(), bmp.GetPixels(), 1);

                Assert.Equal((uint)0xFA04B0CE, (uint)bmp.GetPixel(0, 0));
            }
        }
예제 #21
0
        public void SwizzleSwapsRedAndBlue()
        {
            var info = new SKImageInfo(10, 10);

            using (var bmp = new SKBitmap(info))
            {
                bmp.Erase(SKColors.Red);

                Assert.Equal(SKColors.Red, bmp.Pixels[0]);

                SKSwizzle.SwapRedBlue(bmp.GetPixels(out var length), info.Width * info.Height);

                Assert.Equal(SKColors.Blue, bmp.Pixels[0]);
            }
        }
예제 #22
0
        private SKBitmap generateLabelBitmap(string fName, string lName, string title)
        {
            const int   width                = 596;
            const int   margin               = 4;
            const int   height               = 241;
            const float maxFontSizeName      = 65;
            const float maxFontSizeBrokerage = 30;

            SKBitmap bitmap = new SKBitmap(width + margin, height, SKColorType.Gray8, SKAlphaType.Opaque);

            bitmap.Erase(new SKColor(255, 255, 255));
            SKCanvas canvas = new SKCanvas(bitmap);

            //setup default paint style
            SKPaint paint = new SKPaint();

            paint.TextAlign  = SKTextAlign.Center;
            paint.TextSize   = maxFontSizeName;
            paint.Color      = new SKColor(0, 0, 0);
            paint.Typeface   = SKTypeface.FromFamilyName("Arial");
            paint.TextScaleX = 1;

            int textWidth = (int)(paint.MeasureText(fName + ' ' + lName) + 0.5f);

            if (textWidth > width)
            {
                paint.TextSize = ((float)width) / textWidth * maxFontSizeName;
                paint.TextSize = (int)paint.TextSize; //round down
            }
            float baseline       = -paint.FontMetrics.Ascent;
            float verticalOffset = (baseline / 2) + (height / 4);

            canvas.DrawText(fName + ' ' + lName, width / 2, verticalOffset, paint);

            //2nd line brokerage
            paint.TextSize = maxFontSizeBrokerage;
            textWidth      = (int)(paint.MeasureText(title) + 0.5f);
            if (textWidth > width)
            {
                paint.TextSize = ((float)width) / textWidth * maxFontSizeBrokerage;
                paint.TextSize = (int)paint.TextSize; //round down
            }
            baseline       = -paint.FontMetrics.Ascent;
            verticalOffset = (baseline / 2) + (height / 4) + (height / 2);
            canvas.DrawText(title, width / 2, verticalOffset, paint);

            return(bitmap);
        }
        public void AlphaMaskIsApplied()
        {
            var srcInfo = new SKImageInfo(4, 4);
            var srcBmp  = new SKBitmap(srcInfo);

            srcBmp.Erase(SKColors.Red);
            var pixels = srcBmp.Pixels;

            foreach (var pixel in pixels)
            {
                Assert.AreEqual(255, pixel.Alpha);
            }

            var maskBuffer = new byte[]
            {
                128, 127, 126, 125,
                101, 102, 103, 104,
                96, 95, 94, 93,
                72, 73, 74, 75
            };
            var  bounds   = new SKRectI(0, 0, 4, 4);
            uint rowBytes = 4;
            var  format   = SKMaskFormat.A8;
            var  mask     = SKMask.Create(maskBuffer, bounds, rowBytes, format);

            srcBmp.InstallMaskPixels(mask);

            pixels = srcBmp.Pixels;
            Assert.AreEqual(128, pixels[0].Alpha);
            Assert.AreEqual(127, pixels[1].Alpha);
            Assert.AreEqual(126, pixels[2].Alpha);
            Assert.AreEqual(125, pixels[3].Alpha);
            Assert.AreEqual(101, pixels[4].Alpha);
            Assert.AreEqual(102, pixels[5].Alpha);
            Assert.AreEqual(103, pixels[6].Alpha);
            Assert.AreEqual(104, pixels[7].Alpha);
            Assert.AreEqual(96, pixels[8].Alpha);
            Assert.AreEqual(95, pixels[9].Alpha);
            Assert.AreEqual(94, pixels[10].Alpha);
            Assert.AreEqual(93, pixels[11].Alpha);
            Assert.AreEqual(72, pixels[12].Alpha);
            Assert.AreEqual(73, pixels[13].Alpha);
            Assert.AreEqual(74, pixels[14].Alpha);
            Assert.AreEqual(75, pixels[15].Alpha);

            mask.FreeImage();
        }
예제 #24
0
        public void OverdrawCanvasDrawsProperly()
        {
            using (var bitmap = new SKBitmap(new SKImageInfo(100, 100)))
                using (var canvas = new SKCanvas(bitmap))
                    using (var overdraw = new SKOverdrawCanvas(canvas))
                    {
                        bitmap.Erase(SKColors.Transparent);

                        overdraw.DrawRect(SKRect.Create(10, 10, 30, 30), new SKPaint());
                        overdraw.DrawRect(SKRect.Create(20, 20, 30, 30), new SKPaint());

                        Assert.Equal(0, bitmap.GetPixel(5, 5).Alpha);
                        Assert.Equal(1, bitmap.GetPixel(15, 15).Alpha);
                        Assert.Equal(2, bitmap.GetPixel(25, 25).Alpha);
                        Assert.Equal(1, bitmap.GetPixel(45, 45).Alpha);
                    }
        }
예제 #25
0
        public HatchBrush(HatchStyle hatchStyle, Color foreColor, Color backColor)
        {
            HatchStyle = hatchStyle;
            SKBitmap bitmap = new SKBitmap(new SKImageInfo(2, 2, SKColorType.Bgra8888));

            bitmap.Erase(backColor.ToSKColor());
            bitmap.SetPixel(0, 0, foreColor.ToSKColor());
            bitmap.SetPixel(1, 1, foreColor.ToSKColor());

            // create the bitmap shader
            var shader = SKShader.CreateBitmap(bitmap, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat);

            // add to the paint
            nativeBrush = new SKPaint()
            {
                Shader = shader, Style = SKPaintStyle.Fill
            };
        }
예제 #26
0
        public override void Render(SKCanvas canvas)
        {
            // Scale down the render path to avoid computing a value for every pixel
            var width   = (int)(Math.Max(Layer.Rectangle.Width, Layer.Rectangle.Height) / Scale);
            var height  = (int)(Math.Max(Layer.Rectangle.Width, Layer.Rectangle.Height) / Scale);
            var opacity = (float)Math.Round(Settings.Color.Alpha / 255.0, 2, MidpointRounding.AwayFromZero);

            using (var bitmap = new SKBitmap(new SKImageInfo(width, height)))
            {
                bitmap.Erase(new SKColor(0, 0, 0, 0));
                // Only compute pixels inside LEDs, due to scaling there may be some rounding issues but it's neglect-able
                foreach (var artemisLed in Layer.Leds)
                {
                    var xStart = artemisLed.AbsoluteRenderRectangle.Left / Scale;
                    var xEnd   = artemisLed.AbsoluteRenderRectangle.Right / Scale;
                    var yStart = artemisLed.AbsoluteRenderRectangle.Top / Scale;
                    var yEnd   = artemisLed.AbsoluteRenderRectangle.Bottom / Scale;

                    for (var x = xStart; x < xEnd; x++)
                    {
                        for (var y = yStart; y < yEnd; y++)
                        {
                            var v     = _noise.Evaluate(Settings.XScale * x / width, Settings.YScale * y / height, _z);
                            var alpha = (byte)((v + 1) * 127 * opacity);
                            // There's some fun stuff we can do here, like creating hard lines
                            // if (alpha > 128)
                            //     alpha = 255;
                            // else
                            //     alpha = 0;
                            var color = new SKColor(Settings.Color.Red, Settings.Color.Green, Settings.Color.Blue, alpha);
                            bitmap.SetPixel((int)x, (int)y, color);
                        }
                    }
                }

                using (var sh = SKShader.CreateBitmap(bitmap, SKShaderTileMode.Mirror, SKShaderTileMode.Mirror, SKMatrix.MakeScale(Scale, Scale)))
                    using (var paint = new SKPaint {
                        Shader = sh, BlendMode = Settings.BlendMode
                    })
                    {
                        canvas.DrawPath(Layer.LayerShape.RenderPath, paint);
                    }
            }
        }
예제 #27
0
        private SKBitmap GetOverlayBitmap()
        {
            SKBitmap overlayBitmap;

            lock (_overlayBitmapPool)
            {
                if (_overlayBitmapPool.Count == 0)
                {
                    int bitmapSize = SKMapCanvas.MapTileSize;

                    overlayBitmap = new SKBitmap(bitmapSize, bitmapSize, SKColorType.Rgba8888, SKAlphaType.Premul);
                    overlayBitmap.Erase(SKColor.Empty);
                }
                else
                {
                    overlayBitmap = _overlayBitmapPool.Dequeue();
                }
            }

            return(overlayBitmap);
        }
예제 #28
0
        private SKBitmap GetOverlayBitmap()
        {
            SKBitmap overlayBitmap;

            lock (_overlayBitmapPool)
            {
                if (_overlayBitmapPool.Count == 0)
                {
                    int bitmapSize = (int)(SKMapCanvas.MapTileSize * Math.Min(2, _Context.Resources.DisplayMetrics.Density));

                    overlayBitmap = new SKBitmap(bitmapSize, bitmapSize, SKColorType.Rgba8888, SKAlphaType.Premul);
                    overlayBitmap.Erase(SKColor.Empty);
                }
                else
                {
                    overlayBitmap = _overlayBitmapPool.Dequeue();
                }
            }

            return(overlayBitmap);
        }
        /// <inheritdoc />
        public override PPImage RemoveBackground(PPImage input, CancellationToken token = default)
        {
            if (input == null)
            {
                throw new ArgumentNullException($"The {nameof(input)} cannot be null");
            }

            var component = SelectBackground(input);

            //Cancellation was requested during the SelectBackground method
            if (component == null)
            {
                return(input);
            }

#pragma warning disable CA2000 // The resulting PPImage is the owner of the bitmap
            SKBitmap bmp2 = new SKBitmap(input.Bitmap.Width, input.Bitmap.Height, input.Bitmap.ColorType, SKAlphaType.Premul)
            {
                Pixels = input.Bitmap.Pixels
            };
#pragma warning restore CA2000 // So it should not get disposed there
            bmp2.Erase(SKColors.Transparent);

            foreach (var pix in component)
            {
                if (token.IsCancellationRequested)
                {
                    return(input);
                }
                bmp2.SetPixel(pix % input.Bitmap.Width, pix / input.Bitmap.Width, SKColors.Transparent);
            }

            return(new PPImage(bmp2, input.ImagePath)
            {
                ImageName = input.ImageName
            });
        }
예제 #30
0
        private async Task <SKImage> GetMapVehiculeSymbol(Vehicule vehicule, int symbolHeight, int vehiculeHeight, int ligneRibbonHeight, bool displayDirection)
        {
            _ = 2;
            try
            {
                _ = symbolHeight - vehiculeHeight - ligneRibbonHeight;
                SKPaint paint = new SKPaint
                {
                    FilterQuality = SKFilterQuality.High,
                    IsAntialias   = true
                };
                SKBitmap vehiculeBitmap = await GetVehiculeBitmap(vehicule.Ligne);

                SKBitmap headingBitmap = await GetVehiculeHeadingBitmap(vehicule.Ligne, vehicule.Cap);

                SKBitmap sKBitmap = await GetLigneSymbolBitmap(vehicule.Ligne, displayDirection?vehicule.Destination : null, ligneRibbonHeight, 20);

                SKBitmap sKBitmap2 = new SKBitmap(Math.Max(vehiculeBitmap.Width, sKBitmap.Width), symbolHeight);
                sKBitmap2.Erase(SKColors.Transparent);
                using (SKCanvas sKCanvas = new SKCanvas(sKBitmap2))
                {
                    SKRect vehiculeSpriteRect = GetVehiculeSpriteRect(vehiculeBitmap, vehiculeHeight, sKBitmap2.Width);
                    sKCanvas.DrawBitmap(headingBitmap, vehiculeSpriteRect, paint);
                    sKCanvas.DrawBitmap(vehiculeBitmap, vehiculeSpriteRect, paint);
                    int    num  = ligneRibbonHeight * sKBitmap.Width / sKBitmap.Height;
                    float  num2 = (float)(sKBitmap2.Width - num) / 2f;
                    SKRect dest = new SKRect(num2, symbolHeight - ligneRibbonHeight, (float)sKBitmap2.Width - num2, symbolHeight);
                    sKCanvas.DrawBitmap(sKBitmap, dest, paint);
                }
                return(SKImage.FromBitmap(sKBitmap2));
            }
            catch (Exception)
            {
                return(null);
            }
        }