KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerber_to_png.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) 2025 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef GERBER_TO_PNG_H
21#define GERBER_TO_PNG_H
22
23#include <wx/string.h>
24#include <wx/arrstr.h>
25#include <gal/color4d.h>
26#include <math/box2.h>
27#include <math/vector2d.h>
28#include <memory>
29
32
33
37bool IsExcellonFile( const wxString& aPath );
38
39
44
45
51std::unique_ptr<GERBER_FILE_IMAGE> LoadGerberOrExcellon( const wxString& aPath, wxString* aErrorMsg,
52 wxArrayString* aMessages = nullptr );
53
54
59{
60 int dpi = 300;
61 int width = 0;
62 int height = 0;
63 bool antialias = true;
66
67 double originXMm = 0.0;
68 double originYMm = 0.0;
69 double windowWidthMm = 0.0;
70 double windowHeightMm = 0.0;
71
73 {
74 return windowWidthMm > 0.0 && windowHeightMm > 0.0;
75 }
76};
77
78
90
91static constexpr int MIN_PIXEL_SIZE = 10;
92
101GERBER_PLOTTER_VIEWPORT CalculatePlotterViewport( const BOX2I& aBBox, int aDpi, int aWidth, int aHeight );
102
103
117bool RenderGerberToPng( const wxString& aInputPath, const wxString& aOutputPath, const GERBER_RENDER_OPTIONS& aOptions,
118 wxString* aErrorMsg = nullptr, wxArrayString* aMessages = nullptr );
119
120
131bool RenderGerberToPng( const wxString& aInputPath, const wxString& aOutputPath, const JOB_GERBER_EXPORT_PNG& aJob,
132 wxString* aErrorMsg = nullptr, wxArrayString* aMessages = nullptr );
133
134
135#endif // GERBER_TO_PNG_H
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
Hold the image data and parameters for one gerber file and layer parameters.
Job to convert Gerber/Excellon files to PNG images.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
static const COLOR4D BLACK
Definition color4d.h:406
static constexpr int MIN_PIXEL_SIZE
GERBER_PLOTTER_VIEWPORT CalculatePlotterViewport(const BOX2I &aBBox, int aDpi, int aWidth, int aHeight)
Compute pixel dimensions and plotter scale from a bounding box and DPI/size settings.
std::unique_ptr< GERBER_FILE_IMAGE > LoadGerberOrExcellon(const wxString &aPath, wxString *aErrorMsg, wxArrayString *aMessages=nullptr)
Load a Gerber or Excellon file, auto-detecting by extension.
bool IsExcellonFile(const wxString &aPath)
Determine if a file is an Excellon drill file based on extension.
BOX2I CalculateGerberBoundingBox(GERBER_FILE_IMAGE *aImage)
Calculate bounding box for all draw items in a gerber image.
bool RenderGerberToPng(const wxString &aInputPath, const wxString &aOutputPath, const GERBER_RENDER_OPTIONS &aOptions, wxString *aErrorMsg=nullptr, wxArrayString *aMessages=nullptr)
Render a Gerber or Excellon file to PNG.
Computed plotter viewport parameters from a bounding box and render settings.
Render options for Gerber to PNG conversion.
double windowWidthMm
Viewport width in mm (> 0 enables viewport mode)
KIGFX::COLOR4D foregroundColor
KIGFX::COLOR4D backgroundColor
Transparent white.
int height
0 = calculate from DPI
int width
0 = calculate from DPI
double originYMm
Viewport origin Y in mm.
bool HasViewportOverride() const
double windowHeightMm
Viewport height in mm (> 0 enables viewport mode)
double originXMm
Viewport origin X in mm.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687