KiCad PCB EDA Suite
cimage.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef CIMAGE_H
31 #define CIMAGE_H
32 
33 #include <wx/string.h>
34 
36 enum E_IMAGE_OP {
48 };
49 
50 
52 enum E_WRAP {
56 };
57 
58 
60 enum E_FILTER {
72 };
73 
75 typedef struct {
76  signed char kernel[5][5];
77  unsigned int div;
78  unsigned char offset;
79 }S_FILTER;
80 
81 
86 class CIMAGE
87 {
88 
89 public:
90 
97  CIMAGE( unsigned int aXsize, unsigned int aYsize );
98 
105  CIMAGE( const CIMAGE &aSrcImage );
106 
107  ~CIMAGE();
108 
117  void Setpixel( int aX, int aY, unsigned char aValue );
118 
127  unsigned char Getpixel( int aX, int aY ) const;
128 
136  void Hline( int aXStart, int aXEnd, int aY, unsigned char aValue );
137 
145  void CircleFilled( int aCx, int aCy, int aRadius, unsigned char aValue );
146 
166  void CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOperation );
167 
172  void Invert();
173 
181  void EfxFilter( CIMAGE *aInImg, E_FILTER aFilterType );
182 
189  void SaveAsPNG( wxString aFileName ) const;
190 
197  void SetPixelsFromNormalizedFloat( const float * aNormalizedFloatArray );
198 
204  unsigned char* GetBuffer() const;
205 
206  unsigned int GetWidth() const { return m_width; }
207  unsigned int GetHeight() const { return m_height; }
208 private:
209 
217  bool wrapCoords( int *aXo, int *aYo ) const;
218 
219  void plot8CircleLines( int aCx, int aCy, int aX, int aY, unsigned char aValue );
220 
221 private:
222  unsigned char* m_pixels;
223  unsigned int m_width;
224  unsigned int m_height;
225  unsigned int m_wxh;
227 };
228 
229 #endif // CIMAGE_H
Coords are wrapped arround.
Definition: cimage.h:55
bool wrapCoords(int *aXo, int *aYo) const
Function wrapCoords calculate the coordinates points in accord with the current clamping settings...
Definition: cimage.cpp:73
~CIMAGE()
Definition: cimage.cpp:61
unsigned int m_height
height of the image
Definition: cimage.h:224
unsigned char * GetBuffer() const
Function GetBuffer get the image buffer pointer.
Definition: cimage.cpp:67
unsigned char Getpixel(int aX, int aY) const
Function Getpixel get the pixel value from pixel position, position is clamped in accord with the cur...
Definition: cimage.cpp:124
unsigned char * m_pixels
buffer to store the image 8bit-channel
Definition: cimage.h:222
void Hline(int aXStart, int aXEnd, int aY, unsigned char aValue)
hline - Draws an horizontal line
Definition: cimage.cpp:133
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
CircleFilled.
Definition: cimage.cpp:168
void Setpixel(int aX, int aY, unsigned char aValue)
Function Setpixel set a value in a pixel position, position is clamped in accord with the current cla...
Definition: cimage.cpp:117
unsigned int GetHeight() const
Definition: cimage.h:207
CIMAGE(unsigned int aXsize, unsigned int aYsize)
Constructor CIMAGE constructs a CIMAGE based on image size.
Definition: cimage.cpp:39
E_IMAGE_OP
Image operation type.
Definition: cimage.h:36
unsigned int GetWidth() const
Definition: cimage.h:206
void SaveAsPNG(wxString aFileName) const
Function SaveAsPNG save image buffer to a PNG file into the working folder.
Definition: cimage.cpp:515
void CopyFull(const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOperation)
Function CopyFull perform a copy operation, based on operation type.
Definition: cimage.cpp:200
void Invert()
Function Invert invert the values of image this <- (255 - this)
Definition: cimage.cpp:193
unsigned char offset
Definition: cimage.h:78
unsigned int m_width
width of the image
Definition: cimage.h:223
unsigned int m_wxh
width * height precalc value
Definition: cimage.h:225
void plot8CircleLines(int aCx, int aCy, int aX, int aY, unsigned char aValue)
Definition: cimage.cpp:108
E_WRAP m_wraping
current wrapping type
Definition: cimage.h:226
Coords that wraps are not evaluated.
Definition: cimage.h:53
unsigned int div
Definition: cimage.h:77
Definition: cimage.h:43
5x5 Filter struct parameters
Definition: cimage.h:75
E_FILTER
Filter type enumeration.
Definition: cimage.h:60
void SetPixelsFromNormalizedFloat(const float *aNormalizedFloatArray)
Function SetPixelsFromNormalizedFloat set the current channel from a float normalized (0...
Definition: cimage.cpp:503
Class CIMAGE manages a 8-bit channel image.
Definition: cimage.h:86
void EfxFilter(CIMAGE *aInImg, E_FILTER aFilterType)
Function EfxFilter apply a filter to the input image and stores it in the image class this <- FilterT...
Definition: cimage.cpp:465
E_WRAP
Image wrap type enumeration.
Definition: cimage.h:52
Coords are clamped to image size.
Definition: cimage.h:54