Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
transfer-engine
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mer-core
transfer-engine
Commits
c5cad52b
Commit
c5cad52b
authored
Nov 20, 2013
by
Marko Mattila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review fixes
parent
e4e430db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
29 deletions
+29
-29
lib/imageoperation.cpp
lib/imageoperation.cpp
+18
-18
lib/imageoperation.h
lib/imageoperation.h
+1
-1
tests/ut_imageoperation.cpp
tests/ut_imageoperation.cpp
+10
-10
No files found.
lib/imageoperation.cpp
View file @
c5cad52b
...
...
@@ -186,7 +186,7 @@ QString ImageOperation::scaleImage(const QString &sourceFile, qreal scaleFactor,
// performance bottlenecks here.
QImageReader
ir
(
sourceFile
);
if
(
!
ir
.
canRead
())
{
qWarning
()
<<
Q_FUNC_INFO
<<
"Couldn't
'
source image!"
;
qWarning
()
<<
Q_FUNC_INFO
<<
"Couldn't
read
source image!"
;
return
QString
();
}
...
...
@@ -197,10 +197,10 @@ QString ImageOperation::scaleImage(const QString &sourceFile, qreal scaleFactor,
int
angle
;
bool
mirrored
;
imageOrientation
(
sourceFile
,
angle
,
&
mirrored
);
imageOrientation
(
sourceFile
,
&
angle
,
&
mirrored
);
if
(
mirrored
)
{
image
.
mirrored
(
true
,
false
);
image
=
image
.
mirrored
(
true
,
false
);
}
if
(
angle
!=
0
)
{
...
...
@@ -297,10 +297,10 @@ QString ImageOperation::scaleImageToSize(const QString &sourceFile, quint64 targ
// Make sure orientation is right.
int
angle
;
bool
mirrored
;
imageOrientation
(
sourceFile
,
angle
,
&
mirrored
);
imageOrientation
(
sourceFile
,
&
angle
,
&
mirrored
);
if
(
mirrored
)
{
image
.
mirrored
(
true
,
false
);
image
=
image
.
mirrored
(
true
,
false
);
}
if
(
angle
!=
0
)
{
...
...
@@ -319,32 +319,32 @@ QString ImageOperation::scaleImageToSize(const QString &sourceFile, quint64 targ
return
tmpFile
;
}
void
ImageOperation
::
imageOrientation
(
const
QString
&
sourceFile
,
int
&
angle
,
bool
*
mirror
)
void
ImageOperation
::
imageOrientation
(
const
QString
&
sourceFile
,
int
*
angle
,
bool
*
mirror
)
{
if
(
!
QuillMetadata
::
canRead
(
sourceFile
))
{
qWarning
()
<<
Q_FUNC_INFO
<<
"Can't read metadata"
;
angle
=
0
;
mirror
=
false
;
*
angle
=
0
;
*
mirror
=
false
;
return
;
}
QuillMetadata
md
(
sourceFile
);
if
(
!
md
.
hasExif
())
{
qWarning
()
<<
"Metadata invalid"
;
angle
=
0
;
mirror
=
false
;
*
angle
=
0
;
*
mirror
=
false
;
return
;
}
int
exifOrientation
=
md
.
entry
(
QuillMetadata
::
Tag_Orientation
).
toInt
();
switch
(
exifOrientation
)
{
case
1
:
angle
=
0
;
*
mirror
=
false
;
break
;
case
2
:
angle
=
0
;
*
mirror
=
true
;
break
;
case
3
:
angle
=
180
;
*
mirror
=
false
;
break
;
case
4
:
angle
=
180
;
*
mirror
=
true
;
break
;
case
5
:
angle
=
90
;
*
mirror
=
true
;
break
;
case
6
:
angle
=
90
;
*
mirror
=
false
;
break
;
case
7
:
angle
=
270
;
*
mirror
=
true
;
break
;
case
8
:
angle
=
270
;
*
mirror
=
false
;
break
;
case
1
:
*
angle
=
0
;
*
mirror
=
false
;
break
;
case
2
:
*
angle
=
0
;
*
mirror
=
true
;
break
;
case
3
:
*
angle
=
180
;
*
mirror
=
false
;
break
;
case
4
:
*
angle
=
180
;
*
mirror
=
true
;
break
;
case
5
:
*
angle
=
90
;
*
mirror
=
true
;
break
;
case
6
:
*
angle
=
90
;
*
mirror
=
false
;
break
;
case
7
:
*
angle
=
270
;
*
mirror
=
true
;
break
;
case
8
:
*
angle
=
270
;
*
mirror
=
false
;
break
;
default:
break
;
}
}
lib/imageoperation.h
View file @
c5cad52b
...
...
@@ -37,7 +37,7 @@ public:
static
QString
removeImageMetadata
(
const
QString
&
sourceFile
);
static
QString
scaleImage
(
const
QString
&
sourceFile
,
qreal
scaleFactor
,
const
QString
&
targetFile
=
QString
());
static
QString
scaleImageToSize
(
const
QString
&
sourceFile
,
quint64
targetSize
,
const
QString
&
targetFile
=
QString
());
static
void
imageOrientation
(
const
QString
&
sourceFile
,
int
&
angle
,
bool
*
mirror
);
static
void
imageOrientation
(
const
QString
&
sourceFile
,
int
*
angle
,
bool
*
mirror
);
};
#endif // IMAGEOPERATION_H
tests/ut_imageoperation.cpp
View file @
c5cad52b
...
...
@@ -116,7 +116,7 @@ void ut_imageoperation::testScale()
int
angle
;
bool
mirror
;
ImageOperation
::
imageOrientation
(
filePath
,
angle
,
&
mirror
);
ImageOperation
::
imageOrientation
(
filePath
,
&
angle
,
&
mirror
);
QCOMPARE
(
angle
,
90
);
QCOMPARE
(
mirror
,
false
);
...
...
@@ -157,7 +157,7 @@ void ut_imageoperation::testScaleToSize()
int
angle
;
bool
mirror
;
ImageOperation
::
imageOrientation
(
filePath
,
angle
,
&
mirror
);
ImageOperation
::
imageOrientation
(
filePath
,
&
angle
,
&
mirror
);
QCOMPARE
(
angle
,
90
);
QCOMPARE
(
mirror
,
false
);
...
...
@@ -245,35 +245,35 @@ void ut_imageoperation::testOrientation()
{
int
angle
;
bool
mirrored
;
ImageOperation
::
imageOrientation
(
"images/testimage-0.jpg"
,
angle
,
&
mirrored
);
ImageOperation
::
imageOrientation
(
"images/testimage-0.jpg"
,
&
angle
,
&
mirrored
);
QCOMPARE
(
angle
,
0
);
QCOMPARE
(
mirrored
,
false
);
ImageOperation
::
imageOrientation
(
"images/testimage-0-mirrored.jpg"
,
angle
,
&
mirrored
);
ImageOperation
::
imageOrientation
(
"images/testimage-0-mirrored.jpg"
,
&
angle
,
&
mirrored
);
QCOMPARE
(
angle
,
0
);
QCOMPARE
(
mirrored
,
true
);
ImageOperation
::
imageOrientation
(
"images/testimage-90.jpg"
,
angle
,
&
mirrored
);
ImageOperation
::
imageOrientation
(
"images/testimage-90.jpg"
,
&
angle
,
&
mirrored
);
QCOMPARE
(
angle
,
90
);
QCOMPARE
(
mirrored
,
false
);
ImageOperation
::
imageOrientation
(
"images/testimage-90-mirrored.jpg"
,
angle
,
&
mirrored
);
ImageOperation
::
imageOrientation
(
"images/testimage-90-mirrored.jpg"
,
&
angle
,
&
mirrored
);
QCOMPARE
(
angle
,
90
);
QCOMPARE
(
mirrored
,
true
);
ImageOperation
::
imageOrientation
(
"images/testimage-180.jpg"
,
angle
,
&
mirrored
);
ImageOperation
::
imageOrientation
(
"images/testimage-180.jpg"
,
&
angle
,
&
mirrored
);
QCOMPARE
(
angle
,
180
);
QCOMPARE
(
mirrored
,
false
);
ImageOperation
::
imageOrientation
(
"images/testimage-180-mirrored.jpg"
,
angle
,
&
mirrored
);
ImageOperation
::
imageOrientation
(
"images/testimage-180-mirrored.jpg"
,
&
angle
,
&
mirrored
);
QCOMPARE
(
angle
,
180
);
QCOMPARE
(
mirrored
,
true
);
ImageOperation
::
imageOrientation
(
"images/testimage-270.jpg"
,
angle
,
&
mirrored
);
ImageOperation
::
imageOrientation
(
"images/testimage-270.jpg"
,
&
angle
,
&
mirrored
);
QCOMPARE
(
angle
,
270
);
QCOMPARE
(
mirrored
,
false
);
ImageOperation
::
imageOrientation
(
"images/testimage-270-mirrored.jpg"
,
angle
,
&
mirrored
);
ImageOperation
::
imageOrientation
(
"images/testimage-270-mirrored.jpg"
,
&
angle
,
&
mirrored
);
QCOMPARE
(
angle
,
270
);
QCOMPARE
(
mirrored
,
true
);
}
...
...
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