Kaydet (Commit) ee41193f authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Dialog for Smooth filter

Added dialog for smooth (gaussian blur) filter which now accepts
a parameter for setting the strenth of smoothing (bluring).

Change-Id: Ida6709b060cb5429a63af1994493e716fd0bfebb
üst d7036ac1
...@@ -244,6 +244,57 @@ Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic, ...@@ -244,6 +244,57 @@ Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic,
return aRet; return aRet;
} }
// ------------------
// - GraphicFilterSmooth -
// ------------------
GraphicFilterSmooth::GraphicFilterSmooth( Window* pParent, const Graphic& rGraphic, double nRadius) :
GraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_SMOOTH ), rGraphic ),
maFtRadius ( this, CUI_RES( DLG_FILTERSMOOTH_FT_RADIUS ) ),
maMtrRadius ( this, CUI_RES( DLG_FILTERSMOOTH_MTR_RADIUS ) )
{
FreeResource();
maMtrRadius.SetValue( nRadius* 10 );
maMtrRadius.SetModifyHdl( GetModifyHdl() );
maMtrRadius.GrabFocus();
}
// -----------------------------------------------------------------------------
GraphicFilterSmooth::~GraphicFilterSmooth()
{
}
// -----------------------------------------------------------------------------
Graphic GraphicFilterSmooth::GetFilteredGraphic( const Graphic& rGraphic, double /*fScaleX*/, double /*fScaleY*/ )
{
Graphic aRet;
BmpFilterParam aParam( GetRadius() );
if( rGraphic.IsAnimated() )
{
Animation aAnim( rGraphic.GetAnimation() );
if( aAnim.Filter( BMP_FILTER_SMOOTH, &aParam ) )
{
aRet = aAnim;
}
}
else
{
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
if( aBmpEx.Filter( BMP_FILTER_SMOOTH, &aParam ) )
{
aRet = aBmpEx;
}
}
return aRet;
}
// ------------------ // ------------------
// - GraphicFilterSolarize - // - GraphicFilterSolarize -
// ------------------ // ------------------
......
...@@ -48,6 +48,13 @@ ...@@ -48,6 +48,13 @@
#define DLG_FILTERMOSAIC_MTR_HEIGHT 4 #define DLG_FILTERMOSAIC_MTR_HEIGHT 4
#define DLG_FILTERMOSAIC_CBX_EDGES 5 #define DLG_FILTERMOSAIC_CBX_EDGES 5
// ----------------------
// - DLG_FILTERSMOOTH -
// ----------------------
#define DLG_FILTERSMOOTH_FT_RADIUS 1
#define DLG_FILTERSMOOTH_MTR_RADIUS 2
// ---------------------- // ----------------------
// - DLG_FILTERSOLARIZE - // - DLG_FILTERSOLARIZE -
// ---------------------- // ----------------------
......
...@@ -428,3 +428,75 @@ ModalDialog RID_SVX_GRFFILTER_DLG_EMBOSS ...@@ -428,3 +428,75 @@ ModalDialog RID_SVX_GRFFILTER_DLG_EMBOSS
TabStop = TRUE ; TabStop = TRUE ;
}; };
}; };
// --------------------
// - DLG_FILTERSMOOTH -
// --------------------
ModalDialog RID_SVX_GRFFILTER_DLG_SMOOTH
{
HelpID = CMD_SID_GRFFILTER_SMOOTH;
OutputSize = TRUE ;
Moveable = TRUE ;
SVLook = TRUE ;
Size = MAP_APPFONT ( 250, 100 ) ;
Text [ en-US ] = "Smooth" ;
FixedLine FL_PARAMETER
{
Pos = MAP_APPFONT ( 6 , 3 ) ;
Size = MAP_APPFONT ( 182, RSC_CD_FIXEDLINE_HEIGHT ) ;
Text [ en-US ] = "Parameters";
};
Control CTL_PREVIEW
{
Pos = MAP_APPFONT ( 104 , 3 + RSC_CD_FIXEDLINE_HEIGHT + RSC_SP_FLGR_INNERBORDER_TOP ) ;
Size = MAP_APPFONT ( 81, 73 ) ;
};
#define MA_Y14 3 + RSC_CD_FIXEDLINE_HEIGHT + RSC_SP_FLGR_INNERBORDER_TOP
FixedText DLG_FILTERSMOOTH_FT_RADIUS
{
Pos = MAP_APPFONT ( 12 , MA_Y14 ) ;
Size = MAP_APPFONT ( 77 , 10 ) ;
Text [ en-US ] = "Smooth Radius" ;
};
#define MA_Y15 MA_Y14 + RSC_CD_FIXEDTEXT_HEIGHT + RSC_SP_CTRL_DESC_Y
NumericField DLG_FILTERSMOOTH_MTR_RADIUS
{
HelpID = "cui:NumericField:RID_SVX_GRFFILTER_DLG_SMOOTH:DLG_FILTERSMOOTH_MTR_RADIUS";
Border = TRUE ;
Pos = MAP_APPFONT ( 12 , MA_Y15 );
Size = MAP_APPFONT ( 35 , 12 );
TabStop = TRUE;
Right = TRUE;
Repeat = TRUE;
Spin = TRUE;
Minimum = 0;
Maximum = 1000;
StrictFormat = TRUE;
First = 1;
DecimalDigits = 1;
Last = 1000;
SpinSize = 2;
};
OKButton BTN_OK
{
Pos = MAP_APPFONT ( 194, 6 ) ;
Size = MAP_APPFONT ( 50, 14 ) ;
TabStop = TRUE ;
DefButton = TRUE ;
};
CancelButton BTN_CANCEL
{
Pos = MAP_APPFONT ( 194, 23 ) ;
Size = MAP_APPFONT ( 50, 14 ) ;
TabStop = TRUE ;
};
HelpButton BTN_HELP
{
Pos = MAP_APPFONT ( 194, 43 ) ;
Size = MAP_APPFONT ( 50, 14 ) ;
TabStop = TRUE ;
};
};
...@@ -1574,18 +1574,23 @@ AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterPos ...@@ -1574,18 +1574,23 @@ AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterPos
return 0; return 0;
} }
AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterSmooth ( Window* pParent,
const Graphic& rGraphic, double nRadius, sal_uInt32)
{
GraphicFilterDialog* pDlg = new GraphicFilterSmooth( pParent, rGraphic, nRadius );
return new AbstractGraphicFilterDialog_Impl( pDlg );
}
AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterSolarize (Window* pParent, //add for GraphicFilterSolarize AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterSolarize (Window* pParent, //add for GraphicFilterSolarize
const Graphic& rGraphic, const Graphic& rGraphic, sal_uInt8 nGreyThreshold, sal_Bool bInvert, sal_uInt32 )
sal_uInt8 nGreyThreshold, sal_Bool bInvert, sal_uInt32 )
{ {
GraphicFilterDialog* pDlg = new GraphicFilterSolarize( pParent, rGraphic, nGreyThreshold, bInvert ); GraphicFilterDialog* pDlg = new GraphicFilterSolarize( pParent, rGraphic, nGreyThreshold, bInvert );
return new AbstractGraphicFilterDialog_Impl( pDlg ); return new AbstractGraphicFilterDialog_Impl( pDlg );
} }
AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterMosaic (Window* pParent, //add for GraphicFilterMosaic AbstractGraphicFilterDialog * AbstractDialogFactory_Impl::CreateGraphicFilterMosaic (Window* pParent, //add for GraphicFilterMosaic
const Graphic& rGraphic, const Graphic& rGraphic, sal_uInt16 nTileWidth, sal_uInt16 nTileHeight,
sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, sal_Bool bEnhanceEdges, sal_Bool bEnhanceEdges, sal_uInt32 nResId)
sal_uInt32 nResId)
{ {
GraphicFilterDialog* pDlg=NULL; GraphicFilterDialog* pDlg=NULL;
switch ( nResId ) switch ( nResId )
......
...@@ -725,18 +725,20 @@ public: ...@@ -725,18 +725,20 @@ public:
sal_Int16 nInitialContext, sal_Int16 nInitialContext,
const Link& lnkContextSupplier); const Link& lnkContextSupplier);
virtual AbstractGraphicFilterDialog * CreateGraphicFilterEmboss (Window* pParent, //add for GraphicFilterEmboss virtual AbstractGraphicFilterDialog * CreateGraphicFilterEmboss (Window* pParent, //add for GraphicFilterEmboss
const Graphic& rGraphic, const Graphic& rGraphic, RECT_POINT eLightSource,
RECT_POINT eLightSource, sal_uInt32 nResId); sal_uInt32 nResId);
virtual AbstractGraphicFilterDialog * CreateGraphicFilterPosterSepia (Window* pParent, //add for GraphicFilterPoster & GraphicFilterSepia virtual AbstractGraphicFilterDialog * CreateGraphicFilterPosterSepia (Window* pParent, //add for GraphicFilterPoster & GraphicFilterSepia
const Graphic& rGraphic, const Graphic& rGraphic, sal_uInt16 nCount,
sal_uInt16 nCount, sal_uInt32 nResId);
sal_uInt32 nResId); virtual AbstractGraphicFilterDialog * CreateGraphicFilterSmooth (Window* pParent, //add for GraphicFilterSolarize
virtual AbstractGraphicFilterDialog * CreateGraphicFilterSolarize (Window* pParent, //add for GraphicFilterSolarize const Graphic& rGraphic, double nRadius,
const Graphic& rGraphic, sal_uInt32 nResId);
sal_uInt8 nGreyThreshold, sal_Bool bInvert, sal_uInt32 nResId); virtual AbstractGraphicFilterDialog * CreateGraphicFilterSolarize (Window* pParent, //add for GraphicFilterSmooth
const Graphic& rGraphic, sal_uInt8 nGreyThreshold,
sal_Bool bInvert, sal_uInt32 nResId);
virtual AbstractGraphicFilterDialog * CreateGraphicFilterMosaic (Window* pParent, //add for GraphicFilterMosaic virtual AbstractGraphicFilterDialog * CreateGraphicFilterMosaic (Window* pParent, //add for GraphicFilterMosaic
const Graphic& rGraphic, const Graphic& rGraphic, sal_uInt16 nTileWidth, sal_uInt16 nTileHeight,
sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, sal_Bool bEnhanceEdges, sal_uInt32 nResId); sal_Bool bEnhanceEdges, sal_uInt32 nResId);
virtual AbstractSvxAreaTabDialog* CreateSvxAreaTabDialog( Window* pParent,//add for SvxAreaTabDialog virtual AbstractSvxAreaTabDialog* CreateSvxAreaTabDialog( Window* pParent,//add for SvxAreaTabDialog
const SfxItemSet* pAttr, const SfxItemSet* pAttr,
SdrModel* pModel, SdrModel* pModel,
......
...@@ -95,6 +95,26 @@ public: ...@@ -95,6 +95,26 @@ public:
virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) = 0; virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) = 0;
}; };
// -------------------------
// - GraphicFilterSmooth -
// -------------------------
class GraphicFilterSmooth : public GraphicFilterDialog
{
private:
FixedText maFtRadius;
NumericField maMtrRadius;
public:
GraphicFilterSmooth( Window* pParent, const Graphic& rGraphic, double nRadius);
~GraphicFilterSmooth();
virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
double GetRadius() const { return maMtrRadius.GetValue() / 10.0; }
};
// ----------------------- // -----------------------
// - GraphicFilterMosaic - // - GraphicFilterMosaic -
// ----------------------- // -----------------------
......
...@@ -117,6 +117,7 @@ ...@@ -117,6 +117,7 @@
#define RID_SVX_GRFFILTER_DLG_MOSAIC (RID_SVX_START + 332) #define RID_SVX_GRFFILTER_DLG_MOSAIC (RID_SVX_START + 332)
#define RID_SVX_GRFFILTER_DLG_SOLARIZE (RID_SVX_START + 333) #define RID_SVX_GRFFILTER_DLG_SOLARIZE (RID_SVX_START + 333)
#define RID_SVX_GRFFILTER_DLG_EMBOSS (RID_SVX_START + 336) #define RID_SVX_GRFFILTER_DLG_EMBOSS (RID_SVX_START + 336)
#define RID_SVX_GRFFILTER_DLG_SMOOTH (RID_SVX_START + 337)
#define RID_SVXDLG_SEARCHFORMAT (RID_SVX_START + 21) #define RID_SVXDLG_SEARCHFORMAT (RID_SVX_START + 21)
#define RID_SVXDLG_CHARMAP ( RID_SVX_START + 10 ) #define RID_SVXDLG_CHARMAP ( RID_SVX_START + 10 )
#define RID_SVXDLG_POSTIT ( RID_SVX_START + 8 ) #define RID_SVXDLG_POSTIT ( RID_SVX_START + 8 )
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
#define CMD_SID_GRFFILTER_POSTER ".uno:GraphicFilterPoster" #define CMD_SID_GRFFILTER_POSTER ".uno:GraphicFilterPoster"
#define CMD_SID_GRFFILTER_EMBOSS ".uno:GraphicFilterRelief" #define CMD_SID_GRFFILTER_EMBOSS ".uno:GraphicFilterRelief"
#define CMD_SID_GRFFILTER_SEPIA ".uno:GraphicFilterSepia" #define CMD_SID_GRFFILTER_SEPIA ".uno:GraphicFilterSepia"
#define CMD_SID_GRFFILTER_SMOOTH ".uno:GraphicFilterSmooth"
#define CMD_SID_GRFFILTER_SOLARIZE ".uno:GraphicFilterSolarize" #define CMD_SID_GRFFILTER_SOLARIZE ".uno:GraphicFilterSolarize"
#define CMD_SID_GRID_USE ".uno:GridUse" #define CMD_SID_GRID_USE ".uno:GridUse"
#define CMD_SID_GRID_VISIBLE ".uno:GridVisible" #define CMD_SID_GRID_VISIBLE ".uno:GridVisible"
......
...@@ -444,6 +444,9 @@ public: ...@@ -444,6 +444,9 @@ public:
const Graphic& rGraphic, const Graphic& rGraphic,
sal_uInt16 nCount, sal_uInt16 nCount,
sal_uInt32 nResId)=0; sal_uInt32 nResId)=0;
virtual AbstractGraphicFilterDialog * CreateGraphicFilterSmooth (Window* pParent, //add for GraphicFilterSmooth
const Graphic& rGraphic,
double nRadius, sal_uInt32 nResId)=0;
virtual AbstractGraphicFilterDialog * CreateGraphicFilterSolarize (Window* pParent, //add for GraphicFilterSolarize virtual AbstractGraphicFilterDialog * CreateGraphicFilterSolarize (Window* pParent, //add for GraphicFilterSolarize
const Graphic& rGraphic, const Graphic& rGraphic,
sal_uInt8 nGreyThreshold, sal_Bool bInvert, sal_uInt32 nResId)=0; sal_uInt8 nGreyThreshold, sal_Bool bInvert, sal_uInt32 nResId)=0;
......
...@@ -83,26 +83,15 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj ...@@ -83,26 +83,15 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj
case( SID_GRFFILTER_SMOOTH ): case( SID_GRFFILTER_SMOOTH ):
{ {
if( pShell ) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
pShell->SetWaitCursor( sal_True ); if(pFact)
if( rGraphic.IsAnimated() )
{
Animation aAnimation( rGraphic.GetAnimation() );
if( aAnimation.Filter( BMP_FILTER_SMOOTH ) )
aGraphic = aAnimation;
}
else
{ {
BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSmooth( pWindow, rGraphic, 0.7, RID_SVX_GRFFILTER_DLG_SEPIA);
DBG_ASSERT(aDlg, "Dialogdiet fail!");
if( aBmpEx.Filter( BMP_FILTER_SMOOTH ) ) if( aDlg->Execute() == RET_OK )
aGraphic = aBmpEx; aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
delete aDlg;
} }
if( pShell )
pShell->SetWaitCursor( sal_False );
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment