Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » GDI+ » General » Downloads
 
Add your own
alternative version

Color Scale Filter

, 17 Jul 2007
Grayscale and color scale filters.
faster_grayscale_filter_demo_100.zip
Grayscale_Filter
Grayscale_Filter
bin
Release
Grayscale_Filter.exe
My Project
Application.myapp
Settings.settings
faster_grayscale_filter_source_100.zip
Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class ResizeFilter
   Inherits BasicFilter

   ''' <summary>
   ''' Width of new image.
   ''' </summary>
   Private _width As Integer = 0
   ''' <summary>
   ''' Height of new image.
   ''' </summary>
   Private _height As Integer = 0

   ''' <summary>
   ''' Get or set output image width.
   ''' </summary>
   Public Property Width() As Integer
      Get
         Return _width
      End Get
      Set(ByVal value As Integer)
         _width = value
      End Set
   End Property

   ''' <summary>
   ''' Get or set output image height.
   ''' </summary>
   Public Property Height() As Integer
      Get
         Return _height
      End Get
      Set(ByVal value As Integer)
         _height = value
      End Set
   End Property

   ''' <summary>
   ''' Execute resize of given image.
   ''' </summary>
   ''' <param name="img">Image to be resized.</param>
   ''' <returns>Resized image.</returns>
   Public Overrides Function ExecuteFilter(ByVal img As System.Drawing.Image) As System.Drawing.Image
      If ((img.Width <= 0) Or (img.Height <= 0) Or _
               (_width <= 0) Or (_height <= 0)) Then
         Return img
      End If
      Dim result As Bitmap = New Bitmap(_width, _height)
      Dim g As Graphics = Graphics.FromImage(result)
      g.InterpolationMode = Interpolation
      g.DrawImage(img, 0, 0, _width, _height)
      Return result
   End Function

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Miran.Uhan
Engineer
Slovenia Slovenia
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 17 Jul 2007
Article Copyright 2007 by Miran.Uhan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid