This file accompanies the trial version of the ImageObject imaging library.
ImageObject is an add on class library for Visual C++. It allows you to easily load, display, and manipulate images. For instance, the following lines load and display an image in the OnDraw() function and display it:
void CDisplayView::OnDraw(CDC* pDC)
{
CImageObject ImageObject( "File.jpg" );
if( GetFocus() == this )
ImageObject.SetPalette( pDC );
ImageObject.Draw( pDC );
}
ImageObject takes care of the details for BMP, GIF, JPG, PCX, TGA, and TIF files!
ImageObject License Information
Using the Libraries with Visual C++
CImageObject Class Library Functions
CImagePointProcesses Class Library Functions
CImageAreaProcesses Class Library Functions
Acquiring Images from TWAIN Data Sources
You may use the ImageObject library and related files (such as the ImageLoad.dll file) for your own personal, non-commercial use. The personal, non-commercial use license which is granted is unlimited. You may not sell programs which use the trial version of ImageObject. You may not use the trial version of ImageObject for work- related programming projects, except to evaluate ImageObject’s potential.
Examples of proper ImageObject trial version use:
* You want to evaluate ImageObject’s potential use in your commercial application. You drop the library into your program, use the functions, and see if it meets your needs. If ImageObject meets your needs, you must purchase the commercial version of ImageObject before distributing your application.
* You want to create a non-commercial program such as a screen saver that loads images. You may give it to friends and family members, as long as there is no charge associated with the application itself.
* You want to write a slide show program so that you can display pictures from your family vacation to friends and family.
* You’re a computer science major and an assignment is due in which you must display images. You may use ImageObject to write the program. If the program is ever used for financial gain, you must then recompile with the commercial version of ImageObject.
Examples of improper ImageObject trial version use:
* You write a commercial program using ImageObject, and sell the program.
* You write a slide show program for use in business presentations. This constitutes a commercial use of ImageObject, even though you wouldn’t be charging for the actual program that you wrote. You write a program that’s used internally within your company.
ImageObject is very inexpensive compared to other imaging libraries. The cost is $200.00 for each license. A single license gives unlimited distribution for an unlimited number of programs written by a single software developer. For each software developer, there must be one license. An order for can be found at the end of this file and in the ordering.txt file.
Email support is offered at ivt-rcl@interpath.com, and questions are normally answered in less than 24 hours. ImageObject Imaging Library for Microsoft Visual C++ ImageObject is a complete imaging library for Microsoft Visual C++. It allows you to easily load, save, display, and manipulate images. Ease of use is one of the main goals of ImageObject, yet it retains the ability to allow you to perform your own advanced operations on images. With a single line of code, you can load an image. With another line of code you can display the image. If you’re tired of reading page after page of documentation, and spending weeks getting up to speed with a third-party imaging library’s API, ImageObject is for you. There’s almost no learning curve.
This version of ImageObject is free. You may use it to write programs for your own personal use without obligation. If you distribute programs that are written with ImageObject, however, you must buy a registered copy. Distribution includes any commercial application that you’re charging money for, and any non-commercial application that’s being distributed on more than one computer.
For a current update of the trial version of ImageObject, connect to http://www.interpath.com/~phaedrus and go to the ImageObject section. The cost of ImageObject is a fraction of what other imaging libraries cost. A full license for royalty-free distribution is $200. All orders are charged a $15 shipping and handling fee. The cost for the royalty-free license plus full source code is $1000. Next day shipping is $20.00.
The three ways to get a registered copy of ImageObject are as follows:
* Send a check payable to Infinite Vision Technologies at: Infinite Vision Technologies, P.O. Box 2567, Reidsville, NC 27320.
* Connect to http://www.interpath.com/~phaedrus and go to the ImageObject section. Ordering information will be there, and you can place a credit card order.
* Place an order via fax at (910) 349-2741. The order form is at the end of this document.
* Email inquiries or credit card orders are welcome at ivt-rcl@interpath.com.
Why use images? Your program performs the functions for which it was intended—isn't that enough? If you add visuals, does that mean you're placing too much importance on the appearance of your program?
An image is worth a thousand words. That's one reason Windows software is so popular. Attractive programs have an edge because we tend to equate pleasant, colorful screens with programs that are easy to use and powerful. Images can often convey information in a way that words can't. One image can replace many words and leave the viewer enlightened instead of confused.
I've downloaded plenty of shareware that worked well, but I usually end up using the programs that look good and have slick interfaces. Of the thousands of programs on the retail shelves, software authors need a way to pull out of the pack. Of course, the first requirement is a useful program that works well. But what catches the consumer's eye are the graphics and art. More programs have been sold that look good than programs that work well. I'm not recommending that you favor appearance over functionality, but you should spend enough time so that the "look" of your program doesn't detract from its usefulness.
While it's true that writing computer programs requires above-average technical skills, the creative process during software development is much the same as it is in writing a novel. If you approach your programming as an integrated presentation of information and art, you’ll be able to produce software that appeals to the widest possible audience.
Besides the "edge" graphic images give a program that's competing commercially, there's great satisfaction when you can point to a program that looks great and say, "I created that." To help you realize your creative goals, the ImageObject class that comes with this book provides a quick yet powerful tool for adding images to any Windows 95 or Windows NT application. With almost no effort, you can make your programs shine.
The ImageObject class library can be linked in with any visual C++ project. A DLL named ImageLoad must be in the application's program directory, your Windows directory, or your Windows\System directory. Six file formats are supported: BMP, GIF, JPG, PCX, TGA, and TIF. With just a few lines of code, you can load and display an image file. You don't need to know anything about the image files or the intricacies. The class library does all the work for you.
Images can be saved, too. You can modify a loaded image and overwrite the old disk file, save it as a different file, then change picture file formats and save it as a new picture file. Don't worry about displaying the image either. The class library will do all of the extra stuff it takes to display a bitmap—such as creating a device context, selecting the bitmap, and doing a BitBlt. A single call replaces the entire bitmap display procedure. Many different pictures have different dimensions, different numbers of colors, and different ways of storing information. All of that is handled in a way that's transparent to a program.
The six image file formats supported by the CImageObject class library, BMP, GIF, JPG, PCX, TGA, and TIF, all have advantages and disadvantages. For this reason, you should give some thought to which one you'll use for a given application. Here's a brief description of each file format.
BMP
The Microsoft Windows Bitmap (BMP) file format is one of several graphics file formats supported by the Microsoft Windows operating environment. BMP is the native bitmap format of Windows and is used to store virtually any type of bitmap data. Most graphics and imaging applications running under Microsoft Windows support the creation and display of BMP files.
BMP files support all of the screen resolutions and color combinations that Windows supports. For this reason, it’s always possible to create a BMP file that exactly matches a screen format.
BMP files are almost always completely uncompressed. This makes them very large. A screen capture of a screen that's 800 by 600 and a color resolution of 24 bits will create a file that's 2,743,545 bytes. As you can see, if disk space is a consideration, this file format isn't a good choice.
GIF
GIF stands for Graphics Interchange Format. Its major feature is its great compression capability, achieved by using LZW compression. After being converted to a color resolution of 8 bits, the same BMP image that's 800 by 600 with a color resolution of 24 bitscan be as small as 20 kilobytes.
In view of today’s demand for high color resolution, one disadvantage of using the GIF format is its limitation of 8 bits of color resolution. For most applications this is enough. For applications requiring photographic-quality images, it's not adequate.
JPG
JPG (JPEG) is one of the newest file formats to become popular. Its major feature is great compression, far greater even than GIF's. It achieves this degree of compression, though, at the expense of image integrity. Many times, losing a small amount of image quality won't be noticed. In cases such as this, JPG is a good choice because of the fantastic image compression. The same BMP image that's 800 by 600 with a color resolution of 24 bits can be as small as 5 kilobytes.
JPEGs are usually used for photographic images. That’s because the small amount of image degradation can rarely be detected in a photographic image. The trade-off between file size and an unperceived loss in quality weighs in on the side of smaller file sizes.
PCX
PCX was developed by Zsoft many years ago in order to provide their own paint program, PC Paint, with an image file format that offered some compression. The compression is better than an uncompressed file, but the run-length- encoding scheme it uses can still produce large image files. One problem with PCX files is that their compression is not very good. This has PCX files fading fast from the PC scene.
TGA
TGA (Targa) files were developed to support hardware devices that capture video images. The Targa file format makes it easy to store many of the video captures to disk, since very little data manipulation is required. Targa offers some compression schemes, but normally the images are stored in an uncompressed format. One big advantage that Targa files have had for some time is their support for images ranging from monochrome to those of 32- bit color resolution.
TIF
TIF, or tagged image file format, was designed as the file format that would be everything to everybody. As a result, the file format became difficult to maintain. Many vendors and third parties added their own tags, or modifications, making it hard to keep up with the changes in the file format.
It's still used in many desktop publishing applications because it handles many photometric values that are necessary when manipulating the images. It offers several compression schemes, but TIF files are found uncompressed more often than not.
The installation program creates directories into which your include and lib files are placed. It copies ImageLoad.dll to your system directory.
The installation adds the include and directories to the compiler’s list. If when you compile it can’t find the include or lib files, you may have to add the directories to the list yourself. Run Visual C++. Under the Tools menu, select Options. Click on the Directories tab. In the Show Directories for: combo box, select include. Add the include directory to the list. Now in the Show Directories for: combo box, select lib. Add the lib directory to the list.
When you want to link any of the class libraries into a project, simply select Settings from the Project menu. Clock on the Link tab. Add the library to the Object/library modules: field. Note that there’s a Settings for: combo box that determines whether you’re adding a library to the release or the debug version.
Most of the libraries have a release version and a debug version of the library (which has a 'D' appended to the filename of the library). For instance, the ImageObject.lib release library has a debug counterpart that’s named ImageObjectD.lib.
This section contains some simple examples to get you started. Many additional examples can be found by connecting to http://www.interpath.com/~phaedrus and going to the ImageObject section. Directories named Display, Crop, and Median should have been included in the ImageObject trial version distribution archive file. These directories contain the projects that result from the following three project tutorials.
* Create an MFC project.
* Link in ImageLoad.lib and ImageObjectD.lib for the debug project; and ImageLoad.lib and ImageObject.lib for the release project.
* In the view class .h file, add:
#include "ImageObject.h".
* In the view class .h file add the declaration:
CImageObject *m_pImageObject
* In the view class .cpp file, find the constructor and add:
m_pImageObject = NULL;
* In the view class .cpp file, find the destructor and add:
if( m_pImageObject != NULL ) delete m_pImageObject
* In the view class .cpp, find the OnDraw() function and add:
if( m_pImageObject == NULL )
m_pImageObject = new CImageObject( "FILE.BMP" );
// Make sure FILE.BMP is in the current directory!
if( m_pImageObject != NULL ){
if( GetFocus() == this )
m_pImageObject-SetPalette( pDC );
m_pImageObject-Draw( pDC );
}
Compile and run the application. As long as there’s a file named FILE.BMP, the program will load and display it.
* Create an MFC project.
* Link in ImageLoad.lib and ImageObjectD.lib for the debug project; and ImageLoad.lib and ImageObject.lib for the release project.
* In the view class .h file, add:
#include "ImageObject.h".
* In the view class .h file add the declaration:
CImageObject *m_pImageObject
* In the view class .cpp file, find the constructor and add:
m_pImageObject = NULL;
* In the view class .cpp file, find the destructor and add:
if( m_pImageObject != NULL ) delete m_pImageObject
* In the view class .cpp, find the OnDraw() function and add:
if( m_pImageObject == NULL ){
// Make sure FILE.BMP is in the current directory!
m_pImageObject = new CImageObject( "FILE.BMP" );
m_pImageObject-Crop( 10, 10, 150, 150 );
}
if( m_pImageObject != NULL ){
if( GetFocus() == this )
m_pImageObject-SetPalette( pDC );
m_pImageObject-Draw( pDC );
}
Compile and run the application. As long as there’s a file named FILE.BMP, the program will load and display it. This program will display an image that’s cropped from coordinates 10, 10-150, 150.
* Create an MFC project.
* Link in ImageLoad.lib, ImageObjectD.lib, and
* ImageAreaProcessesD.lib for the debug project; and ImageLoad.lib, ImageObject.lib, and ImageAreaProcesses.lib for the release project.
* In the view class .h file, add:
#include "ImageObject.h".
#include "ImageAreaProcesses.h"
* In the view class .h file add the declaration:
CImageObject *m_pImageObject
* In the view class .cpp file, find the constructor and add:
m_pImageObject = NULL;
* In the view class .cpp file, find the destructor and add:
if( m_pImageObject != NULL ) delete m_pImageObject
* In the view class .cpp, find the OnDraw() function and add:
if( m_pImageObject == NULL ){
// Make sure FILE.BMP is in the current directory!
m_pImageObject = new CImageObject( "FILE.BMP" );
CImageAreaProcesses AreaProcesses( m_pImageObject );
AreaProcesses.MedianFilter();
}
if( m_pImageObject != NULL ){
if( GetFocus() == this )
m_pImageObject-SetPalette( pDC );
m_pImageObject-Draw( pDC );
}
Compile and run the application. As long as there’s a file named FILE.BMP, the program will load and display it. This program will display an image that has been median filtered.
This section is provided as a reference to the public function calls offered by the ImageObject class library. Since the class library was designed with simplicity as a major goal, the calls are simple and easy to use. That's good, because to load and save a picture is easy—it just takes a few lines of code.
You must always link in ImageLoad.lib and make sure the ImageLoad.dll is accessible (preferable in the Windows\System directory). For release versions, link in ImageObject.lib. For debug versions, link in ImageLoadD.lib and ImageObjectD.lib.
Loading, Saving, and Errors.
Drawing.
Information Functions.
Palette Functions.
Image Manipulation Functions.
CImageObject()
Prototype:
CImageObject( void );
Purpose:
This is the constructor that takes no arguments. It simply
creates a CImageObject class and initializes its internal
variables.
Arguments:
None
Returns:
Nothing
CImageObject()
Prototype:
CImageObject( const char *pszFilename, CDC *pDC, int nX,
int nY );
Purpose:
This constructs a CImageObject. The only argument that's
required is the filename. If the CDC argument is given, the
image will be drawn once it's loaded. If nX or nY are
given, their values will be stored and the image will be
drawn to that location. Otherwise, the image will always be
drawn to coordinates 0, 0.
Arguments:
const char *pszFilename
CDC *pDC, Defaults to NULL
int nX, Defaults to -1
int nY, Defaults to -1
Returns:
Nothing
CImageObject()
Prototype:
CImageObject( CDC *pDC, int nX, int nY, int nWidth, int
nHeight );
Purpose:
This constructs a CImageObject from a device context. All
arguments are required.
Arguments:
CDC *pDC
int nX
int nY
int nWidth
int nHeight
Returns:
Nothing
CImageObject()
Prototype:
CImageObject( HBITMAP hBitmap, CDC *pDC );
Purpose:
This constructs a CImageObject from a bitmap. All arguments
are required.
Arguments:
HBITMAP hBitmap;
CDC *pDC
Returns:
Nothing
CImageObject()
Prototype:
CImageObject( int nWidth, int nHeight, int nPlanes, int
nBits, COLORREF FillColor );
Purpose:
This constructs a CImageObject with dimensions nWidth and
nHeight. The nPlanes and nBits arguments specify the number
of bit planes and the number of bits per pixel. All
arguments are required.
Arguments:
int nWidth;
int nHeight;
int nPlanes;
int nBits;
COLORREF FillColor;
Returns:
Nothing
CImageObject()
Prototype:
CImageObject( HGLOBAL hDib );
Purpose:
This constructs a CImageObject constructs a CImageObject
class from a Dib. All arguments are required.
Arguments:
HGLOBAL hDib;
Returns:
Nothing
Load()
Prototype:
BOOL Load( const char *pszFilename, CDC *pDC, int nX, int
nY );
Purpose:
This function loads a file into the CImageObject. The only
argument required is the filename. If the CDC argument is
given, the image will be drawn once it's loaded. If nX or
nY are given, their values will be stored and the image
will be drawn to that location. Otherwise, the image will
always be drawn to coordinates 0, 0.
Arguments:
const char *pszFilename
CDC *pDC, Defaults to NULL
int nX, Defaults to -1
int nY, Defaults to -1
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
int GetLastError( void );
Purpose:
This function returns the last CImageObject error that
occured. See the Errors.h include file for details.
Arguments:
None
Returns:
int nErrorNumber
Prototype:
BOOL Save( const char *pszFilename, int nType );
Purpose:
This function saves the image that currently resides in the
CImageObject class. (See GetImageType() for the image type
defines.)
Arguments:
const char *pszFilename
int nType, Defaults to -1
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
int GetWidth( void );
Purpose:
This function returns the pixel width of the image.
Arguments:
None
Returns:
int nWidth
Prototype:
int GetHeight( void );
Purpose:
This function returns the pixel height of the image.
Arguments:
None
Returns:
int nHeight
Prototype:
int GetNumBits( void );
Purpose:
This function returns the number of pixels for the image:
1, 4, 8, 16, 24, or 32.
Arguments:
None
Returns:
int nBits
Prototype:
int GetNumColors( void );
Purpose:
This function returns the number of colors in the palette.
For an image of 16 bits or greater, this value will be
zero.
Arguments:
None
Returns:
int nColors
GetPaletteData()
Prototype:
BOOL GetPaletteData( RGBQUAD *pRGBPalette );
Purpose:
This function fills in the point that's passed in with the
current RGB palette data. Nothing will be filled in for
images of 16 bits or greater.
Arguments:
RGBQUAD *pRGBPalette
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
RGBQUAD *GetPaletteData( void );
Purpose:
This function returns a pointer to the CImageObject's list
of palette data. This will return NULL for images of 16
bits or greater.
Arguments:
None
Returns:
RGBQUAD *PaletteList
Prototype:
int GetImageType( const char *pFilename );
Purpose:
This function returns the image type. Image types are
defined as follows:
#define IMAGETYPE_NONE 0
#define IMAGETYPE_BMP 1
#define IMAGETYPE_GIF 2
#define IMAGETYPE_PCX 3
#define IMAGETYPE_TGA 4
#define IMAGETYPE_JPG 5
#define IMAGETYPE_TIF 6
Arguments:
const char *pFilename
Returns:
int nImageType
Prototype:
BOOL GetImageInfo( const char *pszFilename, int *pnWidth,
int *pnHeight,
int *pnPlanes, int *pnBitsPerPixel, int *pnNumColors );
Purpose:
This function retrieves the image width, height, number of
bit planes, number of bits per pixel, and number of colors.
Any arguments that are NULL will not be filled in.
Arguments:
const char *pszFilename
int *pnWidth, Defaults to NULL
int *pnHeight, Defaults to NULL
int *pnPlanes, Defaults to NULL
int *pnBitsPerPixel, Defaults to NULL
int *pnNumColors, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL Draw( CDC *pDC, int nX, int nY, int nWidth, nHeight );
Purpose:
This function draws the image to the device context. If the
x and y coordinates are not given, the image will be drawn
to either 0, 0 or the last valid coordinates that were
passed in.
Arguments:
CDC *pDC
int nX, Defaults to -1
int nY, Defaults to –1
int nWidth, Defaults to the width of the image;
int nHeight, Defaults to the height of the image;
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL SetPalette( CDC *pDC );
Purpose:
This function sets the palette of the device context to
that of the image. The palette information is stored in the
CImageObject class when the image loads.
Arguments:
CDC *pDC
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
void SetPaletteCreationType( int nType );
Purpose:
This function sets the method of palette creation when
color reduction to a palettized image is desired. The
possible values are defined as follows:
define POPULARITY_PALETTE 0
#define MEDIAN_CUT_PALETTE 1
#define FIXED_PALETTE 2
Arguments:
int nType
Returns:
Nothing
Prototype:
int GetPaletteCreationType( );
Purpose:
This function returns the palette creation type that will
be used on the next color reduction operation.
Arguments:
None
Returns:
int nPaletteCreationType
Prototype:
BOOL IsLoaded( void );
Purpose:
This function reports whether an image has been loaded or
not.
Arguments:
None
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL Crop( int nX1, int nY1, int nX2, int nY2 );
Purpose:
This function crops an image to the given coordinates.
Arguments:
int nX1
int nY1
int nX2
int nY2
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL Stretch( int nNewWidth, int nNewHeight );
Purpose:
This function stretches (or shrinks) the image to the given
width and height.
Arguments:
int nNewWidth
int nNewHeight
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL Rotate( int nDegrees );
Purpose:
This function rotates the image. Valid arguments are 90,
180, and 270.
Arguments:
int nDegrees
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL Invert( void );
Purpose:
This function inverts an image.
Arguments:
None
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL Reverse( void );
Purpose:
This function reverses an image.
Arguments:
None
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL ChangeFormat(int nNewBitsPerPixel );
Purpose:
This function changes an image from its current pixel
resolution to the given pixel resolution.
Arguments:
int nNewBitsPerPixel
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
HGLOBAL GetDib( void );
Purpose:
This function returns the Dib handle of the currently
loaded image.
Arguments:
None
Returns:
HGLOBAL hDib
Prototype:
CPalette *GetPalette( void );
Purpose:
This function returns a pointer to the Cpalette class.
Arguments:
None
Returns:
CPalette *Palette
CImageObject operator =
This allows you to copy the contents of one CImageObject
class into another.
Prototype:
BOOL MapToPalette( RGBQUAD *pPalette, int nPaletteEntries )
This function maps the image to a new palette.
Arguments:
RGBQUAD *pPalette;
int nPaletteEntries;
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL MapToBrowserPalette( void );
This function maps the image to a browser-safe palette.
Arguments:
None
Returns:
BOOL: TRUE for success, FALSE for FAIL
ProtoType:
BOOL CImageObject::Blit( CImageObject *lpImageObject, int
nX, int nY, int nFlag, int nOptions, int nSrcX, int nSrcY,
int nWidth, int nHeight );
This function blits one CImageObject into another. It
automatically clips if either CImageObject goes out of
range. The following operations are available and are
passed in via the nFlags argument:
BLIT_REPLACE, BLIT_MASK, BLIT_BLEND, and BLIT_SHADOW
nOptions may specify a mask color. It defaults to –1 which
indicates that you want the mask color to be the color of
the pixel in the upper left corner.
The ImagePointProcesses class library provides you with functions to perform operations such as colorization, brightness alterations, and grayscale conversion.
This section is provided as a reference to the public function calls offered by the ImagePointProcess class library. Since the class library was designed with simplicity as a major goal, the calls are simple and easy to use. That's good, because process images is easy—it just takes a few lines of code.
You must always link in ImageLoad.lib and make sure the ImageLoad.dll is accessible (preferable in the Windows\System directory). You must also link in either ImageObject.lib or ImageObjectD.lib for release and debug versions respectively.
CImagePointProcesses Constructors
CImagePointProcesses()
Prototype:
CImagePointProcesses( CImageObject *pImageObject );
Purpose:
This constructs a CImagePointProcesses class and
initializes all internal variables. Since there is a
CImageObject class in this version of the constructor, one
does not need to be supplied for other CImagePointProcesses
functions that are used.
Arguments:
CImageObject *pImageObject
Returns:
Nothing
CImagePointProcesses()
Prototype:
CImagePointProcesses( void );
Purpose:
This constructs a CImagePointProcesses class and
initializes all internal variables. Since there is no
CImageObject class in this version of the constructor, one
must be supplied for other CImagePointProcesses functions
that are used.
Arguments:
None
Returns:
Nothing
Prototype:
BOOL ChangeBrightness( int nBrightness, int nX1, int nY1,
int nX2, int nY2, CImageObject *pImageObject );
Purpose:
This function changes the brightness of the image that's in
the attached CImageObject class. If a CImageObject class
point has not been specified before making this call, one
must be specified when the call is made. Any coordinates
that are not passed and that default to -1, will be
assigned the minimum or maximum value of the image. The
variables nX1 and nY1 will become 0, nX2 will become the
image width -1, and nY2 will become the image height -1.
The best way to perform the operation on the entire image
is to not pass nX1, nY1, nX2, and mY2. This way, they will
default to include the entire image.
Arguments:
int nBrightness
int nX1, Defaults to -1
int nY1, Defaults to -1
int nX2, Defaults to -1
int nY2, Defaults to -1
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL ReverseColors(int nX1,int nY1, int nX2, int nY2,
CImageObject *pImageObject);
Purpose:
This function reverses the colors of the image that's in
the attached CImageObject class. If a CImageObject class
point has not been specified before making this call, one
must be specified when the call is made. Any coordinates
that are not passed and that default to -1, will be
assigned the minimum or maximum value of the image. The
variables nX1 and nY1 will become 0, nX2 will become the
image width -1, and nY2 will become the image height -1.
The best way to perform the operation on the entire image
is to not pass nX1, nY1, nX2, and mY2. This way, they will
default to include the entire image.
Arguments:
int nX1, Defaults to -1
int nY1, Defaults to –1
int nX2, Defaults to -1
int nY2, Defaults to -1
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL MakeGray( BOOL bSetPalette, CImageObject *pImageObject
);
Purpose:
This function makes a color image into a grayscale image
for the image that's in the attached CImageObject class. If
a CImageObject class point has not been specified before
making this call, one must be specified when the call is
made.
Arguments:
BOOL bSetPalette, Defaults to TRUE
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL Colorize( int nX1, int nY1, int nX2, int nY2,
CImageObject *pImageObject );
Purpose: This function colorizes the pixels of the image
that's in the attached CImageObject class. If a
CImageObject class point has not been specified before
making this call, one must be specified at the time the
call is made. Any coordinates that are not passed and that
default to -1, will be assigned the minimum or maximum
value of the image. The variables nX1 and nY1 will become
0, nX2 will become the image width -1, and nY2 will become
the image height -1. The best way to perform the operation
on the entire image is to not pass nX1, nY1, nX2, and mY2.
This way they will default to include the entire image.
Arguments:
int nX1, Defaults to -1
int nY1, Defaults to -1
int nX2, Defaults to -1
int nY2, Defaults to -1
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
The ImageAreaProcesses class library provides you with functions to perform operations such as colorization, brightness alterations, and grayscale conversion.
This section is provided as a reference to the public function calls offered by the ImageAreaProcess class library. Since the class library was designed with simplicity as a major goal, the calls are simple and easy to use. That's good, because process images is easy—it just takes a few lines of code.
You must always link in ImageLoad.lib and make sure the ImageLoad.dll is accessible (preferable in the Windows\System directory). You must also link in either ImageObject.lib or ImageObjectD.lib for release and debug versions respectively.
CImageAreaProcesses()
Prototype:
CImageAreaProcesses( void );
Purpose:
This version of the CImageAreaProcesses class constructs
the class without attaching a CImageObject class. The first
call to an image processing function must include a
CImageObject pointer in order for the function to have
something upon which it can operate.
Arguments:
None
Returns: Nothing
CImageAreaProcesses()
Prototype:
CImageAreaProcesses( CImageObject *pImageObject );
Purpose:
This version of the CImageAreaProcesses class constructs
the class and attaches a CImageObject class. Every
operation will refer to the CImageObject class that was
attached until another is passed in as a function argument
to one of the image processing functions.
Arguments:
None
Returns:
Nothing
Prototype:
BOOL MedianFilter( int nX1, int nY1, int nX2, int nY2,
CImageObject *pImageObject);
Purpose:
This function performs a median filtering operation on the
image that's attached. Any coordinate that's not specified
and is allowed to default to -1 will revert to the edge of
the image. For instance, nX1 and nY1 will become 0; nX2 and
nY2 will become the width and height of the image. The best
way to median filter the entire image is to not pass any
arguments. By not specifying a CImageObject pointer, the
function will use the CImageObject that's been previously
attached.
Arguments:
int nX1, Defaults to -1
int nY1, Defaults to -1
int nX2, Defaults to -1
int nY2, Defaults to -1
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL ChangeContrast( int nContrast, int nX1, int nY1, int
nX2, int nY2, CImageObject *pImageObect );
Purpose:
This function changes the contrast for the image that's
attached. Any coordinate that's not specified and is
allowed to default to -1 will revert to the edge of the
image. For instance, nX1 and nY1 will become 0; nX2 and nY2
will become the width and height of the image. The best way
to change the contrast for the entire image is to not pass
any arguments. By not specifying a CImageObject pointer,
the function will use the CImageObject that's been
previously attached. Contrast values should range from 1 to
200.
Arguments:
int nContrast
int nX1, Defaults to -1
int nY1, Defaults to -1
int nX2, Defaults to -1
int nY2, Defaults to -1
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL EqualizeContrast( int nX1, int nY1, int nX2, int nY2,
int nThresholdFactor );
Purpose:
This function that equalizes the contrast for the image
that's attached. Any coordinate that's not specified and is
allowed to default to -1 will revert to the edge of the
image. For instance, nX1 and nY1 will become 0; nX2 and nY2
will become the width and height of the image. The best way
to equalize the contrast for the entire image is to not
pass any arguments. By not specifying a CImageObject
pointer, the function will use the CImageObject that's been
previously attached.
Arguments:
int nX1, Defaults to -1
int nY1, Defaults to -1
int nX2, Defaults to -1
int nY2, Defaults to -1
int nThresholdFactor, Defaults to -1
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL HighpassFilter( int nX1, int nY1, int nX2, int nY2,
CImageObject *pImageObject);
Purpose:
This function performs a high pass filtering operation on
the image that's attached. Any coordinate that's not
specified and is allowed to default to -1 will revert to
the edge of the image. For instance, nX1 and nY1 will
become 0; nX2 and nY2 will become the width and height of
the image. The best way to high pass filter the entire
image is to not pass any arguments. By not specifying a
CImageObject pointer, the function will use the
CImageObject that's been previously attached.
Arguments:
int nX1, Defaults to -1
int nY1, Defaults to -1
int nX2, Defaults to -1
int nY2, Defaults to -1
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL LowpassFilter( int nX1, int nY1, int nX2, int nY2,
DWORD *dwFact );
Purpose:
This function performs a low pass filtering operation on
the image that's attached. Any coordinate that's not
specified and is allowed to default to -1 will revert to
the edge of the image. For instance, nX1 and nY1 will
become 0; nX2 and nY2 will become the width and height of
the image. The best way to low pass filter the entire image
is to not pass any arguments. By not specifying a
CImageObject pointer, the function will use the
CImageObject that's been previously attached.
Arguments:
int nX1, Defaults to -1
int nY1, Defaults to -1
int nX2, Defaults to -1
int nY2, Defaults to -1
DWORD *dwFact, Defaults to NULL
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL EdgeEnhance( int nX1, int nY1, int nX2, int nY2,
CImageObject *pImageObject);
Purpose:
This function performs an edge enhancement operation on the
image that's attached. Any coordinate that's not specified
and is allowed to default to -1 will revert to the edge of
the image. For instance, nX1 and nY1 will become 0; nX2 and
nY2 will become the width and height of the image. The best
way to edge enhance the entire image is to not pass any
arguments. By not specifying a CImageObject pointer, the
function will use the CImageObject that's been previously
attached.
Arguments:
int nX1, Defaults to -1
int nY1, Defaults to -1
int nX2, Defaults to -1
int nY2, Defaults to -1
CImageObject *pImageObject, Defaults to NULL
Returns:
BOOL: TRUE for success, FALSE for FAIL
You can acquire an image from any TWAIN data source. The following functions will give you the functionality you need:
Prototype:
BOOL InitTwain( HWND hParentWnd );
Purpose:
This function loads the TWAIN dll and initializes the library.
Arguments:
HWND hParentWnd
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL UninitTwain( void );
Purpose:
This function unloads the TWAIN dll and releases any memory that the library has allocated.
Arguments:
None
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL SelectDataSource( HWND hParentWnd );
Purpose:
This function allows the user to select the data source. The TWAIN dll maintains the selection dialog.
Arguments:
HWND hParentWnd
Returns:
BOOL: TRUE for success, FALSE for FAIL
Prototype:
BOOL AcquireImage( HGLOBAL *phDib, BOOL bShowUI, int nReserved );
Purpose:
This function acquires an image from the scanner.
Arguments:
HGLOBAL *phDib (Set hDib to NULL before calling)
BOOL bShowUI
int nReserved (Set to 200 for now)
Returns:
BOOL: TRUE for success, FALSE for FAIL
Example of acquiring image:
hDib = NULL;
AcquireImage( &hDib, TRUE, 100 );
if( hDib != NULL )
m_pImageObject = new CImageObject( hDib );
You can send and receive faxes. The files that you send must be saved as Group 3 or 4 TIF files. The following functions are for the fax support:
Include Fax.h. Declare a CFaxmodem class. Link Fax.lib or FaxD.lib.
void SetClass( int ); 0 for autodetect, 1 for class 1, 2 for class 2 and 20 for class 2.0
void SetErrorCorrection( BOOL ); TRUE for on, FALSE for off
void SetFilename( const char * ); Set the output or input TIF file name
void SetLocalFaxID( const char * ); Set the local fax id
void SetLogFile( const char * ); Set the log file name
void SetConnectSpeed( int ); Set the connect speed. Should be 1200, 2400, 9600, etc.
void SetPhoneNumber( const char * ); Set the destination phone number.
void SetImmediateAnswer( BOOL ); If answering, set whether it answers immediately.
void SetCommPort( int ); Set the comm port, should be 1-4
void SetModemSpeed( int ); Set the modem speed. Should be 1`200, 2400, 9600, etc.
void Set2DFaxes( BOOL ); Enable 2D faxes.
void SetVerbose( BOOL ); Set the reporting to the log file to verbose.
BOOL SendFax( BOOL bWaitForCompletion, const char *lpszPhone = NULL, const char *lpszFilename = NULL, const char *lpszID = NULL, const char *lpszLogFile = NULL ); Sends a fax. You can either wait for completion or let the process go while you go back to your program. You can use IsDone() to check the status.
BOOL ReceiveFax(BOOL bWaitForCompletion, const char *lpszFilename = NULL, const char *lpszID = NULL, const char *lpszLogFile = NULL ); Receives a fax. You can either wait for completion or let the process go while you go back to your program. You can use IsDone() to check the status.
void Abort( void ); Abort the fax process.
BOOL IsDone( void ); See if the process is completed.
ImageObject Order Form
Name __________________________________________________________________
Company Name _________________________________________________________
Shipping Address ________________________________________________________
City __________________________________ State ____________ Zip ___________
Credit Card:
Name __________________________________________________________________
Address on ______________________________________________________________
City __________________________________ State ____________ Zip ___________
How many ImageObject licenses are you buying? _________
Total cost @ $200.00 per license _________
(Licenses give unlimited distribution for an unlimited number of
programs written by a single software developer. For each software
developer, there must be one license.)
Shipping and handling $15.00
Next day shipping ($20.00) _________
Total _________
Payment method _____ Check _____ Credit Card
Credit Card Number _______________________________________
Credit Card Expiration Date _________________________________