31#define VECTORIZE_MAX_EXTENT 512
34 : GenericDialogController(pParent,
"modules/sdraw/ui/vectorize.ui",
"VectorizeDialog")
39 , m_xNmLayers(m_xBuilder->weld_spin_button(
"colors"))
40 , m_xMtReduce(m_xBuilder->weld_metric_spin_button(
"points",
FieldUnit::
PIXEL))
41 , m_xFtFillHoles(m_xBuilder->weld_label(
"tilesft"))
42 , m_xMtFillHoles(m_xBuilder->weld_metric_spin_button(
"tiles",
FieldUnit::
PIXEL))
43 , m_xCbFillHoles(m_xBuilder->weld_check_button(
"fillholes"))
44 , m_xBmpWin(new
weld::CustomWeld(*m_xBuilder,
"source", m_aBmpWin))
45 , m_xMtfWin(new
weld::CustomWeld(*m_xBuilder,
"vectorized", m_aMtfWin))
46 , m_xPrgs(m_xBuilder->weld_progress_bar(
"progressbar"))
47 , m_xBtnOK(m_xBuilder->weld_button(
"ok"))
48 , m_xBtnPreview(m_xBuilder->weld_button(
"preview"))
50 const int nWidth =
m_xFtFillHoles->get_approximate_digit_width() * 32;
52 m_xBmpWin->set_size_request(nWidth, nHeight);
53 m_xMtfWin->set_size_request(nWidth, nHeight);
76 Size aBmpSize( rBmpSize );
77 const double fGrfWH =
static_cast<double>(aBmpSize.
Width()) / aBmpSize.
Height();
78 const double fWinWH =
static_cast<double>(rDispSize.
Width()) / rDispSize.
Height();
118 aNew.
Scale( aRect.GetSize() );
154 assert(nTileX &&
"div-by-zero");
156 assert(nTileY &&
"div-by-zero");
170 AddTile( pRAcc.
get(), aNewMtf, nTX * nTileX, nTY * nTileY, nTileX, nTileY );
173 AddTile( pRAcc.
get(), aNewMtf, nCountX * nTileX, nY, nRestX, nTileY );
181 AddTile( pRAcc.
get(), aNewMtf, nTX * nTileX, nY, nTileX, nRestY );
184 AddTile( pRAcc.
get(), aNewMtf, nCountX * nTileX, nCountY * nTileY, nRestX, nRestY );
192 aMap.SetScaleX(
aMap.GetScaleX() * aScale );
193 aMap.SetScaleY(
aMap.GetScaleY() * aScale );
207 sal_uLong nSumR = 0, nSumG = 0, nSumB = 0;
210 const double fMult = 1.0 / ( nWidth * nHeight );
218 nSumR += aPixel.GetRed();
219 nSumG += aPixel.GetGreen();
220 nSumB += aPixel.GetBlue();
233 if( aRect.
Right() > ( rMaxSize.
Width() - 1 ) )
246 m_xPrgs->set_percentage(nData);
252 m_aMtfWin.SetGraphic( aMtf );
253 m_xBtnPreview->set_sensitive(
false);
258 if (m_xBtnPreview->get_sensitive())
267 if (rCb.get_active())
269 m_xFtFillHoles->set_sensitive(
true);
270 m_xMtFillHoles->set_sensitive(
true);
274 m_xFtFillHoles->set_sensitive(
false);
275 m_xMtFillHoles->set_sensitive(
false);
278 m_xBtnPreview->set_sensitive(
true);
283 m_xBtnPreview->set_sensitive(
true);
288 m_xBtnPreview->set_sensitive(
true);
298 sal_uInt16 nFillHoles;
303 SdIOCompat aCompat( *xIStm, StreamMode::READ );
304 xIStm->ReadUInt16( nLayers ).ReadUInt16( nReduce ).ReadUInt16( nFillHoles ).ReadCharAsBool( bFillHoles );
330 SdIOCompat aCompat( *xOStm, StreamMode::WRITE, 1 );
Reference< XExecutableDialog > m_xDialog
static OutputDevice * GetDefaultDevice()
Bitmap GetBitmap(Color aTransparentReplaceColor) const
static bool Filter(BitmapEx &rBmpEx, BitmapFilter const &rFilter)
BitmapColor GetColor(tools::Long nY, tools::Long nX) const
Size GetSizePixel() const
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
void Vectorize(GDIMetaFile &rMtf, sal_uInt8 cReduce, const Link< tools::Long, void > *pProgress)
void SetGraphic(const Graphic &rGraphic, bool bNewModel=true)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void SaveSettings() const
std::unique_ptr< weld::SpinButton > m_xNmLayers
Bitmap GetPreparedBitmap(Bitmap const &rBmp, Fraction &rScale)
std::unique_ptr< weld::CustomWeld > m_xBmpWin
virtual ~SdVectorizeDlg() override
static void AddTile(BitmapReadAccess const *pRAcc, GDIMetaFile &rMtf, tools::Long nPosX, tools::Long nPosY, tools::Long nWidth, tools::Long nHeight)
std::unique_ptr< weld::ProgressBar > m_xPrgs
std::unique_ptr< weld::CheckButton > m_xCbFillHoles
::tools::Rectangle GetRect(const Size &rDispSize, const Size &rBmpSize)
std::unique_ptr< weld::MetricSpinButton > m_xMtReduce
void Calculate(Bitmap const &rBmp, GDIMetaFile &rMtf)
std::unique_ptr< weld::Button > m_xBtnPreview
::sd::DrawDocShell * m_pDocSh
SdVectorizeDlg(weld::Window *pParent, const Bitmap &rBmp, ::sd::DrawDocShell *pDocShell)
std::unique_ptr< weld::Button > m_xBtnOK
std::unique_ptr< weld::Label > m_xFtFillHoles
std::unique_ptr< weld::MetricSpinButton > m_xMtFillHoles
std::unique_ptr< weld::CustomWeld > m_xMtfWin
void SetWaitCursor(bool bSet) const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
#define SD_OPTION_VECTORIZE
tools::Long FRound(double fVal)
#define LINK(Instance, Class, Member)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
HashMap_OWString_Interface aMap
IMPL_LINK_NOARG(SdVectorizeDlg, ClickPreviewHdl, weld::Button &, void)
IMPL_LINK(SdVectorizeDlg, ProgressHdl, tools::Long, nData, void)
#define VECTORIZE_MAX_EXTENT