diff --git a/ImageEdit/Plugin.ImageEdit.Abstractions/IEditableImage.cs b/ImageEdit/Plugin.ImageEdit.Abstractions/IEditableImage.cs index cb9d691..a3995a5 100644 --- a/ImageEdit/Plugin.ImageEdit.Abstractions/IEditableImage.cs +++ b/ImageEdit/Plugin.ImageEdit.Abstractions/IEditableImage.cs @@ -1,15 +1,63 @@ using System; namespace Plugin.ImageEdit.Abstractions { + /// + /// Interface for EditableImage + /// public interface IEditableImage:IDisposable { + /// + /// Image Width + /// int Width { get; } + + /// + /// Image Height + /// int Height { get; } + + /// + /// Resize + /// + /// IEditableImage + /// resize width. 0 is adjust to aspect ratio. + /// resize height. 0 is adjust to aspect ratio. IEditableImage Resize(int width, int height); + + /// + /// Crop + /// + /// IEditableImage + /// start x + /// start y + /// crop width + /// crop height IEditableImage Crop(int x, int y, int width, int height); + + /// + /// Rotate + /// + /// IEditableImage + /// degree(0-360) IEditableImage Rotate(float degree); + + /// + /// To Jpeg byte array + /// + /// byte[] + /// quality(1-100) byte[] ToJpeg(float quality = 80); + + /// + /// To PNG byte array + /// + /// byte[] byte[] ToPng(); + + /// + /// image pixels array. order by ARGB. 0xFF(A)FF(R)FF(G)FF(B) + /// + /// The ARGB pixels. int[] ToArgbPixels(); } } diff --git a/ImageEdit/Plugin.ImageEdit.Abstractions/IImageEdit.cs b/ImageEdit/Plugin.ImageEdit.Abstractions/IImageEdit.cs index 80c9b50..e3e647d 100755 --- a/ImageEdit/Plugin.ImageEdit.Abstractions/IImageEdit.cs +++ b/ImageEdit/Plugin.ImageEdit.Abstractions/IImageEdit.cs @@ -7,8 +7,19 @@ namespace Plugin.ImageEdit.Abstractions /// Interface for ImageEdit /// public interface IImageEdit - { + { + /// + /// Create editable image + /// + /// IEditableImage + /// image byte array IEditableImage CreateImage(byte[] imageArray); + + /// + /// Create editable image (async) + /// + /// IEditableImage + /// image byte array Task CreateImageAsync(byte[] imageArray); } } diff --git a/ImageEdit/Plugin.ImageEdit.Android/Plugin.ImageEdit.Android.csproj b/ImageEdit/Plugin.ImageEdit.Android/Plugin.ImageEdit.Android.csproj index 0c458b8..d93efa1 100644 --- a/ImageEdit/Plugin.ImageEdit.Android/Plugin.ImageEdit.Android.csproj +++ b/ImageEdit/Plugin.ImageEdit.Android/Plugin.ImageEdit.Android.csproj @@ -30,13 +30,14 @@ 4 - pdbonly + true bin\Release\ TRACE prompt 4 bin\Release\Plugin.ImageEdit.XML + 1591 diff --git a/ImageEdit/Plugin.ImageEdit.iOS/Plugin.ImageEdit.iOS.csproj b/ImageEdit/Plugin.ImageEdit.iOS/Plugin.ImageEdit.iOS.csproj index bd60a08..2f8720d 100644 --- a/ImageEdit/Plugin.ImageEdit.iOS/Plugin.ImageEdit.iOS.csproj +++ b/ImageEdit/Plugin.ImageEdit.iOS/Plugin.ImageEdit.iOS.csproj @@ -33,6 +33,7 @@ false iPhone Developer bin\iPhone\Release\Plugin.ImageEdit.XML + 1591 diff --git a/ImageEdit/Plugin.ImageEdit/Plugin.ImageEdit.csproj b/ImageEdit/Plugin.ImageEdit/Plugin.ImageEdit.csproj old mode 100755 new mode 100644 index 17dfdc0..fe2aad5 --- a/ImageEdit/Plugin.ImageEdit/Plugin.ImageEdit.csproj +++ b/ImageEdit/Plugin.ImageEdit/Plugin.ImageEdit.csproj @@ -26,6 +26,7 @@ 4 + true pdbonly true bin\Release\ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..e0806ac --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 kamu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9544d46 --- /dev/null +++ b/README.md @@ -0,0 +1,103 @@ +# Image Edit Plugin for Xamarin + +This plugin will enable you to manipulate(resize,crop,rotate) a image(png,jpg). + +### Setup + +* Available on NuGet: https://www.nuget.org/packages/Xamarin.Plugin.ImageEdit/ +* Install into your PCL project and Client projects. + +```bash +Install-Package Xamarin.Plugin.ImageEdit -Pre +``` + +**Platform Support** + +|Platform|Supported|Version| +| ------------------- | :-----------: | :------------------: | +|Xamarin.iOS|Yes|iOS 9+| +|Xamarin.Android|Yes|API 22+| +|Windows 10 UWP|No|| +|Xamarin.Mac|No|| + +## Usage example + +Image crop and resize and rotate and get png data. + +```cs +using (var image = await CrossImageEdit.Current.CreateImageAsync(imageByteArray)) { + var croped = await Task.Run(() => + image.Crop(10, 20, 250, 100) + .Rotate(180) + .Resize(100, 0) + .ToPng() + ); +} +``` + +## API Usage + +### Get EditableImage + +```cs +var image = await CrossImageEdit.Current.CreateImageAsync(imageByteArray); +``` +It is able to manipulate a image using this object. + +### Resize + +```cs +var width = 200; +var height = 200; +image.Resize(width, height); +image.Resize(width, 0); //auto height +image.Resize(0, height); //auto width +``` + +### Crop + +```cs +var x = 10; +var y = 10; +var width = 50; +var height = 50; +image.Crop(10, 10, 50, 50); +``` + +### Rotate + +```cs +var degree = 90; // 0-360; +image.Rotate(degree); +``` + +### ToPng + +```cs +var pngBytes = image.ToPng(); +``` + +### ToJpeg + +```cs +var jpgBytes = image.ToJpeg(90); // quality(0-100) +``` + +### ToArgbPixels + +Get image ARGB infomation. + +for example when 0xFF00F090 + +|A|R|G|B| +| -- | :---: | :--: | :--: | +|FF|00|F0 |90| + + +```cs +var pixels = image.ToArgbPixels(); +``` + +## License + +MIT Licensed. diff --git a/nuget/ImageEdit.Plugin.nuspec b/nuget/ImageEdit.Plugin.nuspec index df1e501..b0c0351 100755 --- a/nuget/ImageEdit.Plugin.nuspec +++ b/nuget/ImageEdit.Plugin.nuspec @@ -1,13 +1,13 @@ - + Xamarin.Plugin.ImageEdit - 0.0.1 + 0.0.1-pre Image Edit Plugin for Xamarin kamu kamu - - + https://github.com/muak/Xamarin.Plugin.ImageEdit/blob/master/LICENSE.txt + https://github.com/muak/Xamarin.Plugin.ImageEdit https://raw.githubusercontent.com/jamesmontemagno/Xamarin-Templates/master/Plugins-Templates/icons/plugin_icon_nuget.png @@ -46,50 +46,51 @@ - + - + - + - + - + - + - + - + @@ -97,13 +98,14 @@ - +