Exemple #1
0
        private static IHtmlContent GetHtml(SKData data)
        {
            var base64 = Convert.ToBase64String(data.AsSpan());

            return(div(
                       img[src: "data:image/png;base64," + base64]));
        }
    /// <summary>
    /// Encodes the <paramref name="image"/> into the png bytes of the layer
    /// </summary>
    /// <param name="bitmap">The bitmap that should be encoded</param>
    /// <returns><paramref name="image"/></returns>
    public static SerializableLayer FromSKImage(this SerializableLayer layer, SKImage image)
    {
        using SKData data = image.Encode();

        layer.PngBytes = data.AsSpan().ToArray();
        layer.Width    = image.Width;
        layer.Height   = image.Height;

        return(layer);
    }
    /// <summary>
    /// Encodes the <paramref name="bitmap"/> into the png bytes of the layer
    /// </summary>
    /// <param name="bitmap">The bitmap that should be encoded</param>
    /// <returns><paramref name="layer"/></returns>
    public static SerializableLayer FromSKBitmap(this SerializableLayer layer, SKBitmap bitmap)
    {
        using SKData data = bitmap.Encode(SKEncodedImageFormat.Png, 100);

        layer.PngBytes = data.AsSpan().ToArray();
        layer.Width    = bitmap.Width;
        layer.Height   = bitmap.Height;

        return(layer);
    }
    public byte[] SerializeAndCreate()
    {
        SerializableDocument document = Helper.CreateDocument(Size, Layers, false);

        for (int i = 0; i < Layers; i++)
        {
            SKData encoded = bitmaps[i].Encode(SKEncodedImageFormat.Png, 100);
            document.Layers[i].PngBytes = encoded.AsSpan().ToArray();
        }

        return(PixiParser.Serialize(benchmarkDocument));
    }