Inheritance: SKObject
示例#1
0
        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)));
                                }
        }
示例#2
0
 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));
         }
 }
示例#3
0
 public bool CopyTo(SKWStream dst)
 {
     if (dst == null)
     {
         throw new ArgumentNullException(nameof(dst));
     }
     return(SkiaApi.sk_dynamicmemorywstream_write_to_stream(Handle, dst.Handle));
 }
示例#4
0
		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));
		}
示例#5
0
        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));
        }
示例#6
0
        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));
        }
示例#7
0
        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)));
        }
示例#8
0
        public bool Encode(SKWStream dst, SKPngEncoderOptions options)
        {
            if (dst == null)
            {
                throw new ArgumentNullException(nameof(dst));
            }

            return(SkiaApi.sk_pngencoder_encode(dst.Handle, Handle, &options));
        }
示例#9
0
        public void Serialize(SKWStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            SkiaApi.sk_picture_serialize_to_stream(Handle, stream.Handle);
        }
示例#10
0
        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));
        }
示例#11
0
        private static SKDocument Referenced(SKDocument doc, SKWStream stream)
        {
            if (stream != null && doc != null)
            {
                doc.underlyingStream = stream;
            }

            return(doc);
        }
示例#12
0
        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));
        }
示例#13
0
        public SKXmlStreamWriter(SKWStream stream)
            : this(IntPtr.Zero, true)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            Handle = SkiaApi.sk_xmlstreamwriter_new(stream.Handle);
        }
示例#14
0
        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);
        }
示例#15
0
        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));
        }
示例#16
0
        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));
        }
示例#17
0
        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));
        }
示例#18
0
        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));
        }
示例#19
0
        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));
            }
        }
示例#20
0
        private static SKDocument Owned(SKDocument doc, SKWStream stream)
        {
            if (stream != null)
            {
                if (doc != null)
                {
                    doc.SetDisposeChild(stream);
                }
                else
                {
                    stream.Dispose();
                }
            }

            return(doc);
        }
示例#21
0
        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);
        }
示例#22
0
        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));
                                }
        }
示例#23
0
        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);
        }
示例#24
0
 public bool Encode(SKWStream dst, SKEncodedImageFormat format, int quality)
 {
     return(SKPixmap.Encode(dst, this, format, quality));
 }
示例#25
0
 public static SKDocument CreatePdf(SKWStream stream, SKDocumentPdfMetadata metadata, float dpi)
 {
     metadata.RasterDpi = dpi;
     return(CreatePdf(stream, metadata));
 }
示例#26
0
 public static SKDocument CreateXps(SKWStream stream) =>
 CreateXps(stream, DefaultRasterDpi);
示例#27
0
 public static SKDocument CreatePdf(SKWStream stream, float dpi) =>
 CreatePdf(stream, new SKDocumentPdfMetadata(dpi));
示例#28
0
 public bool Encode(SKWStream dst, SKEncodedImageFormat encoder, int quality)
 {
     return(Encode(dst, this, encoder, quality));
 }
示例#29
0
 public bool Encode(SKWStream dst, SKPngEncoderOptions options)
 {
     return(Encode(dst, this, options));
 }
示例#30
0
 public static SKDocument CreatePdf(SKWStream stream, float dpi)
 {
     return(CreatePdf(stream));
 }