Title: Graphics Drawing Demo 2005
1Graphics - Drawing Demo 2005
image goofy.jpg located inside Folder, Debug
picBox
txtFileName
btnInvert
btnGrayscale
btnLoad
2Method to Read Image File
3class Form1
declare img as a Bitmap
button event passes image by reference
. . .
4Method Invert( )
inverts level of each color value of each pixel
5Method Grayscale( )
sets all three color values to the average level
6OpenFileDialog
Instead of requiring the user to type in a
filename, we can use the OpenFileDialog class to
bring up a file directory. This directory will
show the folder and files at the current level.
We can limit the files to those with a particular
set of extensions as shown. When the appropriate
file is selected, the picBox.Image can be
assigned a new Bitmap using the selected image
file.
7Avast, ye mateys! There be rough seas
ahead! Lubbers should steer to the shore.
Proceed at yer own risk!
The following section is optional, for those who
are interested in learning how to make
pixel-level image operations faster (i.e.
practical).
such as C, C, C with pointers !!!!
8Image Pixel Format
24 bit per pixel is 1 byte per color
scan line
red byte
blue byte
green byte
scan line must be a multiple of 4 bytes, so each
line is padded with between 0 and 3 bytes
9Locking and Unlocking the Bitmap
pointer to the beginning of the first scan line
of the image
10Pixel Operations
11Fast Grayscale Method
12Fast Invert Method
13Form1 Button Events to Access ImgPro Methods