32#include <potracelib.h>
33#include <wx/clipbrd.h>
36#include <wx/dcclient.h>
39#define DEFAULT_DPI 300
44 m_parentFrame( aParent ),
48 for(
const wxString& unit : {
_(
"mm" ),
_(
"Inch" ),
_(
"DPI" ) } )
188 int imageDPIx =
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
189 int imageDPIy =
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
191 if( imageDPIx > 1 && imageDPIy > 1 )
193 if(
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT ) == wxIMAGE_RESOLUTION_CM )
195 imageDPIx =
KiROUND( imageDPIx * 2.54 );
196 imageDPIy =
KiROUND( imageDPIy * 2.54 );
217 wxCommandEvent
dummy;
270 text.Printf( wxS(
"%.1f" ), aSize );
272 text.Printf( wxS(
"%.2f" ), aSize );
298 case 1:
return EDA_UNITS::INCHES;
299 case 2:
return EDA_UNITS::UNSCALED;
301 default:
return EDA_UNITS::MILLIMETRES;
310 if(
m_UnitSizeX->GetValue().ToDouble( &new_size ) )
339 if(
m_UnitSizeY->GetValue().ToDouble( &new_size ) )
391 wxCommandEvent
dummy;
399 unsigned char threshold = aThreshold * 255;
400 unsigned char alpha_thresh = 0.7 * threshold;
410 if( pixel < threshold && alpha > alpha_thresh )
415 m_NB_Image.SetRGB( x, y, pixel, pixel, pixel );
494 if( wxTheClipboard->Open() )
498 wxTheClipboard->SetData(
new wxTextDataObject( buffer.c_str() ) );
499 wxTheClipboard->Flush();
500 wxTheClipboard->Close();
504 wxMessageBox(
_(
"Unable to export to the Clipboard") );
514 if( !potrace_bitmap )
516 wxMessageBox(
_(
"Error allocating memory for potrace bitmap" ) );
521 for(
int y = 0; y <
m_NB_Image.GetHeight(); y++ )
523 for(
int x = 0; x <
m_NB_Image.GetWidth(); x++ )
525 unsigned char pixel =
m_NB_Image.GetGreen( x, y );
526 BM_PUT( potrace_bitmap, x, y, pixel ? 0 : 1 );
530 wxString layer = wxT(
"F.SilkS" );
536 case 0: layer = wxT(
"F.Cu" );
break;
537 case 1: layer = wxT(
"F.SilkS" );
break;
538 case 2: layer = wxT(
"F.Mask" );
break;
539 case 3: layer = wxT(
"Dwgs.User" );
break;
540 case 4: layer = wxT(
"Cmts.User" );
break;
541 case 5: layer = wxT(
"Eco1.User" );
break;
542 case 6: layer = wxT(
"Eco2.User" );
break;
543 case 7: layer = wxT(
"F.Fab" );
break;
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
void ExportPcbnewFormat()
Generate a footprint in S expr format.
void ExportDrawingSheetFormat()
Generate a file suitable to be copied into a drawing sheet (.kicad_wks) file.
void ExportEeschemaFormat()
Generate a schematic library which contains one component: the logo.
void ExportPostScriptFormat()
Generate a postscript file.
Class BITMAP2CMP_PANEL_BASE.
wxStaticText * m_BPPValue
wxScrolledWindow * m_GreyscalePicturePanel
wxButton * m_buttonExportFile
wxScrolledWindow * m_BNPicturePanel
wxButton * m_buttonExportClipboard
wxSlider * m_sliderThreshold
wxCheckBox * m_aspectRatioCheckbox
wxRadioButton * m_rbPostscript
wxCheckBox * m_checkNegative
wxRadioButton * m_rbFootprint
wxRadioButton * m_rbWorksheet
wxStaticText * m_SizeXValue
wxRadioButton * m_rbSymbol
wxStaticText * m_layerLabel
wxStaticText * m_SizeYValue
wxStaticText * m_InputYValueDPI
wxStaticText * m_InputXValueDPI
wxScrolledWindow * m_InitialPicturePanel
void OnPaintGreyscale(wxPaintEvent &event) override
void binarize(double aThreshold)
void SetOutputSize(const IMAGE_SIZE &aSizeX, const IMAGE_SIZE &aSizeY)
void OnSizeUnitChange(wxCommandEvent &event) override
void OnSizeChangeX(wxCommandEvent &event) override
void OnPaintInit(wxPaintEvent &event) override
void OnExportToClipboard(wxCommandEvent &event) override
void LoadSettings(BITMAP2CMP_SETTINGS *aCfg)
wxImage m_Greyscale_Image
void negateGreyscaleImage()
void ToggleAspectRatioLock(wxCommandEvent &event) override
bool OpenProjectFiles(const std::vector< wxString > &aFilenames, int aCtl=0)
wxWindow * GetCurrentPage()
BITMAP2CMP_PANEL(BITMAP2CMP_FRAME *aParent)
void OnExportToFile(wxCommandEvent &event) override
void SaveSettings(BITMAP2CMP_SETTINGS *aCfg)
wxString formatOutputSize(double aSize)
void OnThresholdChange(wxScrollEvent &event) override
void ExportToBuffer(std::string &aOutput, OUTPUT_FMT_ID aFormat)
generate a export data of the current bitmap.
BITMAP2CMP_FRAME * m_parentFrame
void OnFormatChange(wxCommandEvent &event) override
void OnLoadFile(wxCommandEvent &event) override
wxBitmap m_Greyscale_Bitmap
EDA_UNITS getUnitFromSelection()
void OnNegativeClicked(wxCommandEvent &event) override
void OnPaintBW(wxPaintEvent &event) override
OUTPUT_FMT_ID getOutputFormat()
void OnSizeChangeY(wxCommandEvent &event) override
int ConvertBitmap(potrace_bitmap_t *aPotrace_bitmap, OUTPUT_FMT_ID aFormat, int aDpi_X, int aDpi_Y, const wxString &aLayer)
Run the conversion of the bitmap.
void SetUnit(EDA_UNITS aUnit)
void SetOriginalDPI(int aDPI)
void SetOutputSizeFromInitialImageSize()
void SetOutputSize(double aSize, EDA_UNITS aUnit)
void SetOriginalSizePixels(int aPixels)
A wrapper for reporting to a wxString object.
bool HasMessage() const override
Returns true if the reporter client is non-empty.
const wxString & GetMessages() const
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
std::vector< FAB_LAYER_COLOR > dummy