29#include <potracelib.h>
32#include <wx/clipbrd.h>
36#include <wx/dcclient.h>
41#define DEFAULT_DPI 300
50 for(
const wxString& unit : {
_(
"mm" ),
_(
"Inch" ),
_(
"DPI" ) } )
193 int imageDPIx =
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
194 int imageDPIy =
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
196 if( imageDPIx > 1 && imageDPIy > 1 )
198 if(
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT ) == wxIMAGE_RESOLUTION_CM )
200 imageDPIx =
KiROUND( imageDPIx * 2.54 );
201 imageDPIy =
KiROUND( imageDPIy * 2.54 );
222 wxCommandEvent
dummy;
275 text.Printf( wxS(
"%.1f" ), aSize );
277 text.Printf( wxS(
"%.2f" ), aSize );
315 if(
m_UnitSizeX->GetValue().ToDouble( &new_size ) )
344 if(
m_UnitSizeY->GetValue().ToDouble( &new_size ) )
396 wxCommandEvent
dummy;
404 unsigned char threshold = aThreshold * 255;
405 unsigned char alpha_thresh = 0.7 * threshold;
415 if( pixel < threshold && alpha > alpha_thresh )
420 m_NB_Image.SetRGB( x, y, pixel, pixel, pixel );
499 if( wxTheClipboard->Open() )
503 wxTheClipboard->SetData(
new wxTextDataObject( buffer.c_str() ) );
504 wxTheClipboard->Flush();
505 wxTheClipboard->Close();
509 wxMessageBox(
_(
"Unable to export to the Clipboard") );
519 if( !potrace_bitmap )
521 wxMessageBox(
_(
"Error allocating memory for potrace bitmap" ) );
526 for(
int y = 0; y <
m_NB_Image.GetHeight(); y++ )
528 for(
int x = 0; x <
m_NB_Image.GetWidth(); x++ )
530 unsigned char pixel =
m_NB_Image.GetGreen( x, y );
531 BM_PUT( potrace_bitmap, x, y, pixel ? 0 : 1 );
535 wxString layer = wxT(
"F.SilkS" );
541 case 0: layer = wxT(
"F.Cu" );
break;
542 case 1: layer = wxT(
"F.SilkS" );
break;
543 case 2: layer = wxT(
"F.Mask" );
break;
544 case 3: layer = wxT(
"Dwgs.User" );
break;
545 case 4: layer = wxT(
"Cmts.User" );
break;
546 case 5: layer = wxT(
"Eco1.User" );
break;
547 case 6: layer = wxT(
"Eco2.User" );
break;
548 case 7: layer = wxT(
"F.Fab" );
break;
561 wxMessageBox(
reporter.GetMessages(),
_(
"Errors" ) );
583 if(
m_panel->GetOutputSizeX().GetOriginalSizePixels() != 0 )
585 wxString cap =
_(
"Replace Loaded File?" );
586 wxString msg =
_(
"There is already a file loaded. Do you want to replace it?" );
588 int replace = acceptFileDlg.ShowModal();
590 if( replace == wxID_NO )
594 std::vector<wxString> fNameVec;
595 fNameVec.insert( fNameVec.begin(), filenames.begin(), filenames.end() );
596 m_panel->OpenProjectFiles( fNameVec );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
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
BITMAP2CMP_PANEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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.
BITMAP2CMP_PANEL * m_panel
bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) override
A wrapper for reporting to a wxString object.
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
std::vector< FAB_LAYER_COLOR > dummy
IbisParser parser & reporter