コード例 #1
1
ファイル: SKBitmap.cs プロジェクト: prepare/HTML-Renderer
		public SKBitmap (SKImageInfo info, SKColorTable ctable)
			: this ()
		{
			if (!SkiaApi.sk_bitmap_try_alloc_pixels_with_color_table (Handle, ref info, IntPtr.Zero, ctable != null ? ctable.Handle : IntPtr.Zero)) {
				throw new Exception (UnableToAllocatePixelsMessage);
			}
		}
コード例 #2
0
        public static SKBitmap Decode(SKCodec codec, SKImageInfo bitmapInfo)
        {
            if (codec == null)
            {
                throw new ArgumentNullException(nameof(codec));
            }

            // construct a color table for the decode if necessary
            SKColorTable colorTable = null;
            int          colorCount = 0;

            if (bitmapInfo.ColorType == SKColorType.Index8)
            {
                colorTable = new SKColorTable();
            }

            // read the pixels and color table
            var    bitmap = new SKBitmap(bitmapInfo, colorTable);
            IntPtr length;
            var    result = codec.GetPixels(bitmapInfo, bitmap.GetPixels(out length), colorTable, ref colorCount);

            if (result != SKCodecResult.Success && result != SKCodecResult.IncompleteInput)
            {
                bitmap.Dispose();
                bitmap = null;
            }
            return(bitmap);
        }
コード例 #3
0
ファイル: SKBitmap.cs プロジェクト: vecalion/SkiaSharp
        public static SKBitmap Decode(SKCodec codec)
        {
            var info = codec.Info;

            // construct a color table for the decode if necessary
            SKColorTable colorTable = null;
            int          colorCount = 0;

            if (info.ColorType == SKColorType.Index8)
            {
                colorTable = new SKColorTable();
            }

            // read the pixels and color table
            var    bitmap = new SKBitmap(info, colorTable);
            IntPtr length;
            var    result = codec.GetPixels(info, bitmap.GetPixels(out length), colorTable, ref colorCount);

            if (result != SKCodecResult.Success && result != SKCodecResult.IncompleteInput)
            {
                bitmap.Dispose();
                bitmap = null;
            }
            return(bitmap);
        }
コード例 #4
0
 public SKPixmap(SKImageInfo info, IntPtr addr, int rowBytes, SKColorTable ctable = null)
     : this(SkiaApi.sk_pixmap_new_with_params(ref info, addr, (IntPtr)rowBytes, ctable == null ? IntPtr.Zero : ctable.Handle), true)
 {
     if (Handle == IntPtr.Zero)
     {
         throw new InvalidOperationException(UnableToCreateInstanceMessage);
     }
 }
コード例 #5
0
 public SKBitmap(SKImageInfo info, SKColorTable ctable, SKBitmapAllocFlags flags)
     : this()
 {
     if (!TryAllocPixels(info, ctable, flags))
     {
         throw new Exception(UnableToAllocatePixelsMessage);
     }
 }
コード例 #6
0
 public SKBitmap(SKImageInfo info, SKColorTable ctable)
     : this()
 {
     if (!SkiaApi.sk_bitmap_try_alloc_pixels_with_color_table(Handle, ref info, IntPtr.Zero, ctable != null ? ctable.Handle : IntPtr.Zero))
     {
         throw new Exception(UnableToAllocatePixelsMessage);
     }
 }
コード例 #7
0
        public SKBitmap(SKImageInfo info, SKColorTable ctable, SKBitmapAllocFlags flags)
            : this()
        {
            var cinfo = SKImageInfoNative.FromManaged(ref info);

            if (!SkiaApi.sk_bitmap_try_alloc_pixels_with_color_table(Handle, ref cinfo, ctable != null ? ctable.Handle : IntPtr.Zero, flags))
            {
                throw new Exception(UnableToAllocatePixelsMessage);
            }
        }
コード例 #8
0
        public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context)
        {
            IntPtr ct = ctable == null ? IntPtr.Zero : ctable.Handle;

            if (releaseProc == null)
            {
                return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, IntPtr.Zero, IntPtr.Zero));
            }
            else
            {
                var ctx = new NativeDelegateContext(context, releaseProc);
                return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, releaseDelegate, ctx.NativeContext));
            }
        }
コード例 #9
0
ファイル: SKBitmap.cs プロジェクト: luislasonbra/PixelFarm
        public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context)
        {
            IntPtr ct = ctable == null ? IntPtr.Zero : ctable.Handle;

            if (releaseProc == null)
            {
                return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, IntPtr.Zero, IntPtr.Zero));
            }
            else
            {
                var del = Marshal.GetFunctionPointerForDelegate(releaseDelegate);

                var ctx    = new SKBitmapReleaseDelegateContext(releaseProc, context);
                var ctxPtr = ctx.Wrap();

                return(SkiaApi.sk_bitmap_install_pixels(Handle, ref info, pixels, (IntPtr)rowBytes, ct, del, ctxPtr));
            }
        }
コード例 #10
0
 public void SetColorTable(SKColorTable ct)
 {
     // no-op due to unsupperted action
 }
コード例 #11
0
 public SKBitmap(SKImageInfo info, SKColorTable ctable)
     : this(info, SKBitmapAllocFlags.None)
 {
 }
コード例 #12
0
 public void SetPixels(IntPtr pixels, SKColorTable ct)
 {
     SetPixels(pixels);
 }
コード例 #13
0
ファイル: SKCodec.cs プロジェクト: prepare/HTML-Renderer
		public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, SKColorTable colorTable, ref int colorTableCount)
		{
			return GetPixels (info, pixels, info.RowBytes, SKCodecOptions.Default, colorTable, ref colorTableCount);
		}
コード例 #14
0
ファイル: SKBitmap.cs プロジェクト: prepare/HTML-Renderer
		public void SetPixels(IntPtr pixels, SKColorTable ct)
		{
			SkiaApi.sk_bitmap_set_pixels (Handle, pixels, ct != null ? ct.Handle : IntPtr.Zero);
		}
コード例 #15
0
ファイル: SKCodec.cs プロジェクト: prepare/HTML-Renderer
		public unsafe SKCodecResult StartIncrementalDecode(SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
		{
			return StartIncrementalDecode (info, pixels, rowBytes, options, colorTable == null ? IntPtr.Zero : colorTable.ReadColors (), ref colorTableCount);
		}
コード例 #16
0
 public void SetPixels(IntPtr pixels, SKColorTable ct)
 {
     SkiaApi.sk_bitmap_set_pixels(Handle, pixels, ct != null ? ct.Handle : IntPtr.Zero);
 }
コード例 #17
0
ファイル: SKImage.cs プロジェクト: mqp/SkiaSharp
        public static SKImage FromPixelCopy(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable)
        {
            if (pixels == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(pixels));
            }

            var ct     = (ctable == null ? IntPtr.Zero : ctable.Handle);
            var cinfo  = SKImageInfoNative.FromManaged(ref info);
            var handle = SkiaApi.sk_image_new_raster_copy_with_colortable(ref cinfo, pixels, (IntPtr)rowBytes, ct);

            return(GetObject <SKImage> (handle));
        }
コード例 #18
0
 public SKCodecResult GetPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
 {
     return(GetPixels(info, pixels, rowBytes, options, colorTable == null ? IntPtr.Zero : colorTable.ReadColors(), ref colorTableCount));
 }
コード例 #19
0
ファイル: SKBitmap.cs プロジェクト: prepare/HTML-Renderer
		public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context)
		{
			IntPtr ct = ctable == null ? IntPtr.Zero : ctable.Handle;
			if (releaseProc == null) {
				return SkiaApi.sk_bitmap_install_pixels (Handle, ref info, pixels, (IntPtr)rowBytes, ct, IntPtr.Zero, IntPtr.Zero);
			} else {
				var del = Marshal.GetFunctionPointerForDelegate (releaseDelegate);

				var ctx = new SKBitmapReleaseDelegateContext (releaseProc, context);
				var ctxPtr = ctx.Wrap ();

				return SkiaApi.sk_bitmap_install_pixels (Handle, ref info, pixels, (IntPtr)rowBytes, ct, del, ctxPtr);
			}
		}
コード例 #20
0
ファイル: SKPixmap.cs プロジェクト: thefurlong/SkiaSharp
 public SKPixmap(SKImageInfo info, IntPtr addr, int rowBytes, SKColorTable ctable)
     : this(info, addr, info.RowBytes)
 {
 }
コード例 #21
0
ファイル: SKBitmap.cs プロジェクト: prepare/HTML-Renderer
		public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable)
		{
			return InstallPixels (info, pixels, rowBytes, ctable, null, null);
		}
コード例 #22
0
ファイル: SKBitmap.cs プロジェクト: prepare/HTML-Renderer
		public static SKBitmap Decode (SKCodec codec, SKImageInfo bitmapInfo)
		{
			if (codec == null) {
				throw new ArgumentNullException (nameof (codec));
			}

			// construct a color table for the decode if necessary
			SKColorTable colorTable = null;
			int colorCount = 0;
			if (bitmapInfo.ColorType == SKColorType.Index8)
			{
				colorTable = new SKColorTable ();
			}

			// read the pixels and color table
			var bitmap = new SKBitmap (bitmapInfo, colorTable);
			IntPtr length;
			var result = codec.GetPixels (bitmapInfo, bitmap.GetPixels (out length), colorTable, ref colorCount);
			if (result != SKCodecResult.Success && result != SKCodecResult.IncompleteInput) {
				bitmap.Dispose ();
				bitmap = null;
			}
			return bitmap;
		}
コード例 #23
0
ファイル: SKBitmap.cs プロジェクト: prepare/HTML-Renderer
		public void SetColorTable(SKColorTable ct)
		{
			SetPixels (GetPixels (), ct);
		}
コード例 #24
0
 public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context)
 {
     return(InstallPixels(info, pixels, rowBytes, releaseProc, context));
 }
コード例 #25
0
 public unsafe SKCodecResult StartIncrementalDecode(SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
 {
     return(StartIncrementalDecode(info, pixels, rowBytes, options, colorTable == null ? IntPtr.Zero : colorTable.ReadColors(), ref colorTableCount));
 }
コード例 #26
0
 public SKCodecResult GetPixels(SKImageInfo info, IntPtr pixels, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount) =>
 GetPixels(info, pixels, info.RowBytes, options);
コード例 #27
0
ファイル: SKCodec.cs プロジェクト: prepare/HTML-Renderer
		public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
		{
			return GetPixels (info, pixels, rowBytes, options, colorTable == null ? IntPtr.Zero : colorTable.ReadColors (), ref colorTableCount);
		}
コード例 #28
0
ファイル: SKImage.cs プロジェクト: warappa/SkiaSharp
 public static SKImage FromPixelCopy(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable) =>
 FromPixelCopy(info, pixels, rowBytes);
コード例 #29
0
        private bool TryAllocPixels(SKImageInfo info, SKColorTable ctable, SKBitmapAllocFlags flags = SKBitmapAllocFlags.None)
        {
            var cinfo = SKImageInfoNative.FromManaged(ref info);

            return(SkiaApi.sk_bitmap_try_alloc_pixels_with_color_table(Handle, ref cinfo, ctable != null ? ctable.Handle : IntPtr.Zero, flags));
        }
コード例 #30
0
 public void SetColorTable(SKColorTable ct)
 {
     SetPixels(GetPixels(), ct);
 }
コード例 #31
0
 public void Reset(SKImageInfo info, IntPtr addr, int rowBytes, SKColorTable ctable = null)
 {
     SkiaApi.sk_pixmap_reset_with_params(Handle, ref info, addr, (IntPtr)rowBytes, ctable == null ? IntPtr.Zero : ctable.Handle);
 }
コード例 #32
0
 public bool InstallPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable)
 {
     return(InstallPixels(info, pixels, rowBytes, ctable, null, null));
 }
コード例 #33
0
ファイル: SKPixmap.cs プロジェクト: thefurlong/SkiaSharp
 public void Reset(SKImageInfo info, IntPtr addr, int rowBytes, SKColorTable ctable)
 {
     Reset(info, addr, rowBytes);
 }
コード例 #34
0
 public SKBitmap(SKImageInfo info, SKColorTable ctable)
     : this(info, ctable, 0)
 {
 }
コード例 #35
0
ファイル: SKCodec.cs プロジェクト: superowner/SkiaSharp
 public SKCodecResult GetPixels(SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
 {
     return(GetPixels(info, pixels, rowBytes, options));
 }
コード例 #36
0
 public SKCodecResult GetPixels(SKImageInfo info, IntPtr pixels, SKColorTable colorTable, ref int colorTableCount)
 {
     return(GetPixels(info, pixels, info.RowBytes, SKCodecOptions.Default, colorTable, ref colorTableCount));
 }
コード例 #37
0
ファイル: SKCodec.cs プロジェクト: superowner/SkiaSharp
 public SKCodecResult StartIncrementalDecode(SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
 {
     return(StartIncrementalDecode(info, pixels, rowBytes, options));
 }
コード例 #38
0
 public SKCodecResult StartScanlineDecode(SKImageInfo info, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
 {
     return(StartScanlineDecode(info, options, colorTable == null ? IntPtr.Zero : colorTable.ReadColors(), ref colorTableCount));
 }
コード例 #39
0
ファイル: SKCodec.cs プロジェクト: superowner/SkiaSharp
 public SKCodecResult StartScanlineDecode(SKImageInfo info, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
 {
     return(StartScanlineDecode(info, options));
 }