Image Class Reference

This class holds the data corresponding to the image to be displayed. More...

#include <image.h>

List of all members.

Public Member Functions

 Image ()
 Constructor for the class Image. Initializes the size to zero.
 ~Image ()
 Destructor for the class Image. Releases the memory used by the pixels.
bool IsPointInside (unsigned int x, unsigned int y) const
 Test if a point is in our 2d-array.
unsigned int GetSizeX () const
 Returns the size along X of the image.
unsigned int GetSizeY () const
 Returns the size along Y of the image.
int GetData (int x, int y) const
 Returns the data value for a given point.
bool ReadFile (const std::string &filename)
 Reads the data file and fills the 2d data array. A data file has the following structure:
.
int GetMin () const
 Return the smallest pixel value from the 2d-array.
int GetMax () const
 Return the largest pixel value from the 2d-array.
void AdjustPaletteColors ()
 Computes the extrema of the 2d data array.

Protected Member Functions

void ResetMem ()
 Reset the 2d-array holding the pixels.

Protected Attributes

std::vector< std::vector< int > > m_data
 2d-array holding the pixels values.
int m_nX
int m_nY
int m_min
 Smallest pixel value (i.e. from the 2d-array).
int m_max
 Largest pixel value (i.e. from the 2d-array).


Detailed Description

This class holds the data corresponding to the image to be displayed.

Definition at line 15 of file image.h.


Constructor & Destructor Documentation

Image::Image (  ) 

Constructor for the class Image. Initializes the size to zero.

Definition at line 14 of file image.cpp.

Image::~Image (  ) 

Destructor for the class Image. Releases the memory used by the pixels.

Definition at line 18 of file image.cpp.

References ResetMem().

Here is the call graph for this function:


Member Function Documentation

void Image::ResetMem (  )  [protected]

Reset the 2d-array holding the pixels.

Definition at line 23 of file image.cpp.

References m_data.

Referenced by ReadFile(), and ~Image().

Here is the caller graph for this function:

bool Image::IsPointInside ( unsigned int  x,
unsigned int  y 
) const

Test if a point is in our 2d-array.

Returns:
true if the point is in the array, false otherwise

Definition at line 153 of file image.cpp.

References GetSizeX(), and GetSizeY().

Referenced by GetData(), Visu2D::HandleMouse(), and Visu2D::SetTextInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Image::GetSizeX (  )  const

Returns the size along X of the image.

Returns:
the size along X of the image

Definition at line 157 of file image.cpp.

References m_data.

Referenced by AdjustPaletteColors(), IsPointInside(), and Visu2D::UpdateDataAndPixmap().

Here is the caller graph for this function:

unsigned int Image::GetSizeY (  )  const

Returns the size along Y of the image.

Returns:
the size along X of the image

Definition at line 162 of file image.cpp.

References m_data.

Referenced by AdjustPaletteColors(), IsPointInside(), and Visu2D::UpdateDataAndPixmap().

Here is the caller graph for this function:

int Image::GetData ( int  x,
int  y 
) const

Returns the data value for a given point.

Parameters:
x : abscissa of the point
y : ordinate of the point
Returns:
the data value for the point x,y

Definition at line 145 of file image.cpp.

References IsPointInside(), and m_data.

Referenced by AdjustPaletteColors(), Visu2D::SetTextInfo(), Rectangle::SumValues(), and Visu2D::UpdateDataAndPixmap().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Image::ReadFile ( const std::string &  filename  ) 

Reads the data file and fills the 2d data array. A data file has the following structure:
.

  • WIDTH value
    HEIGHT value
    PIXELS
    data_x0_y0 data_x1_y0 data_x3_y0 ....
    data_x0_y1 data_x1_y1 data_x3_y1 ....
    ...
    IMAGE_END
Which would look like :
  • WIDTH 3
    HEIGHT 4
    PIXELS
    3 1 3
    3 4 8
    6 1 3
    1 9 3
    IMAGE_END
See also:
WFrame::ReadImage() : This method calls ReadFile and one just needs to click on the menu File->Read image to trigger the corresponding action.
Parameters:
filename : name of the data file
Returns:
true if everything went right.

A data file has the following structure:

  • WIDTH value
    HEIGHT value
    PIXELS
    data_x0_y0 data_x1_y0 data_x3_y0 ....
    data_x0_y1 data_x1_y1 data_x3_y1 ....
    ...
    IMAGE_END

Which would look like :

  • WIDTH 3
    HEIGHT 4
    PIXELS
    3 1 3
    3 4 8
    6 1 3
    1 9 3
    IMAGE_END

Definition at line 31 of file image.cpp.

References AdjustPaletteColors(), m_data, m_nX, m_nY, and ResetMem().

Referenced by WFrame::ReadImage().

Here is the call graph for this function:

int Image::GetMin (  )  const

Return the smallest pixel value from the 2d-array.

Definition at line 171 of file image.cpp.

References m_min.

Referenced by WFrame::ReadImage().

int Image::GetMax (  )  const

Return the largest pixel value from the 2d-array.

Definition at line 175 of file image.cpp.

References m_max.

Referenced by WFrame::ReadImage().

void Image::AdjustPaletteColors (  ) 

Computes the extrema of the 2d data array.

Definition at line 128 of file image.cpp.

References GetData(), GetSizeX(), GetSizeY(), m_max, and m_min.

Referenced by ReadFile().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

std::vector< std::vector < int > > Image::m_data [protected]

2d-array holding the pixels values.

Definition at line 30 of file image.h.

Referenced by GetData(), GetSizeX(), GetSizeY(), ReadFile(), and ResetMem().

int Image::m_nX [protected]

max size in X of 2d-array holding the pixels values.

Definition at line 33 of file image.h.

Referenced by ReadFile().

int Image::m_nY [protected]

max size in Y of 2d-array holding the pixels values.

Definition at line 36 of file image.h.

Referenced by ReadFile().

int Image::m_min [protected]

Smallest pixel value (i.e. from the 2d-array).

Definition at line 39 of file image.h.

Referenced by AdjustPaletteColors(), and GetMin().

int Image::m_max [protected]

Largest pixel value (i.e. from the 2d-array).

Definition at line 42 of file image.h.

Referenced by AdjustPaletteColors(), and GetMax().


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

Generated on Tue Sep 13 10:10:23 2011 for DrawQt by  doxygen 1.5.6