2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-04 11:25:41 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
#include <tools/shl.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#include <sfx2/viewsh.hxx>
|
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
#include <sfx2/request.hxx>
|
2009-11-02 20:49:14 +01:00
|
|
|
#include <dialmgr.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include "cuigrfflt.hxx"
|
|
|
|
#include "grfflt.hrc"
|
2009-11-02 20:49:14 +01:00
|
|
|
#include <cuires.hrc>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <svx/dialogs.hrc>
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
// --------------------------------------
|
2014-01-31 09:07:26 +00:00
|
|
|
// - oldGraphicFilterDialog::PreviewWindow -
|
2009-10-31 00:36:06 +01:00
|
|
|
// --------------------------------------
|
|
|
|
|
2014-01-31 09:07:26 +00:00
|
|
|
oldGraphicFilterDialog::PreviewWindow::PreviewWindow( Window* pParent, const ResId& rResId ) :
|
2009-10-31 00:36:06 +01:00
|
|
|
Control( pParent, rResId )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2014-01-31 09:07:26 +00:00
|
|
|
void oldGraphicFilterDialog::PreviewWindow::Paint( const Rectangle& rRect )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
Control::Paint( rRect );
|
|
|
|
|
2012-06-17 15:41:46 +02:00
|
|
|
const Size aOutputSize( GetOutputSizePixel() );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
if( maGraphic.IsAnimated() )
|
2012-06-17 15:41:46 +02:00
|
|
|
{
|
|
|
|
const Size aGraphicSize( LogicToPixel( maGraphic.GetPrefSize(), maGraphic.GetPrefMapMode() ) );
|
|
|
|
const Point aGraphicPosition( ( aOutputSize.Width() - aGraphicSize.Width() ) >> 1,
|
|
|
|
( aOutputSize.Height() - aGraphicSize.Height() ) >> 1 );
|
|
|
|
maGraphic.StartAnimation( this, aGraphicPosition, aGraphicSize );
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
else
|
2012-06-17 15:41:46 +02:00
|
|
|
{
|
|
|
|
const Size aGraphicSize( maGraphic.GetSizePixel() );
|
|
|
|
const Point aGraphicPosition( ( aOutputSize.Width() - aGraphicSize.Width() ) >> 1,
|
|
|
|
( aOutputSize.Height() - aGraphicSize.Height() ) >> 1 );
|
|
|
|
maGraphic.Draw( this, aGraphicPosition, aGraphicSize );
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2014-01-31 09:07:26 +00:00
|
|
|
void oldGraphicFilterDialog::PreviewWindow::SetGraphic( const Graphic& rGraphic )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
maGraphic = rGraphic;
|
|
|
|
|
|
|
|
if( maGraphic.IsAnimated() || maGraphic.IsTransparent() )
|
|
|
|
Invalidate();
|
|
|
|
else
|
|
|
|
Paint( Rectangle( Point(), GetOutputSizePixel() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------
|
2014-01-31 09:07:26 +00:00
|
|
|
// - oldGraphicFilterDialog -
|
2009-10-31 00:36:06 +01:00
|
|
|
// -----------------------
|
|
|
|
|
2014-01-31 09:07:26 +00:00
|
|
|
oldGraphicFilterDialog::oldGraphicFilterDialog( Window* pParent, const ResId& rResId, const Graphic& rGraphic ) :
|
2009-10-31 00:36:06 +01:00
|
|
|
ModalDialog ( pParent, rResId ),
|
2014-01-31 09:07:26 +00:00
|
|
|
maModifyHdl ( LINK( this, oldGraphicFilterDialog, ImplModifyHdl ) ),
|
2009-10-31 00:36:06 +01:00
|
|
|
mfScaleX ( 0.0 ),
|
|
|
|
mfScaleY ( 0.0 ),
|
|
|
|
maSizePixel ( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) ),
|
2009-11-02 20:49:14 +01:00
|
|
|
maPreview ( this, CUI_RES( CTL_PREVIEW ) ),
|
|
|
|
maBtnOK ( this, CUI_RES( BTN_OK ) ),
|
|
|
|
maBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
|
2011-01-20 12:21:31 +01:00
|
|
|
maBtnHelp ( this, CUI_RES( BTN_HELP ) ),
|
|
|
|
maFlParameter ( this, CUI_RES( FL_PARAMETER ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
const Size aPreviewSize( maPreview.GetOutputSizePixel() );
|
|
|
|
Size aGrfSize( maSizePixel );
|
|
|
|
|
|
|
|
if( rGraphic.GetType() == GRAPHIC_BITMAP &&
|
|
|
|
aPreviewSize.Width() && aPreviewSize.Height() &&
|
|
|
|
aGrfSize.Width() && aGrfSize.Height() )
|
|
|
|
{
|
|
|
|
const double fGrfWH = (double) aGrfSize.Width() / aGrfSize.Height();
|
|
|
|
const double fPreWH = (double) aPreviewSize.Width() / aPreviewSize.Height();
|
|
|
|
|
|
|
|
if( fGrfWH < fPreWH )
|
|
|
|
{
|
2012-06-17 15:41:46 +02:00
|
|
|
aGrfSize.Width() = (long) ( aPreviewSize.Height() * fGrfWH );
|
|
|
|
aGrfSize.Height() = aPreviewSize.Height();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-06-17 15:41:46 +02:00
|
|
|
aGrfSize.Width() = aPreviewSize.Width();
|
|
|
|
aGrfSize.Height() = (long) ( aPreviewSize.Width() / fGrfWH );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mfScaleX = (double) aGrfSize.Width() / maSizePixel.Width();
|
|
|
|
mfScaleY = (double) aGrfSize.Height() / maSizePixel.Height();
|
|
|
|
|
|
|
|
if( !rGraphic.IsAnimated() )
|
|
|
|
{
|
|
|
|
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
|
|
|
|
|
2012-06-22 17:19:12 +02:00
|
|
|
if( aBmpEx.Scale( aGrfSize, BMP_SCALE_DEFAULT ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
maGraphic = aBmpEx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-31 09:07:26 +00:00
|
|
|
maTimer.SetTimeoutHdl( LINK( this, oldGraphicFilterDialog, ImplPreviewTimeoutHdl ) );
|
2009-10-31 00:36:06 +01:00
|
|
|
maTimer.SetTimeout( 100 );
|
|
|
|
ImplModifyHdl( NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2014-01-31 09:07:26 +00:00
|
|
|
IMPL_LINK_NOARG(oldGraphicFilterDialog, ImplPreviewTimeoutHdl)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
maTimer.Stop();
|
|
|
|
maPreview.SetGraphic( GetFilteredGraphic( maGraphic, mfScaleX, mfScaleY ) );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2014-01-31 09:07:26 +00:00
|
|
|
IMPL_LINK_NOARG(oldGraphicFilterDialog, ImplModifyHdl)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
if( maGraphic.GetType() == GRAPHIC_BITMAP )
|
|
|
|
{
|
|
|
|
maTimer.Stop();
|
|
|
|
maTimer.Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------
|
|
|
|
// - FilterMosaic -
|
|
|
|
// ----------------
|
|
|
|
|
|
|
|
GraphicFilterMosaic::GraphicFilterMosaic( Window* pParent, const Graphic& rGraphic,
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, sal_Bool bEnhanceEdges ) :
|
2014-01-31 09:07:26 +00:00
|
|
|
oldGraphicFilterDialog( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_MOSAIC ), rGraphic ),
|
2009-11-02 20:49:14 +01:00
|
|
|
maFtWidth ( this, CUI_RES( DLG_FILTERMOSAIC_FT_WIDTH ) ),
|
|
|
|
maMtrWidth ( this, CUI_RES( DLG_FILTERMOSAIC_MTR_WIDTH ) ),
|
|
|
|
maFtHeight ( this, CUI_RES( DLG_FILTERMOSAIC_FT_HEIGHT ) ),
|
|
|
|
maMtrHeight ( this, CUI_RES( DLG_FILTERMOSAIC_MTR_HEIGHT ) ),
|
|
|
|
maCbxEdges ( this, CUI_RES( DLG_FILTERMOSAIC_CBX_EDGES ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
maMtrWidth.SetValue( nTileWidth );
|
|
|
|
maMtrWidth.SetLast( GetGraphicSizePixel().Width() );
|
|
|
|
maMtrWidth.SetModifyHdl( GetModifyHdl() );
|
|
|
|
|
|
|
|
maMtrHeight.SetValue( nTileHeight );
|
|
|
|
maMtrHeight.SetLast( GetGraphicSizePixel().Height() );
|
|
|
|
maMtrHeight.SetModifyHdl( GetModifyHdl() );
|
|
|
|
|
|
|
|
maCbxEdges.Check( bEnhanceEdges );
|
|
|
|
maCbxEdges.SetToggleHdl( GetModifyHdl() );
|
|
|
|
|
|
|
|
maMtrWidth.GrabFocus();
|
2011-01-20 12:21:31 +01:00
|
|
|
|
|
|
|
maFtWidth.SetAccessibleRelationMemberOf(&maFlParameter);
|
|
|
|
maMtrWidth.SetAccessibleRelationMemberOf(&maFlParameter);
|
|
|
|
maFtHeight.SetAccessibleRelationMemberOf(&maFlParameter);
|
|
|
|
maMtrHeight.SetAccessibleRelationMemberOf(&maFlParameter);
|
|
|
|
maCbxEdges.SetAccessibleRelationMemberOf(&maFlParameter);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
GraphicFilterMosaic::~GraphicFilterMosaic()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic,
|
|
|
|
double fScaleX, double fScaleY )
|
|
|
|
{
|
|
|
|
Graphic aRet;
|
2013-04-11 00:21:40 -03:00
|
|
|
const Size aSize( std::max( FRound( GetTileWidth() * fScaleX ), 1L ),
|
|
|
|
std::max( FRound( GetTileHeight() * fScaleY ), 1L ) );
|
2009-10-31 00:36:06 +01:00
|
|
|
BmpFilterParam aParam( aSize );
|
|
|
|
|
|
|
|
if( rGraphic.IsAnimated() )
|
|
|
|
{
|
|
|
|
Animation aAnim( rGraphic.GetAnimation() );
|
|
|
|
|
|
|
|
if( aAnim.Filter( BMP_FILTER_MOSAIC, &aParam ) )
|
|
|
|
{
|
|
|
|
if( IsEnhanceEdges() )
|
|
|
|
aAnim.Filter( BMP_FILTER_SHARPEN );
|
|
|
|
|
|
|
|
aRet = aAnim;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
|
|
|
|
|
|
|
|
if( aBmpEx.Filter( BMP_FILTER_MOSAIC, &aParam ) )
|
|
|
|
{
|
|
|
|
if( IsEnhanceEdges() )
|
|
|
|
aBmpEx.Filter( BMP_FILTER_SHARPEN );
|
|
|
|
|
|
|
|
aRet = aBmpEx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2012-06-16 00:05:00 +02:00
|
|
|
// ------------------
|
|
|
|
// - GraphicFilterSmooth -
|
|
|
|
// ------------------
|
|
|
|
|
|
|
|
GraphicFilterSmooth::GraphicFilterSmooth( Window* pParent, const Graphic& rGraphic, double nRadius) :
|
2014-01-31 09:07:26 +00:00
|
|
|
oldGraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_SMOOTH ), rGraphic ),
|
2012-06-16 00:05:00 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-10-31 00:36:06 +01:00
|
|
|
// ------------------
|
|
|
|
// - GraphicFilterSolarize -
|
|
|
|
// ------------------
|
|
|
|
|
|
|
|
GraphicFilterSolarize::GraphicFilterSolarize( Window* pParent, const Graphic& rGraphic,
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt8 cGreyThreshold, sal_Bool bInvert ) :
|
2014-01-31 09:07:26 +00:00
|
|
|
oldGraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_SOLARIZE ), rGraphic ),
|
2009-11-02 20:49:14 +01:00
|
|
|
maFtThreshold ( this, CUI_RES( DLG_FILTERSOLARIZE_FT_THRESHOLD ) ),
|
|
|
|
maMtrThreshold ( this, CUI_RES( DLG_FILTERSOLARIZE_MTR_THRESHOLD ) ),
|
|
|
|
maCbxInvert ( this, CUI_RES( DLG_FILTERSOLARIZE_CBX_INVERT ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
maMtrThreshold.SetValue( FRound( cGreyThreshold / 2.55 ) );
|
|
|
|
maMtrThreshold.SetModifyHdl( GetModifyHdl() );
|
|
|
|
|
|
|
|
maCbxInvert.Check( bInvert );
|
|
|
|
maCbxInvert.SetToggleHdl( GetModifyHdl() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
GraphicFilterSolarize::~GraphicFilterSolarize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Graphic GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic,
|
|
|
|
double /*fScaleX*/, double /*fScaleY*/ )
|
|
|
|
{
|
|
|
|
Graphic aRet;
|
|
|
|
BmpFilterParam aParam( GetGreyThreshold() );
|
|
|
|
|
|
|
|
if( rGraphic.IsAnimated() )
|
|
|
|
{
|
|
|
|
Animation aAnim( rGraphic.GetAnimation() );
|
|
|
|
|
|
|
|
if( aAnim.Filter( BMP_FILTER_SOLARIZE, &aParam ) )
|
|
|
|
{
|
|
|
|
if( IsInvert() )
|
|
|
|
aAnim.Invert();
|
|
|
|
|
|
|
|
aRet = aAnim;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
|
|
|
|
|
|
|
|
if( aBmpEx.Filter( BMP_FILTER_SOLARIZE, &aParam ) )
|
|
|
|
{
|
|
|
|
if( IsInvert() )
|
|
|
|
aBmpEx.Invert();
|
|
|
|
|
|
|
|
aRet = aBmpEx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------
|
|
|
|
// - GraphicFilterSepia -
|
|
|
|
// ----------------------
|
|
|
|
|
|
|
|
GraphicFilterSepia::GraphicFilterSepia( Window* pParent, const Graphic& rGraphic,
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nSepiaPercent ) :
|
2014-01-31 09:07:26 +00:00
|
|
|
oldGraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_SEPIA ), rGraphic ),
|
2009-11-02 20:49:14 +01:00
|
|
|
maFtSepia ( this, CUI_RES( DLG_FILTERSEPIA_FT_SEPIA ) ),
|
|
|
|
maMtrSepia ( this, CUI_RES( DLG_FILTERSEPIA_MTR_SEPIA ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
maMtrSepia.SetValue( nSepiaPercent );
|
|
|
|
maMtrSepia.SetModifyHdl( GetModifyHdl() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
GraphicFilterSepia::~GraphicFilterSepia()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Graphic GraphicFilterSepia::GetFilteredGraphic( const Graphic& rGraphic,
|
|
|
|
double /*fScaleX*/, double /*fScaleY*/ )
|
|
|
|
{
|
|
|
|
Graphic aRet;
|
|
|
|
BmpFilterParam aParam( GetSepiaPercent() );
|
|
|
|
|
|
|
|
if( rGraphic.IsAnimated() )
|
|
|
|
{
|
|
|
|
Animation aAnim( rGraphic.GetAnimation() );
|
|
|
|
|
|
|
|
if( aAnim.Filter( BMP_FILTER_SEPIA, &aParam ) )
|
|
|
|
aRet = aAnim;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
|
|
|
|
|
|
|
|
if( aBmpEx.Filter( BMP_FILTER_SEPIA, &aParam ) )
|
|
|
|
aRet = aBmpEx;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------
|
|
|
|
// - GraphicFilterPoster -
|
|
|
|
// -----------------------
|
|
|
|
|
|
|
|
GraphicFilterPoster::GraphicFilterPoster( Window* pParent, const Graphic& rGraphic,
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPosterCount ) :
|
2014-01-31 09:07:26 +00:00
|
|
|
oldGraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_POSTER ), rGraphic ),
|
2009-11-02 20:49:14 +01:00
|
|
|
maFtPoster ( this, CUI_RES( DLG_FILTERPOSTER_FT_POSTER ) ),
|
|
|
|
maNumPoster ( this, CUI_RES( DLG_FILTERPOSTER_NUM_POSTER ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
maNumPoster.SetFirst( 2 );
|
|
|
|
maNumPoster.SetLast( rGraphic.GetBitmapEx().GetBitCount() );
|
|
|
|
maNumPoster.SetValue( nPosterCount );
|
|
|
|
maNumPoster.SetModifyHdl( GetModifyHdl() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
GraphicFilterPoster::~GraphicFilterPoster()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Graphic GraphicFilterPoster::GetFilteredGraphic( const Graphic& rGraphic,
|
|
|
|
double /*fScaleX*/, double /*fScaleY*/ )
|
|
|
|
{
|
|
|
|
Graphic aRet;
|
2011-01-14 12:41:27 +01:00
|
|
|
const sal_uInt16 nPosterCount = GetPosterColorCount();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
if( rGraphic.IsAnimated() )
|
|
|
|
{
|
|
|
|
Animation aAnim( rGraphic.GetAnimation() );
|
|
|
|
|
|
|
|
if( aAnim.ReduceColors( nPosterCount, BMP_REDUCE_POPULAR ) )
|
|
|
|
aRet = aAnim;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
|
|
|
|
|
|
|
|
if( aBmpEx.ReduceColors( nPosterCount, BMP_REDUCE_POPULAR ) )
|
|
|
|
aRet = aBmpEx;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------
|
|
|
|
// - GraphicFilterEmboss -
|
|
|
|
// -----------------------
|
|
|
|
|
|
|
|
void GraphicFilterEmboss::EmbossControl::MouseButtonDown( const MouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
const RECT_POINT eOldRP = GetActualRP();
|
|
|
|
|
|
|
|
SvxRectCtl::MouseButtonDown( rEvt );
|
|
|
|
|
|
|
|
if( GetActualRP() != eOldRP )
|
|
|
|
maModifyHdl.Call( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
GraphicFilterEmboss::GraphicFilterEmboss( Window* pParent, const Graphic& rGraphic,
|
|
|
|
RECT_POINT eLightSource ) :
|
2014-01-31 09:07:26 +00:00
|
|
|
oldGraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_EMBOSS ), rGraphic ),
|
2009-11-02 20:49:14 +01:00
|
|
|
maFtLight ( this, CUI_RES( DLG_FILTEREMBOSS_FT_LIGHT ) ),
|
|
|
|
maCtlLight ( this, CUI_RES( DLG_FILTEREMBOSS_CTL_LIGHT ), eLightSource )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
maCtlLight.SetModifyHdl( GetModifyHdl() );
|
|
|
|
maCtlLight.GrabFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
GraphicFilterEmboss::~GraphicFilterEmboss()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Graphic GraphicFilterEmboss::GetFilteredGraphic( const Graphic& rGraphic,
|
|
|
|
double /*fScaleX*/, double /*fScaleY*/ )
|
|
|
|
{
|
|
|
|
Graphic aRet;
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nAzim, nElev;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
switch( maCtlLight.GetActualRP() )
|
|
|
|
{
|
2011-03-01 17:55:09 +01:00
|
|
|
default: OSL_FAIL("svx::GraphicFilterEmboss::GetFilteredGraphic(), unknown Reference Point!" );
|
2014-01-28 14:22:15 +00:00
|
|
|
/* Fall through */
|
2009-10-31 00:36:06 +01:00
|
|
|
case( RP_LT ): nAzim = 4500, nElev = 4500; break;
|
|
|
|
case( RP_MT ): nAzim = 9000, nElev = 4500; break;
|
|
|
|
case( RP_RT ): nAzim = 13500, nElev = 4500; break;
|
|
|
|
case( RP_LM ): nAzim = 0, nElev = 4500; break;
|
|
|
|
case( RP_MM ): nAzim = 0, nElev = 9000; break;
|
|
|
|
case( RP_RM ): nAzim = 18000, nElev = 4500; break;
|
|
|
|
case( RP_LB ): nAzim = 31500, nElev = 4500; break;
|
|
|
|
case( RP_MB ): nAzim = 27000, nElev = 4500; break;
|
|
|
|
case( RP_RB ): nAzim = 22500, nElev = 4500; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
BmpFilterParam aParam( nAzim, nElev );
|
|
|
|
|
|
|
|
if( rGraphic.IsAnimated() )
|
|
|
|
{
|
|
|
|
Animation aAnim( rGraphic.GetAnimation() );
|
|
|
|
|
|
|
|
if( aAnim.Filter( BMP_FILTER_EMBOSS_GREY, &aParam ) )
|
|
|
|
aRet = aAnim;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
|
|
|
|
|
|
|
|
if( aBmpEx.Filter( BMP_FILTER_EMBOSS_GREY, &aParam ) )
|
|
|
|
aRet = aBmpEx;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
2010-10-12 15:57:08 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|