Code Monkey home page Code Monkey logo

netfx's Introduction

NETFx - C# Image Manipulation Library

Copyright (C) 2012 Asad Memon

MIT Licence

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.

NETFx

NetFx is a C# image manipulation library. This library makes it possible to clone Instagram effect in your own Apps. The library provides basic building blocks for advanced effects. Think of it as Instagram filters for .NET Developers. The library is heavily inspired by filtrr2 javascript library by Alex Michael.

Following effects have been implemented:

  • Brighten
  • Saturate
  • Gamma
  • Adjust Channels
  • Expose
  • Curves
  • Sharpen
  • Blur
  • Fill
  • Subtract
  • Sepia
  • Contrast
  • Posterize
  • Invert
  • Alpha
  • Vignette
  • Noise

The library also supports photoshop like layer blending modes:

  • Multiply
  • Screen
  • Overlay
  • Soft Light
  • Addition
  • Exclusion
  • Difference

===================================== ##Using NETFx

Set Up

  • You need to add five classes (effects.cs,layers.cs,Util.cs,Bitmap.cs,LockBitmap.cs) to your project in order to use NETFx. These classes are based on .NET 4.0 and are independant of any third party library.

  • After that, just declare an object of both effects 'class' and 'layers' class:

effects effects = new effects(); //contains all the basic effects 
layers layers = new layers(); //photoshop like layer implementation
  • You need to use my wrapper around the .net Bitmap when applying effects, you can use your old bitmap(if you really have to) like this:
Bitmap oldBMP = new Bitmap("megan.jpg"); //this is .NET Bitmap
BitmapW BetterBitmap = new BitmapW(oldBMP); //copy the old bitmap into this one.

Otherwise you can do the following too:

BitmapW BetterBitmap = new BitmapW("megan.jpg"); //load from file

Effects and Layers

  • After you have a bitmap and some objects ready to use, try some effects:
BitmapW a = new BitmapW("D:\megan.jpg"); //load an image
a = effects.sepia(a); //apply the effect
pictureBox1.Image = a.GetBitmap(); //show the resulting image
  • You can also merge two bitmaps with some blending options(like in photoshop):
BitmapW a = new BitmapW("D:\megan.jpg"); //load an image
BitmapW a = new BitmapW("D:\glow.jpg"); //load another image
a = layers.merge("softLight",a,b); //merge 'b' onto 'a' as soft light
pictureBox1.Image = a.GetBitmap(); //show the resulting image

Sample code in C#

effects effects = new effects(); //contains all the basic effects 
layers layers = new layers(); //photoshop like layer implementation

BitmapW a = new BitmapW("D:\megan.jpg"); //load an image
a = effects.sepia(a); //apply the effect
pictureBox1.Image = a.GetBitmap(); //show the resulting image

a more complex sample:

BitmapW a = new BitmapW(openFileDialog1.FileName); //load a bitmap

BitmapW layer1 = a.Clone(), layer2 = a.Clone(), layer3 = a.Clone(); //make three copies of the image l1,l2,l3
BitmapW res = a.Clone(); //this will hold the final result

layer3 = effects.fill(layer3, 167, 118, 12); //layer 3 is a solid fill of this rgb color

layer2 = effects.blur(layer2, "gaussian"); //layer2 is a blurred version of original image
layer1 = effects.saturate(layer1, -50); //layer1 is a saturated version


res = layers.merge("overlay", res, layer1); //merge layer1 onto original with "overlay" layer blending
res = layers.merge("softLight", res, layer2); //now merge layer2 onto this, with "softlight" layer blending
res = layers.merge("softLight", res, layer3); //now merge layer3 onto this, with "softlight" layer blending
res = effects.saturate(res,-40); //apply -40 saturate effect on this now
res = effects.contrast(res, 10); //apply 10 contrast 

pictureBox2.Image = res.GetBitmap(); //show the resulting image

=====================================

netfx's People

Contributors

asadm avatar lionroar avatar mkenfenheuer avatar rottweiler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netfx's Issues

Alpha not working

I'm trying to change the alpha of the top layer, but it just causes it not to render when using 'overlay' effect

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.