mirror of https://github.com/SixLabors/ImageSharp
1 changed files with 0 additions and 34 deletions
@ -1,34 +0,0 @@ |
|||||
## Have I installed the correct Nuget package? |
|
||||
|
|
||||
See: https://github.com/SixLabors/ImageSharp/issues/418 |
|
||||
|
|
||||
## How do I convert a JPG to a PNG image? |
|
||||
```cs |
|
||||
using (Image<Rgba32> image =Image.Load<Rgba32>($"{filename}.jpg")) |
|
||||
{ |
|
||||
image.Save($"{filename}.png"); |
|
||||
} |
|
||||
``` |
|
||||
ImageSharp will automatically choose the encoding based on the file extension used in the filename (eg .jpg or .png) |
|
||||
|
|
||||
## How do I convert an image to black and white? |
|
||||
```cs |
|
||||
using (Image<Rgba32> image = Image.Load<Rgba32>($"{filename}.png")) |
|
||||
{ |
|
||||
image.Mutate(x=>x.BlackWhite()); |
|
||||
image.Save($"{filename}blackWhite.png"); |
|
||||
} |
|
||||
``` |
|
||||
## How do I access the individual pixels of an image? |
|
||||
|
|
||||
```cs |
|
||||
using (Image<Rgba32> image = Image.Load($"{filename}.png")) |
|
||||
{ |
|
||||
var imageHeight = image.Height;//height of image in pixels |
|
||||
var imageWidth = image.Width; |
|
||||
var pixel1 =image[200,200];//the pixel variable contains: <1 1 1 1> |
|
||||
var pixel2 =image[0,0]; //means top left pixel (pixels are zero indexed). Exceeding the bounds of the image would yield an exception |
|
||||
//Which are normalized values (a 0-1 float, instead of 0-255),the 4 values represent "Red Green Blue Alpha" in 32 bits, because Rgba32 was chosen. |
|
||||
var pixels2 = image[125, 180];//<0.7647059 0.7647059 0.7647059 1> |
|
||||
} |
|
||||
``` |
|
||||
Loading…
Reference in new issue