-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
206 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,63 @@ | ||
using System; | ||
namespace Plugin.ImageEdit.Abstractions | ||
{ | ||
/// <summary> | ||
/// Interface for EditableImage | ||
/// </summary> | ||
public interface IEditableImage:IDisposable | ||
{ | ||
/// <summary> | ||
/// Image Width | ||
/// </summary> | ||
int Width { get; } | ||
|
||
/// <summary> | ||
/// Image Height | ||
/// </summary> | ||
int Height { get; } | ||
|
||
/// <summary> | ||
/// Resize | ||
/// </summary> | ||
/// <returns>IEditableImage</returns> | ||
/// <param name="width">resize width. 0 is adjust to aspect ratio.</param> | ||
/// <param name="height">resize height. 0 is adjust to aspect ratio.</param> | ||
IEditableImage Resize(int width, int height); | ||
|
||
/// <summary> | ||
/// Crop | ||
/// </summary> | ||
/// <returns>IEditableImage</returns> | ||
/// <param name="x">start x</param> | ||
/// <param name="y">start y</param> | ||
/// <param name="width">crop width</param> | ||
/// <param name="height">crop height</param> | ||
IEditableImage Crop(int x, int y, int width, int height); | ||
|
||
/// <summary> | ||
/// Rotate | ||
/// </summary> | ||
/// <returns>IEditableImage</returns> | ||
/// <param name="degree">degree(0-360)</param> | ||
IEditableImage Rotate(float degree); | ||
|
||
/// <summary> | ||
/// To Jpeg byte array | ||
/// </summary> | ||
/// <returns>byte[]</returns> | ||
/// <param name="quality">quality(1-100)</param> | ||
byte[] ToJpeg(float quality = 80); | ||
|
||
/// <summary> | ||
/// To PNG byte array | ||
/// </summary> | ||
/// <returns>byte[]</returns> | ||
byte[] ToPng(); | ||
|
||
/// <summary> | ||
/// image pixels array. order by ARGB. 0xFF(A)FF(R)FF(G)FF(B) | ||
/// </summary> | ||
/// <returns>The ARGB pixels.</returns> | ||
int[] ToArgbPixels(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters