KiCad PCB EDA Suite
Loading...
Searching...
No Matches
IMAGE Class Reference

Manage an 8-bit channel image. More...

#include <image.h>

Public Member Functions

 IMAGE (unsigned int aXsize, unsigned int aYsize)
 Construct a IMAGE based on image size.
 
 IMAGE (const IMAGE &aSrcImage)
 Construct a IMAGE based from an existing image.
 
 ~IMAGE ()
 
void Setpixel (int aX, int aY, unsigned char aValue)
 Set a value in a pixel position, position is clamped in accordance with the current clamp settings.
 
unsigned char Getpixel (int aX, int aY) const
 Get the pixel value from pixel position, position is clamped in accord with the current clamp settings.
 
void Hline (int aXStart, int aXEnd, int aY, unsigned char aValue)
 Draw a horizontal line.
 
void CircleFilled (int aCx, int aCy, int aRadius, unsigned char aValue)
 
void CopyFull (const IMAGE *aImgA, const IMAGE *aImgB, IMAGE_OP aOperation)
 Perform a copy operation based on aOperation type.
 
void Invert ()
 Invert the values of this image <- (255 - this)
 
void EfxFilter (IMAGE *aInImg, IMAGE_FILTER aFilterType)
 Apply a filter to the input image and store it in the image class.
 
void EfxFilter_SkipCenter (IMAGE *aInImg, IMAGE_FILTER aFilterType, unsigned int aRadius)
 Apply a filter to the input image and store it in the image class.
 
void SaveAsPNG (const wxString &aFileName) const
 Save image buffer to a PNG file into the working folder.
 
void SetPixelsFromNormalizedFloat (const float *aNormalizedFloatArray)
 Set the current channel from a float normalized (0.0 - 1.0) buffer.
 
unsigned char * GetBuffer () const
 Get the image buffer pointer.
 
unsigned int GetWidth () const
 
unsigned int GetHeight () const
 

Private Member Functions

bool wrapCoords (int *aXo, int *aYo) const
 Calculate the coordinates points in accord with the current clamping settings.
 
void plot8CircleLines (int aCx, int aCy, int aX, int aY, unsigned char aValue)
 

Private Attributes

unsigned char * m_pixels
 buffer to store the image 8bit-channel
 
unsigned int m_width
 width of the image
 
unsigned int m_height
 height of the image
 
unsigned int m_wxh
 width * height precalc value
 
IMAGE_WRAP m_wraping
 current wrapping type
 

Detailed Description

Manage an 8-bit channel image.

Definition at line 89 of file image.h.

Constructor & Destructor Documentation

◆ IMAGE() [1/2]

IMAGE::IMAGE ( unsigned int  aXsize,
unsigned int  aYsize 
)

Construct a IMAGE based on image size.

Parameters
aXsizex size
aYsizey size

Definition at line 45 of file image.cpp.

References m_height, m_pixels, m_width, m_wraping, and m_wxh.

◆ IMAGE() [2/2]

IMAGE::IMAGE ( const IMAGE aSrcImage)

Construct a IMAGE based from an existing image.

It will make a copy the aSrcImage.

Parameters
aSrcImage

Definition at line 56 of file image.cpp.

References GetBuffer(), GetHeight(), GetWidth(), m_height, m_pixels, m_width, m_wraping, and m_wxh.

◆ ~IMAGE()

IMAGE::~IMAGE ( )

Definition at line 67 of file image.cpp.

References m_pixels.

Member Function Documentation

◆ CircleFilled()

void IMAGE::CircleFilled ( int  aCx,
int  aCy,
int  aRadius,
unsigned char  aValue 
)

Definition at line 173 of file image.cpp.

References plot8CircleLines().

Referenced by RENDER_3D_OPENGL::initializeOpenGL().

◆ CopyFull()

void IMAGE::CopyFull ( const IMAGE aImgA,
const IMAGE aImgB,
IMAGE_OP  aOperation 
)

Perform a copy operation based on aOperation type.

The available image operations.

  • IMAGE_OP::RAW this <- aImgA
  • IMAGE_OP::ADD this <- CLAMP(aImgA + aImgB)
  • IMAGE_OP::SUB this <- CLAMP(aImgA - aImgB)
  • IMAGE_OP::DIF this <- abs(aImgA - aImgB)
  • IMAGE_OP::MUL this <- aImgA * aImgB
  • IMAGE_OP::AND this <- aImgA & aImgB
  • IMAGE_OP::OR this <- aImgA | aImgB
  • IMAGE_OP::XOR this <- aImgA ^ aImgB
  • IMAGE_OP::BLEND50 this <- (aImgA + aImgB) / 2
  • IMAGE_OP::MIN this <- (aImgA < aImgB) ? aImgA : aImgB
  • IMAGE_OP::MAX this <- (aImgA > aImgB) ? aImgA : aImgB
Parameters
aImgAan image input.
aImgBan image input.
aOperationoperation to perform

Definition at line 205 of file image.cpp.

References m_pixels, and m_wxh.

◆ EfxFilter()

void IMAGE::EfxFilter ( IMAGE aInImg,
IMAGE_FILTER  aFilterType 
)

Apply a filter to the input image and store it in the image class.

Parameters
aInImginput image
aFilterTypefilter type to apply
Todo:
: This function can be optimized slipping it between the edges and do it without use the getpixel function. Optimization can be done to m_pixels[ix + iy * m_width] but keep in mind the parallel process of the algorithm
Todo:
This needs to write to a separate buffer.

Definition at line 474 of file image.cpp.

References filter, FILTERS, m_height, and m_wraping.

◆ EfxFilter_SkipCenter()

void IMAGE::EfxFilter_SkipCenter ( IMAGE aInImg,
IMAGE_FILTER  aFilterType,
unsigned int  aRadius 
)

Apply a filter to the input image and store it in the image class.

skip the circle center defined by radius

Parameters
aInImginput image
aFilterTypefilter type to apply
aRadiuscenter circle that the effect will not be applied

Definition at line 527 of file image.cpp.

References CLAMP, filter, FILTERS, Getpixel(), m_height, m_pixels, m_width, and m_wraping.

Referenced by RENDER_3D_OPENGL::initializeOpenGL().

◆ GetBuffer()

unsigned char * IMAGE::GetBuffer ( ) const

Get the image buffer pointer.

Returns
unsigned char* the pointer of the buffer 8bit channel.

Definition at line 73 of file image.cpp.

References m_pixels.

Referenced by IMAGE(), and OglLoadTexture().

◆ GetHeight()

unsigned int IMAGE::GetHeight ( ) const
inline

Definition at line 214 of file image.h.

References m_height.

Referenced by IMAGE(), RENDER_3D_OPENGL::initializeOpenGL(), and OglLoadTexture().

◆ Getpixel()

unsigned char IMAGE::Getpixel ( int  aX,
int  aY 
) const

Get the pixel value from pixel position, position is clamped in accord with the current clamp settings.

Parameters
aXx position
aYy position
Returns
unsigned char - pixel value

Definition at line 130 of file image.cpp.

References m_pixels, m_width, and wrapCoords().

Referenced by EfxFilter_SkipCenter().

◆ GetWidth()

unsigned int IMAGE::GetWidth ( ) const
inline

Definition at line 213 of file image.h.

References m_width.

Referenced by IMAGE(), RENDER_3D_OPENGL::initializeOpenGL(), and OglLoadTexture().

◆ Hline()

void IMAGE::Hline ( int  aXStart,
int  aXEnd,
int  aY,
unsigned char  aValue 
)

Draw a horizontal line.

Parameters
aXStartx start position
aXEndx end position
aYy position
aValuevalue to add

Definition at line 139 of file image.cpp.

References m_height, m_pixels, m_width, and swap.

Referenced by plot8CircleLines().

◆ Invert()

void IMAGE::Invert ( )

Invert the values of this image <- (255 - this)

Definition at line 198 of file image.cpp.

References m_pixels, and m_wxh.

◆ plot8CircleLines()

void IMAGE::plot8CircleLines ( int  aCx,
int  aCy,
int  aX,
int  aY,
unsigned char  aValue 
)
private

Definition at line 114 of file image.cpp.

References Hline().

Referenced by CircleFilled().

◆ SaveAsPNG()

void IMAGE::SaveAsPNG ( const wxString &  aFileName) const

Save image buffer to a PNG file into the working folder.

Each RGB channel will have the 8bit-channel from the image.

Parameters
aFileNamefile name (without extension)

Definition at line 597 of file image.cpp.

References DBG_SaveBuffer(), m_height, m_pixels, and m_width.

◆ Setpixel()

void IMAGE::Setpixel ( int  aX,
int  aY,
unsigned char  aValue 
)

Set a value in a pixel position, position is clamped in accordance with the current clamp settings.

Parameters
aXx position
aYy position
aValuevalue to set the pixel

Definition at line 123 of file image.cpp.

References m_pixels, m_width, and wrapCoords().

◆ SetPixelsFromNormalizedFloat()

void IMAGE::SetPixelsFromNormalizedFloat ( const float *  aNormalizedFloatArray)

Set the current channel from a float normalized (0.0 - 1.0) buffer.

this <- CLAMP(NormalizedFloat * 255)

Parameters
aNormalizedFloatArraya float array with the same size of the image

Definition at line 585 of file image.cpp.

References CLAMP, m_pixels, and m_wxh.

◆ wrapCoords()

bool IMAGE::wrapCoords ( int *  aXo,
int *  aYo 
) const
private

Calculate the coordinates points in accord with the current clamping settings.

Parameters
aXoX coordinate to be converted (output).
aXoY coordinate to be converted (output).
Returns
bool - true if the coordinates are inside the image, false otherwise.

Definition at line 79 of file image.cpp.

References m_height, m_width, and m_wraping.

Referenced by Getpixel(), and Setpixel().

Member Data Documentation

◆ m_height

unsigned int IMAGE::m_height
private

height of the image

Definition at line 230 of file image.h.

Referenced by EfxFilter(), EfxFilter_SkipCenter(), GetHeight(), Hline(), IMAGE(), SaveAsPNG(), and wrapCoords().

◆ m_pixels

unsigned char* IMAGE::m_pixels
private

buffer to store the image 8bit-channel

Definition at line 228 of file image.h.

Referenced by CopyFull(), EfxFilter_SkipCenter(), GetBuffer(), Getpixel(), Hline(), IMAGE(), Invert(), SaveAsPNG(), Setpixel(), SetPixelsFromNormalizedFloat(), and ~IMAGE().

◆ m_width

unsigned int IMAGE::m_width
private

width of the image

Definition at line 229 of file image.h.

Referenced by EfxFilter_SkipCenter(), Getpixel(), GetWidth(), Hline(), IMAGE(), SaveAsPNG(), Setpixel(), and wrapCoords().

◆ m_wraping

IMAGE_WRAP IMAGE::m_wraping
private

current wrapping type

Definition at line 232 of file image.h.

Referenced by EfxFilter(), EfxFilter_SkipCenter(), IMAGE(), and wrapCoords().

◆ m_wxh

unsigned int IMAGE::m_wxh
private

width * height precalc value

Definition at line 231 of file image.h.

Referenced by CopyFull(), IMAGE(), Invert(), and SetPixelsFromNormalizedFloat().


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