Bodoconsult.Core.Drawing

Logo Bodoconsult EDV-Dienstleistungen GmbH

Bodoconsult.Core.Drawing

Autor: Bodoconsult EDV-Dienstleistungen GmbH Robert Leisner

Nuget package

https://www.nuget.org/packages/Bodoconsult.Core.Drawing/

Github repository

https://github.com/RobertLeisner/Bodoconsult.Core.Drawing

About the library Bodoconsult.Core.Drawing

What does the library

Bodoconsult.Core.Drawing library is a simple library based on System.Drawing for essential image manipulation like resizing, adjusting brightness, contrast or gamma and saturation.

How to use the library

The source code contain NUnit test classes, the following source code is extracted from. The samples below show the most helpful use cases for the library.

Using class ImageTools

Reduce a image to a new size if the current file sizes is to big
		var fi = new FileInfo(@"C:\test\test.jpg");

		var maxImageSize = 1000000; // byte

		var maxPicWidth = 800; // pixel
		var maxPicWidth = 800; // pixel

		ImageTools.GenerateWebImage(fi, maxImageSize, maxPicWidth, maxPicHeight);

Generate a thumbnail for an image
		var fi = new FileInfo(@"C:\test\test.jpg");
		
		var thumb = @"C:\test\test_t.jpg"

		var thumbWidth = 60;	// Thumbnail width
		var thumbHeight = 60;	// Thumbnail height

		ImageTools.GenerateThumb(fi, thumb, thumbWidth, thumbHeight);

Using class BitmapService

The class BitmapServices is intended to be use if you have to do more than one manipulation with one image.

Resize an image

		BitmapSevice _service;
		
		_service.LoadBitmap(source);
		
		_service.ResizeImage(400, 400);

		_service.SaveAsJpeg(target);

Adjust brightness, contrast or gamma

		var brightness = 1.4f;
		var contrast = 0.8f;
		var gamma = 1f;

		BitmapSevice _service;
		
		_service.LoadBitmap(source);
		
		_service.AdjustBcg(brightness, contrast, gamma);

		_service.SaveAsJpeg(target);
		
Adjust saturation

		var saturation = -1F;

		BitmapSevice _service;
		
		_service.LoadBitmap(source);
		
		_service.AdjustSaturation(saturation);

		_service.SaveAsJpeg(target);

Combining two or more manipulations

		var saturation = -1F;
		var brightness = 1.4f;
		var contrast = 0.8f;
		var gamma = 1f;
		
		BitmapSevice _service;
		
		_service.LoadBitmap(source);
		
		_service.AdjustBcg(brightness, contrast, gamma);
		_service.AdjustSaturation(saturation);

		_service.SaveAsJpeg(target);

Using class OpenGraphHelper

OpenGraphHelper helps creating OpenGraph images for websites automatically.


			// Load master file once
            OpenGraphHelper.SourceFile = Path.Combine(TestHelper.GetTestDataFolder(), "OpenGraphBasis.png");

            // Act 1
            OpenGraphHelper.Save("Page 1", "Anything to write", @C:\Test\test1.png");

            // Act 2
            OpenGraphHelper.Save("Page 2", "Test description", @C:\Test\test2.png");

About us

Bodoconsult (http://www.bodoconsult.de) is a Munich based software development company from Germany.

Robert Leisner is senior software developer at Bodoconsult. See his profile on http://www.bodoconsult.de/Curriculum_vitae_Robert_Leisner.pdf.

Licence for the library Bodoconsult.Core.Drawing

The MIT License (MIT)

Copyright (c) Bodoconsult EDV-Dienstleistungen GmbH

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.

Licences for libraries used by Bodoconsult.Core.Drawing

System.Drawing.Common by Microsoft Corporation

MIT License

Copyright (c) _____

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.

Url: https://www.nuget.org/packages/System.Drawing.Common

Licence: https://licenses.nuget.org/MIT