public unsafe static SKDocument CreatePdf(SKWStream stream, SKDocumentPdfMetadata metadata, float dpi = DefaultRasterDpi) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } using (var title = SKString.Create(metadata.Title)) using (var author = SKString.Create(metadata.Author)) using (var subject = SKString.Create(metadata.Subject)) using (var keywords = SKString.Create(metadata.Keywords)) using (var creator = SKString.Create(metadata.Creator)) using (var producer = SKString.Create(metadata.Producer)) { var cmetadata = new SKDocumentPdfMetadataInternal { Title = title?.Handle ?? IntPtr.Zero, Author = author?.Handle ?? IntPtr.Zero, Subject = subject?.Handle ?? IntPtr.Zero, Keywords = keywords?.Handle ?? IntPtr.Zero, Creator = creator?.Handle ?? IntPtr.Zero, Producer = producer?.Handle ?? IntPtr.Zero }; if (metadata.Creation != null) { var creation = SKTimeDateTimeInternal.Create(metadata.Creation.Value); cmetadata.Creation = &creation; } if (metadata.Modified != null) { var modified = SKTimeDateTimeInternal.Create(metadata.Modified.Value); cmetadata.Modified = &modified; } return(GetObject <SKDocument> (SkiaApi.sk_document_create_pdf_from_stream_with_metadata(stream.Handle, dpi, ref cmetadata))); } }
public bool Encode(SKWStream dst, SKEncodedImageFormat format, int quality) { using (new SKAutoLockPixels(this)) using (var pixmap = new SKPixmap()) { return(PeekPixels(pixmap) && pixmap.Encode(dst, format, quality)); } }
public bool CopyTo(SKWStream dst) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } return(SkiaApi.sk_dynamicmemorywstream_write_to_stream(Handle, dst.Handle)); }
public static SKDocument CreatePdf (SKWStream stream, float dpi = DefaultRasterDpi) { if (stream == null) { throw new ArgumentNullException (nameof(stream)); } return GetObject<SKDocument> (SkiaApi.sk_document_create_pdf_from_stream(stream.Handle, dpi)); }
public static SKDocument CreatePdf(SKWStream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } return(Referenced(GetObject(SkiaApi.sk_document_create_pdf_from_stream(stream.Handle)), stream)); }
public bool Encode(SKWStream dst, SKEncodedImageFormat encoder, int quality) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } return(SkiaApi.sk_pixmap_encode_image(dst.Handle, Handle, encoder, quality)); }
public static SKDocument CreatePdf(SKWStream stream, float dpi = DefaultRasterDpi) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } return(GetObject <SKDocument> (SkiaApi.sk_document_create_pdf_from_stream(stream.Handle, dpi))); }
public bool Encode(SKWStream dst, SKPngEncoderOptions options) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } return(SkiaApi.sk_pngencoder_encode(dst.Handle, Handle, &options)); }
public void Serialize(SKWStream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } SkiaApi.sk_picture_serialize_to_stream(Handle, stream.Handle); }
public static SKDocument CreateXps(SKWStream stream, float dpi) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } return(Referenced(GetObject <SKDocument> (SkiaApi.sk_document_create_xps_from_stream(stream.Handle, dpi)), stream)); }
private static SKDocument Referenced(SKDocument doc, SKWStream stream) { if (stream != null && doc != null) { doc.underlyingStream = stream; } return(doc); }
public static SKCanvas Create(SKRect bounds, SKWStream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } return(SKObject.Referenced(SKCanvas.GetObject(SkiaApi.sk_svgcanvas_create_with_stream(&bounds, stream.Handle)), stream)); }
public SKXmlStreamWriter(SKWStream stream) : this(IntPtr.Zero, true) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } Handle = SkiaApi.sk_xmlstreamwriter_new(stream.Handle); }
public bool Encode(SKWStream dst, SKEncodedImageFormat format, int quality) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } using var pixmap = PeekPixels(); return(pixmap?.Encode(dst, format, quality) ?? false); }
public static bool Encode(SKWStream dst, SKPixmap src, SKPngEncoderOptions options) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (src == null) { throw new ArgumentNullException(nameof(src)); } return(src.Encode(dst, options)); }
public static bool Encode(SKWStream dst, SKPixmap src, SKPngEncoderOptions options) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (src == null) { throw new ArgumentNullException(nameof(src)); } return(SkiaApi.sk_pngencoder_encode(dst.Handle, src.Handle, options)); }
public static bool Encode(SKWStream dst, SKPixmap src, SKEncodedImageFormat encoder, int quality) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (src == null) { throw new ArgumentNullException(nameof(src)); } return(src.Encode(dst, encoder, quality)); }
public static SKCanvas Create(SKRect bounds, SKWStream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } // TODO: there seems to be a memory issue with things getting destroyed in the incorrect order //return SKObject.Referenced (SKObject.GetObject<SKCanvas> (SkiaApi.sk_svgcanvas_create_with_stream (&bounds, stream.Handle)), stream); var writer = new SKXmlStreamWriter(stream); return(SKObject.Owned(SKCanvas.GetObject(SkiaApi.sk_svgcanvas_create_with_writer(&bounds, writer.Handle)), writer)); }
public static bool Encode(SKWStream dst, SKBitmap src, SKEncodedImageFormat format, int quality) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (src == null) { throw new ArgumentNullException(nameof(src)); } using (var pixmap = new SKPixmap()) { return(src.PeekPixels(pixmap) && Encode(dst, pixmap, format, quality)); } }
private static SKDocument Owned(SKDocument doc, SKWStream stream) { if (stream != null) { if (doc != null) { doc.SetDisposeChild(stream); } else { stream.Dispose(); } } return(doc); }
public int CopyTo(SKWStream destination) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } var total = 0; int len; using var buffer = Utils.RentArray <byte> (SKData.CopyBufferSize); while ((len = stream.Read((byte[])buffer, 0, buffer.Length)) > 0) { destination.Write((byte[])buffer, len); total += len; } destination.Flush(); return(total); }
public static SKDocument CreatePdf(SKWStream stream, SKDocumentPdfMetadata metadata) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } using (var title = SKString.Create(metadata.Title)) using (var author = SKString.Create(metadata.Author)) using (var subject = SKString.Create(metadata.Subject)) using (var keywords = SKString.Create(metadata.Keywords)) using (var creator = SKString.Create(metadata.Creator)) using (var producer = SKString.Create(metadata.Producer)) { var cmetadata = new SKDocumentPdfMetadataInternal { fTitle = title?.Handle ?? IntPtr.Zero, fAuthor = author?.Handle ?? IntPtr.Zero, fSubject = subject?.Handle ?? IntPtr.Zero, fKeywords = keywords?.Handle ?? IntPtr.Zero, fCreator = creator?.Handle ?? IntPtr.Zero, fProducer = producer?.Handle ?? IntPtr.Zero, fRasterDPI = metadata.RasterDpi, fPDFA = metadata.PdfA ? (byte)1 : (byte)0, fEncodingQuality = metadata.EncodingQuality, }; SKTimeDateTimeInternal creation; if (metadata.Creation != null) { creation = SKTimeDateTimeInternal.Create(metadata.Creation.Value); cmetadata.fCreation = &creation; } SKTimeDateTimeInternal modified; if (metadata.Modified != null) { modified = SKTimeDateTimeInternal.Create(metadata.Modified.Value); cmetadata.fModified = &modified; } return(Referenced(GetObject <SKDocument> (SkiaApi.sk_document_create_pdf_from_stream_with_metadata(stream.Handle, &cmetadata)), stream)); } }
public int CopyTo(SKWStream destination) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } var total = 0; int len; var buffer = ArrayPool <byte> .Shared.Rent(SKData.CopyBufferSize); try { while ((len = stream.Read(buffer, 0, buffer.Length)) > 0) { destination.Write(buffer, len); total += len; } } finally { ArrayPool <byte> .Shared.Return(buffer); } destination.Flush(); return(total); }
public bool Encode(SKWStream dst, SKEncodedImageFormat format, int quality) { return(SKPixmap.Encode(dst, this, format, quality)); }
public static SKDocument CreatePdf(SKWStream stream, SKDocumentPdfMetadata metadata, float dpi) { metadata.RasterDpi = dpi; return(CreatePdf(stream, metadata)); }
public static SKDocument CreateXps(SKWStream stream) => CreateXps(stream, DefaultRasterDpi);
public static SKDocument CreatePdf(SKWStream stream, float dpi) => CreatePdf(stream, new SKDocumentPdfMetadata(dpi));
public bool Encode(SKWStream dst, SKEncodedImageFormat encoder, int quality) { return(Encode(dst, this, encoder, quality)); }
public bool Encode(SKWStream dst, SKPngEncoderOptions options) { return(Encode(dst, this, options)); }
public static SKDocument CreatePdf(SKWStream stream, float dpi) { return(CreatePdf(stream)); }