29#include <wx/mstream.h>
51 return m_image.LoadFile( aFileName );
59 wxMemoryInputStream stream( aMemBuffer.GetData(), aMemBuffer.GetDataLen() );
63 return m_image.LoadFile( stream );
67static int imageResolution(
const wxImage& aImage,
const wxString& aOption,
int aDefault )
71 wxString resolution = aImage.GetOption( aOption );
73 resolution.ToCDouble( &dpi );
78 if( aImage.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT ) == wxIMAGE_RESOLUTION_CM )
136 std::vector<VECTOR2D> vertices;
140 for(
int jj = 0; jj < outline.
PointCount(); jj++ )
static int imageResolution(const wxImage &aImage, const wxString &aOption, int aDefault)
static const double TRACE_SUBUNITS
Sub units per pixel while tracing. A whole pixel is too coarse a step for the integer tracer.
static const double MM_PER_INCH
wxImage ConvertImageToBilevel(const wxImage &aImage, double aThreshold, bool aInvert)
Reduce an image to pure black and white.
SHAPE_POLY_SET TraceBilevelImage(const wxImage &aBilevelImage, double aScaleX, double aScaleY, REPORTER &aReporter)
Trace the black regions of a black and white image into filled polygons.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
bool Load(const wxString &aFileName) override
Load file for import.
double GetImageWidth() const override
Return image width from original imported file.
void ReportMsg(const wxString &aMessage) override
double pixelSizeYmm() const
bool LoadFromMemory(const wxMemoryBuffer &aMemBuffer) override
Set memory buffer with content for import.
bool Import() override
Actually imports the file.
BOX2D GetImageBBox() const override
Return image bounding box from original imported file.
static constexpr int DEFAULT_DPI
Resolution assumed for images that do not carry one.
double GetImageHeight() const override
Return image height from original imported file.
double pixelSizeXmm() const
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
GRAPHICS_IMPORTER * m_importer
Importer used to create objects representing the imported shapes.
A clone of IMPORTED_STROKE, but with floating-point width.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
A wrapper for reporting to a wxString object.
IbisParser parser & reporter
VECTOR2< double > VECTOR2D