Enum SvgImageFormat
The format SvgCanvas embeds drawn images in.
public enum SvgImageFormat
Fields
Jpeg = 1JPEG for opaque images (smaller for photos); images with transparency are still written as PNG.
Png = 0PNG: lossless, with alpha. The default.
Examples
// Anything drawn on a Canvas can be written as SVG: gradients, clips, images and pictures go once into defs.
using (SvgCanvas canvas = new(file, 200, 120, new SvgWriteOptions { Precision = 2, ImageFormat = SvgImageFormat.Png }))
{
canvas.FillRoundRect(new RoundRect(new RectF(10, 10, 180, 100), 12), new LinearGradient(new Vector2(10, 0), new Vector2(190, 0), new RgbaF32(0.1f, 0.4f, 0.9f, 1), new RgbaF32(0.9f, 0.2f, 0.5f, 1)));
canvas.SaveLayer(0.5f);
canvas.StrokePath(Egami.Drawing.Path.Oval(new RectF(30, 30, 140, 60)), new Stroke(6) { Dash = new DashPattern([10, 5]) }, new Rgba8(255, 255, 255, 255));
canvas.Restore();
// A sweep gradient has no SVG form: it is drawn by Egami and embedded as a PNG (Svg.FallbackImage).
canvas.FillCircle(new Vector2(100, 60), 20, new SweepGradient(new Vector2(100, 60), [new GradientStop(0, new RgbaF32(1, 1, 0, 1)), new GradientStop(1, new RgbaF32(0, 1, 1, 1))]));
}
// Disposing writes the file; the stream stays open.