<commit_before>﻿//
// Bindings for SKImage
//
// Author:
//   <NAME>
//
// Copyright 2016 Xamarin Inc
//
using System;

namespace SkiaSharp
{
	public class SKImage : SKObject
	{
		protected override void Dispose (bool disposing)
		{
			if (Handle != IntPtr.Zero) {
				SkiaApi.sk_image_unref (Handle);
			}

			base.Dispose (disposing);
		}

		[Preserve]
		internal SKImage (IntPtr x)
			: base (x)
		{
		}
		
		public static SKImage FromPixels (SKImageInfo info, IntPtr pixels, int rowBytes)
		{
			var handle = SkiaApi.sk_image_new_raster_copy (ref info, pixels, (IntPtr) rowBytes);
			if (handle == IntPtr.Zero)
				return null;
			return new SKImage (handle);
		}

		public static SKImage FromData (SKData data, SKRectI subset)
		{
			if (data == null)
				throw new ArgumentNullException ("data");
			
			var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, ref subset);
			if (handle == IntPtr.Zero)
				return null;
			return new SKImage (handle);
		}

		public SKData Encode ()
		{
			return new SKData (SkiaApi.sk_image_encode (Handle));
		}

		public int Width => SkiaApi.sk_image_get_width (Handle);
		public int Height => SkiaApi.sk_image_get_height (Handle); 
		public uint UniqueId => SkiaApi.sk_image_get_unique_id (Handle);
	}<commit_msg>[SKImage] Fixes github issue 10, missing FromData API that does not take a region<commit_after>﻿//
// Bindings for SKImage
//
// Author:
//   <NAME>
//
// Copyright 2016 Xamarin Inc
//
using System;

namespace SkiaSharp
{
	public class SKImage : SKObject
	{
		protected override void Dispose (bool disposing)
		{
			if (Handle != IntPtr.Zero) {
				SkiaApi.sk_image_unref (Handle);
			}

			base.Dispose (disposing);
		}

		[Preserve]
		internal SKImage (IntPtr x)
			: base (x)
		{
		}
		
		public static SKImage FromPixels (SKImageInfo info, IntPtr pixels, int rowBytes)
		{
			var handle = SkiaApi.sk_image_new_raster_copy (ref info, pixels, (IntPtr) rowBytes);
			if (handle == IntPtr.Zero)
				return null;
			return new SKImage (handle);
		}

		public static SKImage FromData (SKData data, SKRectI subset)
		{
			if (data == null)
				throw new ArgumentNullException ("data");
			
			var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, ref subset);
			if (handle == IntPtr.Zero)
				return null;
			return new SKImage (handle);
		}

		public static SKImage FromData (SKData data)
		{
			if (data == null)
				throw new ArgumentNullException ("data");
			
			var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, IntPtr.Zero);
			if (handle == IntPtr.Zero)
				return null;
			return new SKImage (handle);
		}

		public SKData Encode ()
		{
			return new SKData (SkiaApi.sk_image_encode (Handle));
		}

		public int Width => SkiaApi.sk_image_get_width (Handle);
		public int Height => SkiaApi.sk_image_get_height (Handle); 
		public uint UniqueId => SkiaApi.sk_image_get_unique_id (Handle);
	}
{'fraction_non_alphanumeric': 0.10744089012517385, 'fraction_numerical': 0.0034770514603616135, 'mean_word_length': 3.3789954337899544, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1175690', 'n_tokens_mistral': 1147, 'n_tokens_neox': 972, 'n_words': 276}