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
44c6c4da
Kaydet (Commit)
44c6c4da
authored
Mar 25, 2015
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
vcl: tests for Bitmap, check for symmetry when scaling bitmaps
Change-Id: I53d6e70018477abb9f98140a52697c1de0f90934
üst
389bf9e1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
258 additions
and
0 deletions
+258
-0
CppunitTest_vcl_bitmap_test.mk
vcl/CppunitTest_vcl_bitmap_test.mk
+56
-0
Library_vcl.mk
vcl/Library_vcl.mk
+1
-0
Module_vcl.mk
vcl/Module_vcl.mk
+1
-0
BitmapSymmetryCheck.hxx
vcl/inc/BitmapSymmetryCheck.hxx
+31
-0
BitmapTest.cxx
vcl/qa/cppunit/BitmapTest.cxx
+88
-0
BitmapSymmetryCheck.cxx
vcl/source/bitmap/BitmapSymmetryCheck.cxx
+81
-0
No files found.
vcl/CppunitTest_vcl_bitmap_test.mk
0 → 100644
Dosyayı görüntüle @
44c6c4da
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_CppunitTest_CppunitTest,vcl_bitmap_test))
$(eval $(call gb_CppunitTest_add_exception_objects,vcl_bitmap_test, \
vcl/qa/cppunit/BitmapTest \
))
$(eval $(call gb_CppunitTest_use_externals,vcl_bitmap_test,\
boost_headers \
))
$(eval $(call gb_CppunitTest_set_include,vcl_bitmap_test,\
$$(INCLUDE) \
-I$(SRCDIR)/vcl/inc \
))
$(eval $(call gb_CppunitTest_use_libraries,vcl_bitmap_test, \
comphelper \
cppu \
cppuhelper \
sal \
svt \
test \
tl \
unotest \
vcl \
utl \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_use_api,vcl_bitmap_test,\
udkapi \
offapi \
))
$(eval $(call gb_CppunitTest_use_ure,vcl_bitmap_test))
$(eval $(call gb_CppunitTest_use_vcl,vcl_bitmap_test))
$(eval $(call gb_CppunitTest_use_components,vcl_bitmap_test,\
configmgr/source/configmgr \
i18npool/util/i18npool \
ucb/source/core/ucb1 \
unotools/util/utl \
))
$(eval $(call gb_CppunitTest_use_configuration,vcl_bitmap_test))
# vim: set noet sw=4 ts=4:
vcl/Library_vcl.mk
Dosyayı görüntüle @
44c6c4da
...
...
@@ -315,6 +315,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/wall \
vcl/source/bitmap/bitmapfilter \
vcl/source/bitmap/bitmapscalesuper \
vcl/source/bitmap/BitmapSymmetryCheck \
vcl/source/helper/canvasbitmap \
vcl/source/helper/canvastools \
vcl/source/helper/evntpost \
...
...
vcl/Module_vcl.mk
Dosyayı görüntüle @
44c6c4da
...
...
@@ -99,6 +99,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
endif
$(eval $(call gb_Module_add_check_targets,vcl,\
CppunitTest_vcl_bitmap_test \
CppunitTest_vcl_fontcharmap \
CppunitTest_vcl_complextext \
CppunitTest_vcl_filters_test \
...
...
vcl/inc/BitmapSymmetryCheck.hxx
0 → 100644
Dosyayı görüntüle @
44c6c4da
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*
*/
#ifndef INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
#define INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
#include <vcl/bitmap.hxx>
#include <vcl/bmpacc.hxx>
class
VCL_DLLPUBLIC
BitmapSymmetryCheck
{
public
:
BitmapSymmetryCheck
();
virtual
~
BitmapSymmetryCheck
();
bool
check
(
Bitmap
&
rBitmap
);
protected
:
virtual
bool
checkImpl
(
BitmapReadAccess
*
pReadAccess
);
};
#endif // INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl/qa/cppunit/BitmapTest.cxx
0 → 100644
Dosyayı görüntüle @
44c6c4da
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*/
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <vcl/bitmap.hxx>
#include <vcl/bmpacc.hxx>
#include <tools/stream.hxx>
#include <vcl/graphicfilter.hxx>
#include "BitmapSymmetryCheck.hxx"
namespace
{
class
BitmapTest
:
public
CppUnit
::
TestFixture
{
void
testScale
();
CPPUNIT_TEST_SUITE
(
BitmapTest
);
CPPUNIT_TEST
(
testScale
);
CPPUNIT_TEST_SUITE_END
();
};
void
BitmapTest
::
testScale
()
{
bool
bExportBitmap
(
false
);
Bitmap
aBitmap24Bit
(
Size
(
10
,
10
),
24
);
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
sal_uInt16
>
(
24
),
aBitmap24Bit
.
GetBitCount
());
{
Bitmap
::
ScopedWriteAccess
aWriteAccess
(
aBitmap24Bit
);
aWriteAccess
->
Erase
(
COL_WHITE
);
aWriteAccess
->
SetLineColor
(
COL_BLACK
);
aWriteAccess
->
DrawRect
(
Rectangle
(
1
,
1
,
8
,
8
));
aWriteAccess
->
DrawRect
(
Rectangle
(
3
,
3
,
6
,
6
));
}
BitmapSymmetryCheck
aBitmapSymmetryCheck
;
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
long
>
(
10
),
aBitmap24Bit
.
GetSizePixel
().
Width
());
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
long
>
(
10
),
aBitmap24Bit
.
GetSizePixel
().
Height
());
// Check symmetry of the bitmap
CPPUNIT_ASSERT
(
aBitmapSymmetryCheck
.
check
(
aBitmap24Bit
));
if
(
bExportBitmap
)
{
SvFileStream
aStream
(
OUString
(
"~/scale_before.png"
),
StreamMode
::
WRITE
|
StreamMode
::
TRUNC
);
GraphicFilter
&
rFilter
=
GraphicFilter
::
GetGraphicFilter
();
rFilter
.
compressAsPNG
(
aBitmap24Bit
,
aStream
,
9
);
}
aBitmap24Bit
.
Scale
(
2
,
2
,
BMP_SCALE_FAST
);
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
long
>
(
20
),
aBitmap24Bit
.
GetSizePixel
().
Width
());
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
long
>
(
20
),
aBitmap24Bit
.
GetSizePixel
().
Height
());
// After scaling the bitmap should still be symmetrical. This check guarantees that
// scaling doesn't misalign the bitmap.
CPPUNIT_ASSERT
(
aBitmapSymmetryCheck
.
check
(
aBitmap24Bit
));
if
(
bExportBitmap
)
{
SvFileStream
aStream
(
OUString
(
"~/scale_after.png"
),
StreamMode
::
WRITE
|
StreamMode
::
TRUNC
);
GraphicFilter
&
rFilter
=
GraphicFilter
::
GetGraphicFilter
();
rFilter
.
compressAsPNG
(
aBitmap24Bit
,
aStream
,
9
);
}
}
}
// namespace
CPPUNIT_TEST_SUITE_REGISTRATION
(
BitmapTest
);
CPPUNIT_PLUGIN_IMPLEMENT
();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl/source/bitmap/BitmapSymmetryCheck.cxx
0 → 100644
Dosyayı görüntüle @
44c6c4da
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*
*/
#include <BitmapSymmetryCheck.hxx>
BitmapSymmetryCheck
::
BitmapSymmetryCheck
()
{}
BitmapSymmetryCheck
::~
BitmapSymmetryCheck
()
{}
bool
BitmapSymmetryCheck
::
check
(
Bitmap
&
rBitmap
)
{
Bitmap
::
ScopedReadAccess
aReadAccess
(
rBitmap
);
return
checkImpl
(
aReadAccess
.
get
());
}
bool
BitmapSymmetryCheck
::
checkImpl
(
BitmapReadAccess
*
pReadAccess
)
{
long
nHeight
=
pReadAccess
->
Height
();
long
nWidth
=
pReadAccess
->
Width
();
long
nHeightHalf
=
nHeight
/
2
;
long
nWidthHalf
=
nWidth
/
2
;
bool
nHeightEven
=
(
nHeight
%
2
)
==
0
;
bool
nWidthEven
=
(
nWidth
%
2
)
==
0
;
for
(
long
y
=
0
;
y
<
nHeightHalf
;
++
y
)
{
for
(
long
x
=
0
;
x
<
nWidthHalf
;
++
x
)
{
if
(
pReadAccess
->
GetPixel
(
y
,
x
)
!=
pReadAccess
->
GetPixel
(
nHeight
-
y
-
1
,
x
))
{
return
false
;
}
if
(
pReadAccess
->
GetPixel
(
y
,
x
)
!=
pReadAccess
->
GetPixel
(
y
,
nWidth
-
x
-
1
))
{
return
false
;
}
if
(
pReadAccess
->
GetPixel
(
y
,
x
)
!=
pReadAccess
->
GetPixel
(
nHeight
-
y
-
1
,
nWidth
-
x
-
1
))
{
return
false
;
}
}
}
if
(
nWidthEven
)
{
for
(
long
y
=
0
;
y
<
nHeightHalf
;
++
y
)
{
if
(
pReadAccess
->
GetPixel
(
y
,
nWidthHalf
)
!=
pReadAccess
->
GetPixel
(
nHeight
-
y
-
1
,
nWidthHalf
))
{
return
false
;
}
}
}
if
(
nHeightEven
)
{
for
(
long
x
=
0
;
x
<
nWidthHalf
;
++
x
)
{
if
(
pReadAccess
->
GetPixel
(
nHeightHalf
,
x
)
!=
pReadAccess
->
GetPixel
(
nHeightHalf
,
nWidth
-
x
-
1
))
{
return
false
;
}
}
}
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