CodeVis.com SourceForge.net Logo

CVImage Class Reference

#include <CVImage.h>

Inheritance diagram for CVImage:

CVImageGrey CVImageRGB24 CVImageRGBFloat List of all members.

Detailed Description

CVImage is the root image class for image capture and processing.

Stores the image as an unpadded array of pixels. Multiple formats are supported as derived classes. If you add a new type, you'll need to add it into the CVIMAGE_TYPE enum and add support where the type is referenced in CVImage in addition to creating the new child class itself.

Externally, use CVImage::CreateImage(), ReleaseImage(), and the other static functions to construct and destruct images. Do *not* use new and delete! CVImages are reference counted objects.

CVImage objects can now be sub images of other CVImage objects. What that means is that if you want to access the fData buffer directly via CVImage::GetRawDataPtr(), you need to take account of the x/y offsets and the fact that the size of the data buffer won't necessarily be the same size as the image.

You can get the absolute width and height of the image buffer from CVImage::AbsWidth() and CVImage::AbsHeight().

For the absolute X and Y offsets, use CVImage::XOffsetAbs() and CVImage::YOffsetAbs().

Please use these functions rather than just checking for parents and grabbing the parent's data! The parent might be a sub image as well.

Loading and saving currently support PNM (Portable Anywhere Maps) in binary formats only. Floating point and 32-bit integer formats have their own derivation of these formats. See documentation for the CVImage::Load() and CVImage::Save() functions in the code.

When adding new functions, if it's easy and portable please add them to only the CVImage base class. However, for image-type specific stuff, make them pure virtuals in the base class (if possible - if not return CVRES_NOT_IMPLEMENTED from the base), then implement them on all image types individually. If it's going to kill the speed to make the function generic in the base class, use the latter method and implement it for each type.

A note on threading....
CVImage objects should be accessed in a serialized manner. Additionally, all child (sub)images and parent images of a CVImage object should be serialized with each other. If you want to access a single image (or an image and its sub-images) simultaneously from multiple threads for anything but the const functions, I'd highly recommend making a copy of it first with CVImage::CreateCopy().

See also:
CVImageGrey, CVImageRGB24, CVImageRGBFloat
RCSfile
CVImage.h,v
Date
2004/02/08 23:47:39
Revision
1.1.1.1
Author
mikeellison

Definition at line 111 of file CVImage.h.

Public Types

Public Member Functions

Static Public Member Functions

Protected Member Functions

Static Protected Member Functions

Protected Attributes


Member Enumeration Documentation

enum CVImage::CVIMAGE_TYPE
 

Enumeration values:
CVIMAGE_DEFAULT  Default type (sometimes used for auto-detect).
CVIMAGE_RGB24  8-bit red, green, blue triplets
CVIMAGE_RGBFLOAT  32-bit float red, green, blue triplets
CVIMAGE_GREY  8-bit intensity values

Definition at line 121 of file CVImage.h.

Referenced by CVDevGrabImage(), CVDevStartCap(), CVSaveImage(), CVImageRGBFloat::GetImageType(), CVImageRGB24::GetImageType(), CVImageGrey::GetImageType(), and Load().


Constructor & Destructor Documentation

CVImage::CVImage  )  [protected]
 

Constructor for CVImage - use CVImage::CreateImage() or similar static functions instead!

Definition at line 557 of file CVImage.cpp.

References fData, fHeight, fOwnData, fParentImage, fRefCount, fWidth, fXOffset, and fYOffset.

CVImage::~CVImage  )  [protected, virtual]
 

Destructor for CVImage - use CVImage::ReleaseImage().

Definition at line 572 of file CVImage.cpp.

References CVAssert, DecRef(), fData, fOwnData, and fRefCount.


Member Function Documentation

int CVImage::AbsHeight  )  const
 

Returns the absolute height of the fData image buffer.

Returns:
int - Absolute height of root image

Definition at line 714 of file CVImage.cpp.

References fHeight, and fParentImage.

Referenced by AbsSize().

int CVImage::AbsSize  )  const
 

Returns absolute size of parent image.

Returns:
int - Absolute size of root image in bytes.

Definition at line 756 of file CVImage.cpp.

References AbsHeight(), AbsWidth(), and GetBytesPerPixel().

int CVImage::AbsWidth  )  const
 

Returns the absolute width of the fData image buffer.

Returns:
int - Absolute width of root image

Definition at line 699 of file CVImage.cpp.

References fParentImage, and fWidth.

Referenced by AbsSize(), CopyImage(), GetMaxPixel(), CVImageRGBFloat::GetPixel(), CVImageRGB24::GetPixel(), CVImageGrey::GetPixel(), Save(), CVImageRGBFloat::SetPixel(), CVImageRGB24::SetPixel(), and CVImageGrey::SetPixel().

unsigned long CVImage::AddRef  ) 
 

AddRef increments our reference count and calls AddRef on our parent if one exists.

Returns:
long - current reference count

Definition at line 515 of file CVImage.cpp.

References fParentImage, and fRefCount.

Referenced by Create(), and CreateSub().

CVRES CVImage::Clear  ) 
 

Clear() sets all the pixels in the image to 0.

Returns:
CVRES result code.

Definition at line 630 of file CVImage.cpp.

References CVAssert, CVRES, CVRES_IMAGE_MUST_INITIALIZE_ERR, CVRES_SUCCESS, and fData.

Referenced by Create().

CVRES CVImage::CopyImage const CVImage srcImg,
CVImage *&  dstImg,
int  xOffset,
int  yOffset,
int  width,
int  height
[static]
 

CopyImage() creates a new image of the same type as srcImg and stores it in dstImg. The data from srcImg is copied into a buffer owned by dstImg. Caller must call CVImage::ReleaseImage() on the returned image when done.

This version allows you to specify offsets, width, and height of the data to copy into a new image.

Parameters:
srcImg - source image to copy from
dstImg - uninitialized image ptr. Contains copy of srcImg on return.
xOffset - relative x offset for top-left of copy.
yOffset - relative y offset for top-left of copy.
width - width of destination image.
height - height of destination image.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::ReleaseImage()

Definition at line 367 of file CVImage.cpp.

References AbsWidth(), CreateImage(), CVAssert, CVFAILED, CVRES, CVRES_IMAGE_INVALID_SUB_POSITION, CVRES_INVALID_PARAMETER, CVRES_SUCCESS, fData, fHeight, fWidth, GetBytesPerPixel(), GetImageType(), XOffsetAbs(), and YOffsetAbs().

CVRES CVImage::CopyImage const CVImage srcImg,
CVImage *&  dstImg
[static]
 

CopyImage() creates a new image of the same type as srcImg and stores it in dstImg. The data from srcImg is copied into a buffer owned by dstImg. Caller must call CVImage::ReleaseImage() on the returned image when done.

Parameters:
srcImg - source image to copy from
dstImg - uninitizlied image ptr. Contains copy of srcImg on return.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::ReleaseImage()

Definition at line 332 of file CVImage.cpp.

References CVAssert, CVRES, CVRES_INVALID_PARAMETER, Height(), Width(), XOffsetRel(), and YOffsetRel().

CVRES CVImage::Create int  width,
int  height,
bool  init
[protected]
 

Create - internal image creation function. Creates the buffer and sets it up, then calls AddRef().

Parameters:
width - width of image in pixels.
height - height of image in pixels.
init - if true, initializes image pixels to 0.
Returns:
CVRES result code.
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM

Definition at line 598 of file CVImage.cpp.

References AddRef(), Clear(), CVRES, CVRES_IMAGE_INVALID_SIZE, CVRES_OUT_OF_MEMORY, CVRES_SUCCESS, fData, fHeight, fOwnData, fWidth, and GetBytesPerPixel().

Referenced by CreateImage(), CVImageRGBFloat::SetFromWin32Bmp(), CVImageRGB24::SetFromWin32Bmp(), and CVImageGrey::SetFromWin32Bmp().

CVRES CVImage::CreateCompatible const CVImage srcImg,
CVImage *&  dstImg,
int  width,
int  height,
bool  init = true
[static]
 

CreateCompatible creates an image of the same type as the specified srcImg. This version uses user-specified dimensions for the new image. Call CVImage::ReleaseImage() on returned image when done.

Parameters:
srcImg - source image to get information from.
dstImg - uninitialized image ptr. Set on return.
width - width of desired image in pixels.
height - height of desired image in pixels.
init - if true, image data is set to 0.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::ReleaseImage()

Definition at line 227 of file CVImage.cpp.

References CreateImage(), CVRES, and GetImageType().

CVRES CVImage::CreateCompatible const CVImage srcImg,
CVImage *&  dstImg,
bool  init = true
[static]
 

CreateCompatible creates an image of the same type as the specified srcImg. This version also uses the source image's width and height for the new image.

Call CVImage::ReleaseImage() on returned image when done.

Parameters:
srcImg - source image to get information from.
dstImg - uninitialized image ptr. Set on return.
init - if true, image data is set to 0.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::ReleaseImage()

Definition at line 204 of file CVImage.cpp.

References CreateImage(), CVRES, GetImageType(), Height(), and Width().

CVRES CVImage::CreateFromWin32Bmp CVIMAGE_TYPE  imageType,
CVImage *&  dstImage,
const BITMAPINFOHEADER *  bmih,
const unsigned char *  data
[static]
 

CreateFromWin32Bmp creates an image from a bitmap buffer. WARNING: Currently only supports 24-bit uncompressed RGB bitmaps

Bitmap header and data may be freed after call - we do a deep copy of the data we care about. You must call CVImage::ReleaseImage() on the image when you are done.

Parameters:
imageType - type of image to create
dstImage - uninitialized image ptr. Set on return.
bmih - BITMAPINFOHEADER with format information
data - raw bitmap data matching bmih format.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::ReleaseImage()

Definition at line 453 of file CVImage.cpp.

References CVAssert, CVIMAGE_DEFAULT, CVIMAGE_GREY, CVIMAGE_RGB24, CVIMAGE_RGBFLOAT, CVRES, CVRES_IMAGE_INVALID_DATA, CVRES_IMAGE_UNKNOWN_TYPE, CVRES_IMAGE_UNSUPPORTED_FORMAT, CVRES_OUT_OF_MEMORY, and SetFromWin32Bmp().

Referenced by CVVidCaptureDSWin32::Grab(), and CVVidCaptureDSWin32::SampleCB().

CVRES CVImage::CreateImage CVIMAGE_TYPE  type,
CVImage *&  image,
int  width,
int  height,
bool  init = true
[static]
 

CreateImage creates an image of the appropriate type.

Use this instead of new to create image objects. If width and height are non-zero, creates the appropriate memory for the image and adds a reference. Otherwise, does not create memory buffer or add reference.

Call CVImage::ReleaseImage() on the returned image when done.

Parameters:
type - specifies the type of image to create.
image - uninitialized image ptr. Set on return.
width - desired width of image in pixels.
height - desired height of image in pixels.
init - if true, image data is set to 0.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::ReleaseImage()

Definition at line 116 of file CVImage.cpp.

References Create(), CVAssert, CVIMAGE_DEFAULT, CVIMAGE_GREY, CVIMAGE_RGB24, CVIMAGE_RGBFLOAT, CVRES, CVRES_IMAGE_UNKNOWN_TYPE, CVRES_OUT_OF_MEMORY, and CVRES_SUCCESS.

Referenced by CopyImage(), CreateCompatible(), CreateSub(), CVSaveImage(), and Load().

CVRES CVImage::CreateSub const CVImage orgImg,
CVImage *&  dstImg,
int  xOffset,
int  yOffset,
int  width,
int  height
[static]
 

CreateSub creates a sub-image of the specified parent.

dstImage should not be instantiated prior to calling CreateSub. Sub image is returned in dstImage.

The sub image references the parent's fData member, and the parent image must not be deleted before you are done using the sub image.

You may create a sub image of a sub image, ad infinum. It'll handle the offsets. Call CVImage::ReleaseImage() when done.

Parameters:
orgImg - parent image to derive subimage from.
dstImg - uninitialized image ptr. Set on return.
xOffset - relative x offset for top-left of sub image.
yOffset - relative y offset for top-left of sub image.
width - width of sub image.
height - height of sub image.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::ReleaseImage()

CVImage::SetSubPosition()

Definition at line 260 of file CVImage.cpp.

References AddRef(), CreateImage(), CVAssert, CVFAILED, CVRES, CVRES_IMAGE_INVALID_SUB_POSITION, CVRES_SUCCESS, fData, fHeight, fOwnData, fParentImage, fWidth, fXOffset, fYOffset, and GetImageType().

Referenced by capCallback().

unsigned long CVImage::DecRef  ) 
 

DecRef decrements our reference count and calls ReleaseImage() on our parent if one exists.

Returns:
long - current reference count

Definition at line 530 of file CVImage.cpp.

References CVAssert, fParentImage, fRefCount, and ReleaseImage().

Referenced by ReleaseImage(), and ~CVImage().

virtual int CVImage::GetBytesPerPixel  )  const [pure virtual]
 

GetBytesPerPixel retrieves the number of bytes per pixel. Note that pixel can be in floating point or integer format, depending on the image type.

Returns:
int - bytes per pixel
See also:
GetNumChannels()

Implemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Referenced by AbsSize(), CopyImage(), Create(), CVImgStructFromImage(), CVSaveImage(), DllCaptureCb(), Load(), Save(), and Size().

virtual CVIMAGE_TYPE CVImage::GetImageType  )  const [pure virtual]
 

GetImageType() retrieves the image type. See CVIMAGE_TYPE enum.

Returns:
CVIMAGE_TYPE specifying the image's type.

Implemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Referenced by CopyImage(), CreateCompatible(), CreateSub(), CVImgStructFromImage(), and DllCaptureCb().

template<class PixelTypeT>
CVRES CVImage::GetMaxPixel PixelTypeT &  maxVal  )  const [inline, protected]
 

GetMaxPixel() provides an easy way to retrieve the maximum pixel value.

Right now, we call it from GetMaxPixelValue() in the child classes, so the caller doesn't have to deal with undue templating and we don't have to deal with rewriting the code each time.

Note that the PixelTypeT type is specific to the type of image. CVImageGrey uses an unsigned character, CVImageRGBFloat uses a float, etc. Using the wrong type is a good way to go haywire in the memory, which is one reason why this is protected and encapsulated via GetMaxPixelValue().

Parameters:
maxVal - reference to value, set on return. Must be of the same pixel type that the image contains.
Returns:
CVRES result code.
See also:
GetMaxPixelValue()

Definition at line 666 of file CVImage.h.

References AbsWidth(), CVAssert, CVMax(), CVRES, CVRES_IMAGE_MUST_INITIALIZE_ERR, CVRES_SUCCESS, fData, fHeight, fWidth, GetNumChannels(), XOffsetAbs(), and YOffsetAbs().

Referenced by CVImageRGBFloat::GetMaxPixelValue(), CVImageRGB24::GetMaxPixelValue(), and CVImageGrey::GetMaxPixelValue().

virtual CVRES CVImage::GetMaxPixelValue float &  maxValue  )  const [pure virtual]
 

GetMaxPixelValue() retrieves the maximum value of any pixel in the image.

In multichannel images (e.g. RGB triplets), it will return the maximum value on any of the channels.

All child classes should implement this.

Parameters:
maxValue - reference to max pixel value, set on return.
Returns:
CVRES result code
See also:
GetPixel(), SetPixel(), GetMaxPixel()

Implemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Referenced by Save().

virtual int CVImage::GetNumChannels  )  const [pure virtual]
 

GetNumChannels retrieves the number of channels per pixel. This is one in greyscale, 3 in RGB, and 4 in RGBA

Returns:
int - number of channels per pixel.
See also:
GetBytesPerPixel()

Implemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Referenced by CVImgStructFromImage(), DllCaptureCb(), and GetMaxPixel().

virtual CVRES CVImage::GetPixel int  x,
int  y,
float &  r,
float &  g,
float &  b
const [pure virtual]
 

GetPixel() retrieves the red, green, and blue values for a specified pixel as floating points.

This is for convenience and prototyping - for high-speed image processing you'll need to work more directly with the image buffer.

All child classes should implement this.

Parameters:
x - x position within the image of the pixel
y - y position within the image of the pixel
r - receives the red value of the pixel
g - receives the green value of the pixel
b - receives the blue value of the pixel
Returns:
CVRES result code. CVRES_SUCCESS on success.
See also:
SetPixel()

Implemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Referenced by SlowNegateImage().

virtual const char* CVImage::GetPNMExtension  )  const [pure virtual]
 

GetPNMExtension() retrieves the default file extension for PNM file saving. (e.g. ".pgm" for greyscale)

Returns:
const char* - ASCIIZ default file extension, including preceeding '.'
See also:
Load(), Save()

Implemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Referenced by Save().

virtual char CVImage::GetPNMMagicVal  )  const [pure virtual]
 

GetPNMMagicVal() retrieves the magic value for a pnm file matching the current image format.

Returns:
char - Magic value for PNM files (e.g. '5' for 'P5' .pgm's)
See also:
Load(), Save()

Implemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Referenced by Save().

unsigned char * CVImage::GetRawDataPtr  )  const
 

GetRawDataPtr() retrieves the image data ptr.

Remember that this may be a sub image, in which case the data ptr returned is to the raw buffer of a parent image. It can also be of any format / byte size - check GetImageType() to determine how to access the buffer.

So, any time you access the raw data you should use the XOffsetAbs, YOffsetAbs, AbsWidth, and AbsHeight functions when calculating your pointers into the data.

Also remember that if you modify a sub image, you'll be modifying the parent image and any other overlapping sub images. If you want to muck with an image without messing up any others, use CVImage::CopyImage() first to get a base image that owns its own data.

Note that the xOffset and yOffset are relative to parent. They will be calculated at runtime if you call this function.

Returns:
unsigned char* to image data

Definition at line 796 of file CVImage.cpp.

References fData.

Referenced by CVImgStructFromImage(), CVSaveImage(), DllCaptureCb(), Load(), and Save().

int CVImage::Height  )  const
 

Returns height of image in pixels.

Returns:
int - Height of image

Definition at line 738 of file CVImage.cpp.

References fHeight.

Referenced by capCallback(), CopyImage(), CreateCompatible(), CVImgStructFromImage(), DllCaptureCb(), Save(), and SlowNegateImage().

bool CVImage::IsBigEndianMachine  )  [static]
 

IsBigEndianMachine returns true if it is on a big-endian machine, such as a Macintosh, and returns false on little-endian machines like Intel or AMD PC's.

Returns:
bool - true if big-endian, false if little-endian.

Definition at line 806 of file CVImage.cpp.

Referenced by CVImageRGBFloat::GetPNMMagicVal(), and Load().

bool CVImage::IsImageRoot  )  const
 

IsImageRoot() returns true if the image is a root (parent) image that owns its own data. If the image is a sub image, it returns false.

Returns:
bool - true if the image is a root (without a parent), or fase otherwise.

Definition at line 766 of file CVImage.cpp.

References CVAssert, fOwnData, and fParentImage.

Referenced by SetSubPosition().

CVRES CVImage::Load const char *  filename,
CVImage *&  newImage
[static]
 

Load() creates the appropriate image type based on type of file.

newImage should *not* be instantiated prior to passing it in.

Currently only supports binary .pgm, .ppm, .pxm, and .pdm formats.

.pgm and .ppm were created by Jef Poskanzer with his Portable Bitmap Utilities, and are not only very simple but also widely supported and well documented.

.pxm is based on the .ppm format, but using 32-bit floating point values for R, G, and B. The magic value used for .pxm files differs depending on endian-ness. I'm using P7 for little endian, and P8 for big-endian.

.pdm is a similar idea, but with 32-bit integer values. The magic values for .pdm files are P9 for little-endian, and PA for big-endian.

In both .pxm and .pdm files, the max value is ignored on load, although written in Save(). The max pixel value is written as 255 for .ppm's and .pgm's and is also ignored on load.

Parameters:
filename - ASCIIZ filename of the image to load
newImage - uninitialized pointer to image. Set on return.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVRES_FILE_ENUM,

CVImage::Save()

Definition at line 840 of file CVImage.cpp.

References CVFile::Close(), CreateImage(), CVAssert, CVFAILED, CVIMAGE_GREY, CVIMAGE_RGB24, CVIMAGE_RGBFLOAT, CVIMAGE_TYPE, CVRES, CVRES_FILE_DOES_NOT_EXIST, CVRES_IMAGE_FILE_CORRUPTED, CVRES_IMAGE_UNKNOWN_TYPE, CVRES_IMAGE_UNSUPPORTED_TYPE, CVRES_OUT_OF_MEMORY, CVRES_SUCCESS, CVTrace, CVFile::FileExists(), GetBytesPerPixel(), GetRawDataPtr(), IsBigEndianMachine(), CVFile::OpenForRead(), CVFile::ReadLine(), ReadNonCommentLine(), ReleaseImage(), and Size().

Referenced by CVLoadImage().

CVImage & CVImage::operator= const CVImage img  )  [protected]
 

operator= is overridden to generate an error if someone attempts to use it - Don't use it! Use CreateCopy() or CreateSub() instead depending on whether you want a deep or shallow copy of the object.

Definition at line 1278 of file CVImage.cpp.

References CVAssert.

CVRES CVImage::ReadNonCommentLine CVFile file,
char *  buffer,
int  maxBufLen
[static, protected]
 

ReadNonCommentLine() reads a non-comment line from a .p?m.

Eventually this function should be moved to an image-file handling class or image factory.

Parameters:
file - an open file to read from.
buffer - buffer to load line into
maxBufLen - max amount to read into buffer
Returns:
CVRES result code
See also:
CVFile::ReadLine(), Load()

Definition at line 1115 of file CVImage.cpp.

References CVAssert, CVFAILED, CVRES, CVRES_INVALID_PARAMETER, CVRES_SUCCESS, and CVFile::ReadLine().

Referenced by Load().

CVRES CVImage::ReleaseImage CVImage *&  image  )  [static]
 

ReleaseImage decrements the reference count of an image and will free the image if it hits zero. It may also free parent images if the specified image holds the last reference to a parent.

Parameters:
image - pointer to image to release. Is set to NULL if last reference was deleted.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::CreateImage()

Definition at line 164 of file CVImage.cpp.

References CVAssert, CVRES, CVRES_INVALID_PARAMETER, CVRES_SUCCESS, DecRef(), and fRefCount.

Referenced by capCallback(), CVDevGrabImage(), CVLoadImage(), CVSaveImage(), DecRef(), Load(), CVVidCaptureDSWin32::SampleCB(), and TestIt().

CVRES CVImage::Save const char *  filename,
const CVImage outputImage,
bool  overwrite = true
[static]
 

Save() saves an image file to disk.

Format is automatically chosen depending on image type. See Load() for comments.

File extension is appended if none is set (preferred)

Parameters:
filename - ASCIIZ filename of image to save. You do not need to include the extension - it is automatically determined.
outputImage - Image to write to the file.
overwrite - if true, overwrites the file if one already exists.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVRES_FILE_ENUM,

CVImage::Load()

Definition at line 1151 of file CVImage.cpp.

References AbsWidth(), CVFile::Close(), CVFile::Create(), CVAssert, CVFAILED, CVRES, CVRES_IMAGE_ALREADY_EXISTS, CVRES_IMAGE_EMPTY_ERR, CVRES_OUT_OF_MEMORY, CVRES_SUCCESS, CVTrace, fData, CVFile::FileExists(), GetBytesPerPixel(), GetMaxPixelValue(), GetPNMExtension(), GetPNMMagicVal(), GetRawDataPtr(), Height(), Width(), CVFile::Write(), CVFile::WriteString(), XOffsetAbs(), and YOffsetAbs().

Referenced by capCallback(), CVSaveImage(), and TestIt().

CVRES CVImage::SetFromWin32Bmp const BITMAPINFOHEADER *  bmih,
const unsigned char *  data
[protected, virtual]
 

Win32-only function for setting image data from a bitmap. WARNING: Currently only supports 24-bit uncompressed RGB bitmaps

Bitmap header and data may be freed after call - we do a deep copy of the data we care about.

Parameters:
bmih - BITMAPINFOHEADER with format information
data - raw bitmap data matching bmih format.
Returns:
CVRES result code
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM

Reimplemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Definition at line 1262 of file CVImage.cpp.

References CVAssert, CVRES, and CVRES_NOT_IMPLEMENTED.

Referenced by CreateFromWin32Bmp().

virtual CVRES CVImage::SetPixel int  x,
int  y,
float  r,
float  g,
float  b
[pure virtual]
 

SetPixel() sets the red, green, and blue pixel values for a pixel

This is for convenience and prototyping - for high-speed image processing you'll need to work more directly with the image buffer.

All child classes should implement this.

Parameters:
x - x position within the image of the pixel
y - y position within the image of the pixel
r - receives the red value of the pixel
g - receives the green value of the pixel
b - receives the blue value of the pixel
Returns:
CVRES result code. CVRES_SUCCESS on success.
See also:
GetPixel()

Implemented in CVImageGrey, CVImageRGB24, and CVImageRGBFloat.

Referenced by SlowNegateImage().

CVRES CVImage::SetSubPosition int  newXOffset,
int  newYOffset,
int  newWidth,
int  newHeight
 

SetSubPosition() moves the ROI of the image within its parent. Will return CVRES_IMAGE_OPERATION_INVALID_ON_ROOT if you try to use this on a root image instead of a sub image.

Parameters:
newXOffset - relative x offset of new pos within parent.
newYOffset - relative y offset of new pos within parent.
newWidth - new width of sub image.
newHeight - new height of sub image.
Returns:
CVRES result code.
See also:
CVRES_CORE_ENUM, CVRES_IMAGE_ENUM, CVImage::CreateSub()

Definition at line 1290 of file CVImage.cpp.

References CVAssert, CVRES, CVRES_IMAGE_INVALID_SUB_POSITION, CVRES_IMAGE_OPERATION_INVALID_ON_ROOT, CVRES_SUCCESS, fData, fHeight, fParentImage, fWidth, fXOffset, fYOffset, and IsImageRoot().

int CVImage::Size  )  const
 

Returns size of image buffer in bytes.

Returns:
int - Size of image in bytes

Definition at line 747 of file CVImage.cpp.

References fHeight, fWidth, and GetBytesPerPixel().

Referenced by Load().

int CVImage::Width  )  const
 

Returns width of image in pixels.

Returns:
int - Width of image

Definition at line 729 of file CVImage.cpp.

References fWidth.

Referenced by capCallback(), CopyImage(), CreateCompatible(), CVImgStructFromImage(), DllCaptureCb(), Save(), and SlowNegateImage().

int CVImage::XOffsetAbs  )  const
 

Returns absolute X offset within fData.

Returns:
int - Absolute x offset of current image within root

Definition at line 664 of file CVImage.cpp.

References fParentImage, and fXOffset.

Referenced by CopyImage(), GetMaxPixel(), CVImageRGBFloat::GetPixel(), CVImageRGB24::GetPixel(), CVImageGrey::GetPixel(), Save(), CVImageRGBFloat::SetPixel(), CVImageRGB24::SetPixel(), and CVImageGrey::SetPixel().

int CVImage::XOffsetRel  )  const
 

Returns relative offset within parent image.

Returns:
int - X Offset relative to parent.

Definition at line 646 of file CVImage.cpp.

References fXOffset.

Referenced by CopyImage().

int CVImage::YOffsetAbs  )  const
 

Returns absolute Y offset within fData.

Returns:
int - Absolute y offset of current image within root

Definition at line 682 of file CVImage.cpp.

References fParentImage, and fYOffset.

Referenced by CopyImage(), GetMaxPixel(), CVImageRGBFloat::GetPixel(), CVImageRGB24::GetPixel(), CVImageGrey::GetPixel(), Save(), CVImageRGBFloat::SetPixel(), CVImageRGB24::SetPixel(), and CVImageGrey::SetPixel().

int CVImage::YOffsetRel  )  const
 

Returns relative offset within parent image.

Returns:
int - Y Offset relative to parent.

Definition at line 655 of file CVImage.cpp.

References fYOffset.

Referenced by CopyImage().


Member Data Documentation

unsigned char* CVImage::fData [protected]
 

Definition at line 718 of file CVImage.h.

Referenced by Clear(), CopyImage(), Create(), CreateSub(), CVImage(), GetMaxPixel(), CVImageRGBFloat::GetPixel(), CVImageRGB24::GetPixel(), CVImageGrey::GetPixel(), GetRawDataPtr(), Save(), CVImageRGBFloat::SetFromWin32Bmp(), CVImageRGB24::SetFromWin32Bmp(), CVImageGrey::SetFromWin32Bmp(), CVImageRGBFloat::SetPixel(), CVImageRGB24::SetPixel(), CVImageGrey::SetPixel(), SetSubPosition(), and ~CVImage().

int CVImage::fHeight [protected]
 

Definition at line 717 of file CVImage.h.

Referenced by AbsHeight(), CopyImage(), Create(), CreateSub(), CVImage(), GetMaxPixel(), CVImageRGBFloat::GetPixel(), CVImageRGB24::GetPixel(), CVImageGrey::GetPixel(), Height(), CVImageRGBFloat::SetFromWin32Bmp(), CVImageRGB24::SetFromWin32Bmp(), CVImageGrey::SetFromWin32Bmp(), CVImageRGBFloat::SetPixel(), CVImageRGB24::SetPixel(), CVImageGrey::SetPixel(), SetSubPosition(), and Size().

bool CVImage::fOwnData [protected]
 

Definition at line 729 of file CVImage.h.

Referenced by Create(), CreateSub(), CVImage(), IsImageRoot(), and ~CVImage().

CVImage* CVImage::fParentImage [protected]
 

Definition at line 733 of file CVImage.h.

Referenced by AbsHeight(), AbsWidth(), AddRef(), CreateSub(), CVImage(), DecRef(), IsImageRoot(), SetSubPosition(), XOffsetAbs(), and YOffsetAbs().

unsigned long CVImage::fRefCount [protected]
 

Definition at line 732 of file CVImage.h.

Referenced by AddRef(), CVImage(), DecRef(), ReleaseImage(), and ~CVImage().

int CVImage::fWidth [protected]
 

Definition at line 716 of file CVImage.h.

Referenced by AbsWidth(), CopyImage(), Create(), CreateSub(), CVImage(), GetMaxPixel(), CVImageRGBFloat::GetPixel(), CVImageRGB24::GetPixel(), CVImageGrey::GetPixel(), CVImageRGBFloat::SetFromWin32Bmp(), CVImageRGB24::SetFromWin32Bmp(), CVImageGrey::SetFromWin32Bmp(), CVImageRGBFloat::SetPixel(), CVImageRGB24::SetPixel(), CVImageGrey::SetPixel(), SetSubPosition(), Size(), and Width().

int CVImage::fXOffset [protected]
 

Definition at line 723 of file CVImage.h.

Referenced by CreateSub(), CVImage(), SetSubPosition(), XOffsetAbs(), and XOffsetRel().

int CVImage::fYOffset [protected]
 

Definition at line 726 of file CVImage.h.

Referenced by CreateSub(), CVImage(), SetSubPosition(), YOffsetAbs(), and YOffsetRel().


The documentation for this class was generated from the following files:

Generated on Mon Mar 1 13:27:13 2004 for VidCapture Library by doxygen 1.3.3
CodeVis VidCapture 0.2 Copyright © 2003-2004 by Michael Ellison.