KiCad PCB EDA Suite
Loading...
Searching...
No Matches
image.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 <[email protected]>
5 * Copyright The 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, see <https://www.gnu.org/licenses/>.
19 */
20
25
26#ifndef IMAGE_H
27#define IMAGE_H
28
29#include <wx/string.h>
30
46
47
49enum class IMAGE_WRAP
50{
54};
55
56
72
75{
76 signed char kernel[5][5];
77 unsigned int div;
78 unsigned char offset;
79};
80
81
85class IMAGE
86{
87public:
94 IMAGE( unsigned int aXsize, unsigned int aYsize );
95
103 IMAGE( const IMAGE& aSrcImage );
104
105 ~IMAGE();
106
115 void Setpixel( int aX, int aY, unsigned char aValue );
116
125 unsigned char Getpixel( int aX, int aY ) const;
126
135 void Hline( int aXStart, int aXEnd, int aY, unsigned char aValue );
136
137 void CircleFilled( int aCx, int aCy, int aRadius, unsigned char aValue );
138
159 void CopyFull( const IMAGE* aImgA, const IMAGE* aImgB, IMAGE_OP aOperation );
160
164 void Invert();
165
172 void EfxFilter( IMAGE* aInImg, IMAGE_FILTER aFilterType );
173
182 void EfxFilter_SkipCenter( IMAGE* aInImg, IMAGE_FILTER aFilterType, unsigned int aRadius );
183
191 void SaveAsPNG( const wxString& aFileName ) const;
192
200 void SetPixelsFromNormalizedFloat( const float* aNormalizedFloatArray );
201
207 unsigned char* GetBuffer() const;
208
209 unsigned int GetWidth() const { return m_width; }
210 unsigned int GetHeight() const { return m_height; }
211
212private:
220 bool wrapCoords( int* aXo, int* aYo ) const;
221
222 void plot8CircleLines( int aCx, int aCy, int aX, int aY, unsigned char aValue );
223
224 unsigned char* m_pixels;
225 unsigned int m_width;
226 unsigned int m_height;
227 unsigned int m_wxh;
229};
230
231#endif // IMAGE_H
@ MUL
Definition am_param.h:146
@ SUB
Definition am_param.h:146
@ ADD
Definition am_param.h:146
IMAGE_WRAP m_wraping
current wrapping type
Definition image.h:228
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
Definition image.cpp:169
void EfxFilter(IMAGE *aInImg, IMAGE_FILTER aFilterType)
Apply a filter to the input image and store it in the image class.
Definition image.cpp:470
void CopyFull(const IMAGE *aImgA, const IMAGE *aImgB, IMAGE_OP aOperation)
Perform a copy operation based on aOperation type.
Definition image.cpp:201
unsigned int m_width
width of the image
Definition image.h:225
~IMAGE()
Definition image.cpp:63
void SaveAsPNG(const wxString &aFileName) const
Save image buffer to a PNG file into the working folder.
Definition image.cpp:593
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.
Definition image.cpp:523
unsigned char * GetBuffer() const
Get the image buffer pointer.
Definition image.cpp:69
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.
Definition image.cpp:119
unsigned int m_height
height of the image
Definition image.h:226
unsigned char * m_pixels
buffer to store the image 8bit-channel
Definition image.h:224
void Invert()
Invert the values of this image <- (255 - this)
Definition image.cpp:194
void SetPixelsFromNormalizedFloat(const float *aNormalizedFloatArray)
Set the current channel from a float normalized (0.0 - 1.0) buffer.
Definition image.cpp:581
IMAGE(unsigned int aXsize, unsigned int aYsize)
Construct a IMAGE based on image size.
Definition image.cpp:41
unsigned int GetHeight() const
Definition image.h:210
void plot8CircleLines(int aCx, int aCy, int aX, int aY, unsigned char aValue)
Definition image.cpp:110
void Hline(int aXStart, int aXEnd, int aY, unsigned char aValue)
Draw a horizontal line.
Definition image.cpp:135
unsigned char Getpixel(int aX, int aY) const
Get the pixel value from pixel position, position is clamped in accord with the current clamp setting...
Definition image.cpp:126
bool wrapCoords(int *aXo, int *aYo) const
Calculate the coordinates points in accord with the current clamping settings.
Definition image.cpp:75
unsigned int GetWidth() const
Definition image.h:209
unsigned int m_wxh
width * height precalc value
Definition image.h:227
@ MIN
@ MAX
#define CLAMP(n, min, max)
Definition image.cpp:37
IMAGE_WRAP
Image wrap type enumeration.
Definition image.h:50
@ ZERO
Coords that wraps are not evaluated.
Definition image.h:51
@ WRAP
Coords are wrapped around.
Definition image.h:53
IMAGE_FILTER
Filter type enumeration.
Definition image.h:59
@ GAUSSIAN_BLUR
Definition image.h:61
@ INVERT_BLUR
Definition image.h:63
@ GAUSSIAN_BLUR2
Definition image.h:62
IMAGE_OP
Image operation type.
Definition image.h:33
@ BLEND50
Definition image.h:42
@ OR
Definition image.h:40
@ DIF
Definition image.h:37
@ AND
Definition image.h:39
@ RAW
Definition image.h:34
@ XOR
Definition image.h:41
5x5 Filter struct parameters
Definition image.h:75
signed char kernel[5][5]
Definition image.h:76
unsigned int div
Definition image.h:77
unsigned char offset
Definition image.h:78