Sample Code
Zip file
Above is zipped up sample code that you can use to start you on developing
imaging applications. YOU ARE encouraged to
alter the code to your own style AND to conform to your project needs and requirements. Note, that an (unfortunate) mixture of awt and swing are used to produce the GUI....you are more than welcome to update it to use only swing,etc. A pleasing and easy to use interface is necessary and an important part of a usable computer vision /imaging system. Included are the following java files (there are more):
ImageApplication.java : main application
class, has GUI
QuitDialog: dialog class, pops-up to confirm user
wishes to exit application
AboutDialog.java : about dialog class,
pops-up to tell you about application
ImageFrame.java: this is the secondary frame that pops-up when you open up an image. Displays image and lets you save raw data (not as jpeg/gif) and hide this window.
ImageData.java: this is a class that represents the image data.
(unzipped directory)
TIP: to create an image from a data array. You can have a class that
extends java.awt.Component (and hence inheirits its createImage method).
This createImage method that it inherits requires an instance of the
ImageProducer class. You can use the class java.awt.MemoryImageSource
class to get you this instance directly from the data array. You will
have something like this:
//Now create Image using new MemoryImageSource
// where data is stored in pixels array.
return ( super.createImage(new MemoryImageSource(cols, rows, pixels,
0, cols)));
//NOTE: pixel array was made in following fashion
pixels[index] = (255 << 24) | (red[index] << 16) | (green[index]
<< 8) | blue[index];
Also, included in zip are files needed to load Visual Cafe project file
(this is an OLD IDE we dont use anymore so you can ignore these) called SampleProject
|