Important alert: (current site time 5/18/2013 6:03:37 AM EDT)
 

VB icon

VB.NET Image Filters

Email
Submitted on: 11/7/2012 11:05:44 AM
By: Kris Alexander Bennett  
Level: Advanced
User Rating: By 2 Users
Compatibility: VB.NET
Views: 2672
author picture
 
     LINK: http://i00productions.org:80/downloader/default.aspx?DownloadFile=446F776E6C6F6164735C496D61676546696C746572735F32303132313031312E7A6970

Downloads

Total downloads:

Introduction

I have seen a few image filters written in VB, but most are poorly implemented, slow or just overly-complex. So I decided to create a simple class that contains a variety of filters and is easy to use.

Background

I originally created this class to render a drop shadow on a custom shaped tooltip that I created in my spell check. Somewhat bored over my break, I decided to expand on this class and it quickly grew into its own project.

Using the Code

Using the filters is as easy as going:

Using b As New Bitmap("c:\test.png")
 b.Filters.DropShadow(Color.Black, New Point(8, 8), 4)
 b.Save("c:\test.png", Imaging.ImageFormat.Png)
End Using

The above will open the file c:\test.png, apply the DropShadow filter, and re-saves the image over the original file.

More details on specific filters and their options are listed in the code section.


 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: VB.NET Image Filters
// Description:<B>LINK:</B> http://i00productions.org:80/downloader/default.aspx?DownloadFile=446F776E6C6F6164735C496D61676546696C746572735F32303132313031312E7A6970<br><br>
<h2>Downloads</h2>
<p>Total downloads: <img src="http://i00productions.org/downloader/?ShowDownloads=Set:Image%20Filters" border="0" hspace="0" complete="true" /></p>
<h2>Introduction</h2>
<p>I have seen a few image filters written in VB, but most are poorly implemented, slow or just overly-complex. So I decided to create a simple class that contains a variety of filters and is easy to use.</p>
<h2>Background</h2>
<p>I originally created this class to render a drop shadow on a custom shaped tooltip that I created in my spell check. Somewhat bored over my break, 
I decided to expand on this class and it quickly grew into its own project.</p>
<p><a href="http://img42.imageshack.us/img42/6175/asdzg.png"><img width="640" src="http://www.codeproject.com/KB/graphics/VBNETImageFilters/asdzg_small.png" border="0" /></a
</p>
<h2>Using the Code</h2>
<p>Using the filters is as easy as going: </p>
<blockquote><pre lang="vb.net">Using b As New Bitmap("c:\test.png")
 b.Filters.DropShadow(Color.Black, New Point(8, 8), 4)
 b.Save("c:\test.png", Imaging.ImageFormat.Png)
End Using</pre></blockquote>
<p>The above will open the file <em>c:\test.png</em>, apply the <code>DropShadow </code>filter, and re-saves the image over the original file.</p>
<p>More details on specific filters and their options are listed in the code 
 section.</p>
<a href="http://img526.imageshack.us/img526/3308/testproject.png"><img width="640" src="http://img526.imageshack.us/img526/3308/testproject.png" border="0" /></a
// By: Kris Alexander Bennett
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=8867&lngWId=10//for details.//**************************************

'Alpha
'Makes the image translucent by the value specified
b.Filters.Alpha(Amount As Byte)
'Amount (0 - 255)
' The amount of alpha to apply to the bitmap 0=Transparent 255=Opaque
'AlphaMask
'Creates a silhouette based on the alpha channel of an image
b.Filters.AlphaMask(AlphaColor As Color, SolidColor As Color)
'AlphaColor
' The color that the transparent sections will be in the resulting bitmap
'SolidColor
' The color that the solid sections will be in the resulting bitmap
'Brightness
'Makes the bitmap lighter or darker
b.Filters.Brightness(amount As Single)
'amount (-1 - 1)
' The amount of brightness to apply to the bitmap 
' (negative numbers darken the image positive lighten)
'DropShadow
'Adds a drop shadow to an image with alpha
b.Filters.DropShadow(ShadowColor As Color, Depth As Point, BlurAmount As Integer)
'ShadowColor
' The color of the resulting shadow
'Depth
' The x and y offsets for the shadow depth
'BlurAmount (2 +)
' How blurred the shadow will appear
'EdgeDetection
'Highlights edges in black and white
b.Filters.EdgeDetection()
'Emboss
'Adds an emboss effect to the bitmap
b.Filters.Emboss()
'Fontify
'Creates an ASCII image (font representation) of an image
b.Filters.Fontify(font As Font, ColorCount As Byte, ColorAlso As Boolean)
'font
' Specifies the font that is to be used with the ASCII image
'ColorCount
' Specifies the amount of chars that will be used when generating the final image
'ColorAlso
' If this value is true each char in the image output will be colored
'GausianBlur
'Applies a blur to the bitmap
b.Filters.GausianBlur(Amount As Integer)
'Amount (2 +)
' Specifies the amount that the image will be blurred in pixels
'GrayScale
'Converts the bitmap a GrayScale Image
b.Filters.GrayScale()
'HSL
'Adjusts the Hue, Saturation and Luminance of a bitmap
b.Filters.HSL(hue As Single, sat As Single , lum As Single)
'hue (0 - 359 but can be any number .. if 361 or 721 is used this is
'equivalent to 1, 362 or 722 = 2 etc, 
'NOTE: some people prefer to use -180 to + 180 instead)
' defines the hue of the resulting bitmap (0 = No Change)
'sat (-1 - 1)
' defines the saturation of the resulting bitmap (0 = No Change)
'lum (-1 - 1)
' defines the Luminance of the resulting bitmap (0 = No Change)
'Invert
'Inverts the colors of the bitmap object
b.Filters.Invert
'OilPainting
'Creates an artistic oil painting impression of an image
b.Filters.OilPainting(Amount As Integer, BleedTransparentEdges As Boolean)
'Amount
' Specifies the brush size for the oil painting
'BleedTransparentEdges
' Also applies the oil painting effect to the alpha channel
'Static
'Mixes the pixels up of the image to produce a static like effect 
'(Although no actual static is added :))
b.Filters.Static(Amount As Integer)
'Amount (0 +)
' The zone (in pixels) to swap with other pixels (0 = No Change)
'TwoTone
'Gets the average color of each pixel and converts it to either black or white
b.Filters.TwoTone(Amount As Byte)
'Amount
' The tollance used to determine whether the pixel is black or white


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
10/16/2012 5:04:26 AMAniket Naik

Excellent application!
(If this comment was disrespectful, please report it.)

 
11/1/2012 8:57:42 AMCarl George

Link Broken:•Download source and demo project for version 20121011
(If this comment was disrespectful, please report it.)

 
11/2/2012 4:55:01 PMKris Alexander Bennett

Actually the link isn't down ... this is a problem with PSC... I have contacted them several times about this with NO REPLY ... if you goto the page that you clicked on to get here with the overview you can see the link in the html ... if you copy and paste that it works, so not my fault

Kris
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.