Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
8b716072
Kaydet (Commit)
8b716072
authored
Tem 17, 2013
tarafından
Muthu Subramanian
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
n#820077: Import images with duotone filter.
Also, contains implementation for a simple duotone filter.
üst
09fb28de
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
145 additions
and
1 deletion
+145
-1
fillproperties.hxx
include/oox/drawingml/fillproperties.hxx
+1
-0
fillpropertiesgroupcontext.hxx
include/oox/drawingml/fillpropertiesgroupcontext.hxx
+24
-0
bitmap.hxx
include/vcl/bitmap.hxx
+2
-0
XGraphicTransformer.idl
offapi/com/sun/star/graphic/XGraphicTransformer.idl
+9
-0
fillproperties.cxx
oox/source/drawingml/fillproperties.cxx
+17
-1
fillpropertiesgroupcontext.cxx
oox/source/drawingml/fillpropertiesgroupcontext.cxx
+25
-0
transformer.cxx
svtools/source/graphic/transformer.cxx
+19
-0
transformer.hxx
svtools/source/graphic/transformer.hxx
+5
-0
bitmap4.cxx
vcl/source/gdi/bitmap4.cxx
+43
-0
No files found.
include/oox/drawingml/fillproperties.hxx
Dosyayı görüntüle @
8b716072
...
...
@@ -93,6 +93,7 @@ struct BlipFillProperties
OptValue
<
sal_Int32
>
moContrast
;
/// Contrast in the range [-100000,100000].
Color
maColorChangeFrom
;
/// Start color of color transformation.
Color
maColorChangeTo
;
/// Destination color of color transformation.
Color
maDuotoneColors
[
2
];
/// Duotone Colors
/** Overwrites all members that are explicitly set in rSourceProps. */
void
assignUsed
(
const
BlipFillProperties
&
rSourceProps
);
...
...
include/oox/drawingml/fillpropertiesgroupcontext.hxx
Dosyayı görüntüle @
8b716072
...
...
@@ -76,6 +76,30 @@ private:
PatternFillProperties
&
mrPatternProps
;
};
// ============================================================================
/** Context handler that imports the a:duotone element containing the colors
of a bitmap duotone transformation. */
class
DuotoneContext
:
public
::
oox
::
core
::
ContextHandler2
{
public
:
explicit
DuotoneContext
(
::
oox
::
core
::
ContextHandler2Helper
&
rParent
,
const
::
oox
::
AttributeList
&
rAttribs
,
BlipFillProperties
&
rBlipProps
);
virtual
~
DuotoneContext
();
virtual
::
oox
::
core
::
ContextHandlerRef
onCreateContext
(
sal_Int32
nElement
,
const
::
oox
::
AttributeList
&
rAttribs
)
SAL_OVERRIDE
;
private
:
BlipFillProperties
&
mrBlipProps
;
int
mnColorIndex
;
};
// ============================================================================
/** Context handler that imports the a:clrChange element containing the colors
of a bitmap color change transformation. */
...
...
include/vcl/bitmap.hxx
Dosyayı görüntüle @
8b716072
...
...
@@ -120,6 +120,7 @@ enum BmpFilter
BMP_FILTER_SEPIA
=
6
,
BMP_FILTER_MOSAIC
=
7
,
BMP_FILTER_POPART
=
8
,
BMP_FILTER_DUOTONE
=
9
,
BMP_FILTER_UNKNOWN
=
65535
};
...
...
@@ -362,6 +363,7 @@ public:
SAL_DLLPRIVATE
bool
ImplSeparableBlurFilter
(
const
double
aRadius
=
0.7
);
SAL_DLLPRIVATE
bool
ImplSeparableUnsharpenFilter
(
const
double
aRadius
=
0.7
);
SAL_DLLPRIVATE
bool
ImplDuotoneFilter
(
const
sal_uLong
nColorOne
,
sal_uLong
nColorTwo
);
SAL_DLLPRIVATE
void
ImplBlurContributions
(
const
int
aSize
,
const
int
aNumberOfContributions
,
double
*
pBlurVector
,
double
*&
pWeights
,
int
*&
pPixels
,
int
*&
pCount
);
public
:
...
...
offapi/com/sun/star/graphic/XGraphicTransformer.idl
Dosyayı görüntüle @
8b716072
...
...
@@ -42,6 +42,15 @@ interface XGraphicTransformer : ::com::sun::star::uno::XInterface
com
::
sun
::
star
::
graphic
::
XGraphic
colorChange
(
[
in
]
com
::
sun
::
star
::
graphic
::
XGraphic
In
,
[
in
]
long
ColorFrom
,
[
in
]
byte
tolerance
,
[
in
]
long
ColorTo
,
[
in
]
byte
AlphaTo
)
raises
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
)
;
/**
applies
Duotone
effect
@
returns
The
modified
graphic
*/
com
::
sun
::
star
::
graphic
::
XGraphic
applyDuotone
(
[
in
]
com
::
sun
::
star
::
graphic
::
XGraphic
In
,
[
in
]
long
ColorOne
,
[
in
]
long
ColorTwo
)
raises
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
)
;
}
;
}
; } ; } ; } ;
...
...
oox/source/drawingml/fillproperties.cxx
Dosyayı görüntüle @
8b716072
...
...
@@ -149,6 +149,8 @@ void BlipFillProperties::assignUsed( const BlipFillProperties& rSourceProps )
moContrast
.
assignIfUsed
(
rSourceProps
.
moContrast
);
maColorChangeFrom
.
assignIfUsed
(
rSourceProps
.
maColorChangeFrom
);
maColorChangeTo
.
assignIfUsed
(
rSourceProps
.
maColorChangeTo
);
maDuotoneColors
[
0
].
assignIfUsed
(
rSourceProps
.
maDuotoneColors
[
0
]
);
maDuotoneColors
[
1
].
assignIfUsed
(
rSourceProps
.
maDuotoneColors
[
1
]
);
}
// ============================================================================
...
...
@@ -372,9 +374,23 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
// do not start complex graphic transformation if property is not supported...
if
(
maBlipProps
.
mxGraphic
.
is
()
&&
rPropMap
.
supportsProperty
(
SHAPEPROP_FillBitmapUrl
)
)
{
Reference
<
XGraphic
>
xGraphic
=
maBlipProps
.
mxGraphic
;
if
(
maBlipProps
.
maDuotoneColors
[
0
].
isUsed
()
&&
maBlipProps
.
maDuotoneColors
[
1
].
isUsed
()
)
{
sal_Int32
nColor1
=
maBlipProps
.
maDuotoneColors
[
0
].
getColor
(
rGraphicHelper
,
nPhClr
);
sal_Int32
nColor2
=
maBlipProps
.
maDuotoneColors
[
1
].
getColor
(
rGraphicHelper
,
nPhClr
);
try
{
Reference
<
XGraphicTransformer
>
xTransformer
(
maBlipProps
.
mxGraphic
,
UNO_QUERY_THROW
);
xGraphic
=
xTransformer
->
applyDuotone
(
maBlipProps
.
mxGraphic
,
nColor1
,
nColor2
);
}
catch
(
Exception
&
)
{
}
}
// TODO: "rotate with shape" is not possible with our current core
OUString
aGraphicUrl
=
rGraphicHelper
.
createGraphicObject
(
maBlipProps
.
m
xGraphic
);
OUString
aGraphicUrl
=
rGraphicHelper
.
createGraphicObject
(
xGraphic
);
// push bitmap or named bitmap to property map
if
(
!
aGraphicUrl
.
isEmpty
()
&&
rPropMap
.
setProperty
(
SHAPEPROP_FillBitmapUrl
,
aGraphicUrl
)
)
eFillStyle
=
FillStyle_BITMAP
;
...
...
oox/source/drawingml/fillpropertiesgroupcontext.cxx
Dosyayı görüntüle @
8b716072
...
...
@@ -179,6 +179,9 @@ ContextHandlerRef BlipContext::onCreateContext(
case
A_TOKEN
(
clrChange
):
return
new
ColorChangeContext
(
*
this
,
rAttribs
,
mrBlipProps
);
case
A_TOKEN
(
duotone
):
return
new
DuotoneContext
(
*
this
,
rAttribs
,
mrBlipProps
);
case
A_TOKEN
(
lum
):
mrBlipProps
.
moBrightness
=
rAttribs
.
getInteger
(
XML_bright
);
mrBlipProps
.
moContrast
=
rAttribs
.
getInteger
(
XML_contrast
);
...
...
@@ -187,6 +190,28 @@ ContextHandlerRef BlipContext::onCreateContext(
return
0
;
}
DuotoneContext
::
DuotoneContext
(
ContextHandler2Helper
&
rParent
,
const
AttributeList
&
/*rAttribs*/
,
BlipFillProperties
&
rBlipProps
)
:
ContextHandler2
(
rParent
),
mrBlipProps
(
rBlipProps
),
mnColorIndex
(
0
)
{
mrBlipProps
.
maDuotoneColors
[
0
].
setUnused
();
mrBlipProps
.
maDuotoneColors
[
1
].
setUnused
();
}
DuotoneContext
::~
DuotoneContext
()
{
}
::
oox
::
core
::
ContextHandlerRef
DuotoneContext
::
onCreateContext
(
sal_Int32
/*nElement*/
,
const
AttributeList
&
/*rAttribs*/
)
{
if
(
mnColorIndex
<
2
)
return
new
ColorValueContext
(
*
this
,
mrBlipProps
.
maDuotoneColors
[
mnColorIndex
++
]
);
return
0
;
}
BlipFillContext
::
BlipFillContext
(
ContextHandler2Helper
&
rParent
,
const
AttributeList
&
rAttribs
,
BlipFillProperties
&
rBlipProps
)
:
ContextHandler2
(
rParent
),
...
...
svtools/source/graphic/transformer.cxx
Dosyayı görüntüle @
8b716072
...
...
@@ -139,6 +139,25 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
return
xRet
;
}
uno
::
Reference
<
graphic
::
XGraphic
>
SAL_CALL
GraphicTransformer
::
applyDuotone
(
const
uno
::
Reference
<
graphic
::
XGraphic
>&
rxGraphic
,
sal_Int32
nColorOne
,
sal_Int32
nColorTwo
)
throw
(
lang
::
IllegalArgumentException
,
uno
::
RuntimeException
)
{
const
uno
::
Reference
<
uno
::
XInterface
>
xIFace
(
rxGraphic
,
uno
::
UNO_QUERY
);
::
Graphic
aGraphic
(
*::
unographic
::
Graphic
::
getImplementation
(
xIFace
)
);
BitmapEx
aBitmapEx
(
aGraphic
.
GetBitmapEx
()
);
Bitmap
aBitmap
(
aBitmapEx
.
GetBitmap
()
);
BmpFilterParam
aFilter
(
(
sal_uLong
)
nColorOne
,
(
sal_uLong
)
nColorTwo
);
aBitmap
.
Filter
(
BMP_FILTER_DUOTONE
,
&
aFilter
);
aGraphic
=
::
Graphic
(
BitmapEx
(
aBitmap
)
);
::
unographic
::
Graphic
*
pUnoGraphic
=
new
::
unographic
::
Graphic
();
pUnoGraphic
->
init
(
aGraphic
);
uno
::
Reference
<
graphic
::
XGraphic
>
xRet
(
pUnoGraphic
);
return
xRet
;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
svtools/source/graphic/transformer.hxx
Dosyayı görüntüle @
8b716072
...
...
@@ -46,6 +46,11 @@ class GraphicTransformer : public GraphicTransformer_UnoImplHelper1
sal_Int32
nColorFrom
,
sal_Int8
nTolerance
,
sal_Int32
nColorTo
,
sal_Int8
nAlphaTo
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
virtual
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
graphic
::
XGraphic
>
SAL_CALL
applyDuotone
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
graphic
::
XGraphic
>&
rGraphic
,
sal_Int32
nColorOne
,
sal_Int32
nColorTwo
)
throw
(
::
com
::
sun
::
star
::
lang
::
IllegalArgumentException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
};
}
...
...
vcl/source/gdi/bitmap4.cxx
Dosyayı görüntüle @
8b716072
...
...
@@ -30,6 +30,14 @@
#define MNMX5(a,b,c,d,e) S2(a,b); S2(c,d); MN3(a,c,e); MX3(b,d,e);
#define MNMX6(a,b,c,d,e,f) S2(a,d); S2(b,e); S2(c,f); MN3(a,b,c); MX3(d,e,f);
static
inline
sal_uInt8
lcl_getDuotoneColorComponent
(
sal_uInt8
base
,
sal_uInt16
color1
,
sal_uInt16
color2
)
{
color2
=
color2
*
base
/
0xFF
;
color1
=
color1
*
(
0xFF
-
base
)
/
0xFF
;
return
(
sal_uInt8
)
(
color1
+
color2
);
}
sal_Bool
Bitmap
::
Filter
(
BmpFilter
eFilter
,
const
BmpFilterParam
*
pFilterParam
,
const
Link
*
pProgress
)
{
sal_Bool
bRet
=
sal_False
;
...
...
@@ -90,6 +98,10 @@ sal_Bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam,
bRet
=
ImplPopArt
(
pFilterParam
,
pProgress
);
break
;
case
(
BMP_FILTER_DUOTONE
):
bRet
=
ImplDuotoneFilter
(
pFilterParam
->
mnProgressStart
,
pFilterParam
->
mnProgressEnd
);
break
;
default
:
OSL_FAIL
(
"Bitmap::Convert(): Unsupported filter"
);
break
;
...
...
@@ -1163,4 +1175,35 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) {
return
true
;
}
bool
Bitmap
::
ImplDuotoneFilter
(
const
sal_uLong
nColorOne
,
const
sal_uLong
nColorTwo
)
{
const
long
nWidth
=
GetSizePixel
().
Width
();
const
long
nHeight
=
GetSizePixel
().
Height
();
Bitmap
aResultBitmap
(
GetSizePixel
(),
24
);
BitmapReadAccess
*
pReadAcc
=
AcquireReadAccess
();
BitmapWriteAccess
*
pWriteAcc
=
aResultBitmap
.
AcquireWriteAccess
();
const
BitmapColor
aColorOne
(
static_cast
<
sal_uInt8
>
(
nColorOne
>>
16
),
static_cast
<
sal_uInt8
>
(
nColorOne
>>
8
),
static_cast
<
sal_uInt8
>
(
nColorOne
)
);
const
BitmapColor
aColorTwo
(
static_cast
<
sal_uInt8
>
(
nColorTwo
>>
16
),
static_cast
<
sal_uInt8
>
(
nColorTwo
>>
8
),
static_cast
<
sal_uInt8
>
(
nColorTwo
)
);
for
(
int
x
=
0
;
x
<
nWidth
;
x
++
)
{
for
(
int
y
=
0
;
y
<
nHeight
;
y
++
)
{
BitmapColor
aColor
=
pReadAcc
->
GetColor
(
y
,
x
);
BitmapColor
aResultColor
(
lcl_getDuotoneColorComponent
(
aColor
.
GetRed
(),
aColorOne
.
GetRed
(),
aColorTwo
.
GetRed
()
)
,
lcl_getDuotoneColorComponent
(
aColor
.
GetGreen
(),
aColorOne
.
GetGreen
(),
aColorTwo
.
GetGreen
()
)
,
lcl_getDuotoneColorComponent
(
aColor
.
GetBlue
(),
aColorOne
.
GetBlue
(),
aColorTwo
.
GetBlue
()
)
);
pWriteAcc
->
SetPixel
(
y
,
x
,
aResultColor
);
}
}
ReleaseAccess
(
pWriteAcc
);
ReleaseAccess
(
pReadAcc
);
ImplAssignWithSize
(
aResultBitmap
);
return
true
;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment