상속: SKObject
예제 #1
1
		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
        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
        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
		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
		public void SetPixels(IntPtr pixels, SKColorTable ct)
		{
			SkiaApi.sk_bitmap_set_pixels (Handle, pixels, ct != null ? ct.Handle : IntPtr.Zero);
		}
예제 #15
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);
		}
예제 #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
		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
 public SKPixmap(SKImageInfo info, IntPtr addr, int rowBytes, SKColorTable ctable)
     : this(info, addr, info.RowBytes)
 {
 }
예제 #21
0
		public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable)
		{
			return InstallPixels (info, pixels, rowBytes, ctable, null, null);
		}
예제 #22
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;
		}
예제 #23
0
		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
		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
 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
 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
 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
 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
 public SKCodecResult StartScanlineDecode(SKImageInfo info, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
 {
     return(StartScanlineDecode(info, options));
 }