From d61c7d2c9ea7af6703d6fc7d71a1903e0ced55ac Mon Sep 17 00:00:00 2001 From: asterixorobelix Date: Fri, 29 Dec 2017 14:52:27 +0200 Subject: [PATCH] I have just started using imagesharp and I imagine that many of my questions regarding the package will be asked by others. So, I have begun a Q&A page --- Questions-and-Answers.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Questions-and-Answers.md diff --git a/Questions-and-Answers.md b/Questions-and-Answers.md new file mode 100644 index 0000000..6e77acd --- /dev/null +++ b/Questions-and-Answers.md @@ -0,0 +1,32 @@ +## 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? +` +using (Image image =Image.Load($"{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? +` +using (Image image = Image.Load($"{filename}.png")) + { + image.Mutate(x=>x.BlackWhite()); + image.Save($"{filename}blackWhite.png"); + } +` +## How do I access the individual pixels of an image? + +` +using (Image image = Image.Load($"{filename}.png")) + { + var imageHeight = image.Height;//pixel height + var imageWidth = image.Width; + var pixels =image[200,200];//<1  1  1  1> + var pixels2 = image[125, 180];//<0.7647059  0.7647059  0.7647059  1> + } +` \ No newline at end of file