Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
7bc35a15
Commit
7bc35a15
authored
Feb 03, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented case when the size of the masked image doesn't match to the size of the mask.
parent
903245e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
22 deletions
+74
-22
PdfReader/Src/RendererOutputDev.cpp
PdfReader/Src/RendererOutputDev.cpp
+74
-22
No files found.
PdfReader/Src/RendererOutputDev.cpp
View file @
7bc35a15
...
@@ -3306,12 +3306,10 @@ namespace PdfReader
...
@@ -3306,12 +3306,10 @@ namespace PdfReader
}
}
void
RendererOutputDev
::
DrawMaskedImage
(
GrState
*
pGState
,
Object
*
pRef
,
Stream
*
pStream
,
int
nWidth
,
int
nHeight
,
GrImageColorMap
*
pColorMap
,
Stream
*
pMaskStream
,
int
nMaskWidth
,
int
nMaskHeight
,
bool
bMaskInvert
)
void
RendererOutputDev
::
DrawMaskedImage
(
GrState
*
pGState
,
Object
*
pRef
,
Stream
*
pStream
,
int
nWidth
,
int
nHeight
,
GrImageColorMap
*
pColorMap
,
Stream
*
pMaskStream
,
int
nMaskWidth
,
int
nMaskHeight
,
bool
bMaskInvert
)
{
{
if
(
m_bDrawOnlyText
)
if
(
m_bDrawOnlyText
)
return
;
return
;
// Вообще, размеры маски и самой картинки могут не совпадать (в этом случае мы должны срезайзить до размеров картинки)
if
(
nMaskWidth
<=
0
||
nMaskHeight
<=
0
)
// TO DO: Сделать, когда появится файл
if
(
nWidth
!=
nMaskWidth
||
nHeight
!=
nMaskHeight
)
DrawImage
(
pGState
,
pRef
,
pStream
,
nWidth
,
nHeight
,
pColorMap
,
NULL
,
false
);
DrawImage
(
pGState
,
pRef
,
pStream
,
nWidth
,
nHeight
,
pColorMap
,
NULL
,
false
);
double
dPageHeight
=
pGState
->
GetPageHeight
();
double
dPageHeight
=
pGState
->
GetPageHeight
();
...
@@ -3334,25 +3332,79 @@ namespace PdfReader
...
@@ -3334,25 +3332,79 @@ namespace PdfReader
pMask
->
Reset
();
pMask
->
Reset
();
pImageStream
->
Reset
();
pImageStream
->
Reset
();
unsigned
char
unPixel
[
4
]
=
{
0
,
0
,
0
,
0
};
if
(
nWidth
!=
nMaskWidth
||
nHeight
!=
nMaskHeight
)
unsigned
char
unMask
=
0
;
for
(
int
nY
=
nHeight
-
1
;
nY
>=
0
;
nY
--
)
{
{
for
(
int
nX
=
0
;
nX
<
nWidth
;
nX
++
)
unsigned
char
*
pMaskBuffer
=
new
unsigned
char
[
nMaskWidth
*
nMaskHeight
];
if
(
!
pMaskBuffer
)
{
{
int
nIndex
=
4
*
(
nX
+
nY
*
nWidth
);
delete
pMask
;
pImageStream
->
GetPixel
(
unPixel
);
delete
pImageStream
;
pMask
->
GetPixel
(
&
unMask
);
return
;
GrRGB
oRGB
;
}
pColorMap
->
GetRGB
(
unPixel
,
&
oRGB
);
pBufferPtr
[
nIndex
+
0
]
=
ColorToByte
(
oRGB
.
b
);
pBufferPtr
[
nIndex
+
1
]
=
ColorToByte
(
oRGB
.
g
);
pBufferPtr
[
nIndex
+
2
]
=
ColorToByte
(
oRGB
.
r
);
if
(
unMask
&&
!
bMaskInvert
)
unsigned
char
unMask
=
0
;
pBufferPtr
[
nIndex
+
3
]
=
0
;
for
(
int
nY
=
nMaskHeight
-
1
;
nY
>=
0
;
nY
--
)
else
{
pBufferPtr
[
nIndex
+
3
]
=
255
;
for
(
int
nX
=
0
;
nX
<
nMaskWidth
;
nX
++
)
{
int
nIndex
=
nX
+
nY
*
nMaskWidth
;
pMask
->
GetPixel
(
&
unMask
);
pMaskBuffer
[
nIndex
]
=
unMask
;
}
}
double
dScaleWidth
=
(
double
)
nWidth
/
(
double
)
nMaskWidth
;
double
dScaleHeight
=
(
double
)
nHeight
/
(
double
)
nMaskHeight
;
unsigned
char
unPixel
[
4
]
=
{
0
,
0
,
0
,
0
};
for
(
int
nY
=
nHeight
-
1
;
nY
>=
0
;
nY
--
)
{
for
(
int
nX
=
0
;
nX
<
nWidth
;
nX
++
)
{
int
nIndex
=
4
*
(
nX
+
nY
*
nWidth
);
pImageStream
->
GetPixel
(
unPixel
);
int
nNearestY
=
std
::
min
((
int
)(
nY
/
dScaleHeight
),
nMaskHeight
-
1
);
int
nNearestX
=
std
::
min
((
int
)(
nX
/
dScaleWidth
),
nMaskWidth
-
1
);
unMask
=
pMaskBuffer
[
nNearestY
*
nMaskWidth
+
nNearestX
];
GrRGB
oRGB
;
pColorMap
->
GetRGB
(
unPixel
,
&
oRGB
);
pBufferPtr
[
nIndex
+
0
]
=
ColorToByte
(
oRGB
.
b
);
pBufferPtr
[
nIndex
+
1
]
=
ColorToByte
(
oRGB
.
g
);
pBufferPtr
[
nIndex
+
2
]
=
ColorToByte
(
oRGB
.
r
);
if
(
unMask
&&
!
bMaskInvert
)
pBufferPtr
[
nIndex
+
3
]
=
0
;
else
pBufferPtr
[
nIndex
+
3
]
=
255
;
}
}
delete
[]
pMaskBuffer
;
}
else
{
unsigned
char
unPixel
[
4
]
=
{
0
,
0
,
0
,
0
};
unsigned
char
unMask
=
0
;
for
(
int
nY
=
nHeight
-
1
;
nY
>=
0
;
nY
--
)
{
for
(
int
nX
=
0
;
nX
<
nWidth
;
nX
++
)
{
int
nIndex
=
4
*
(
nX
+
nY
*
nWidth
);
pImageStream
->
GetPixel
(
unPixel
);
pMask
->
GetPixel
(
&
unMask
);
GrRGB
oRGB
;
pColorMap
->
GetRGB
(
unPixel
,
&
oRGB
);
pBufferPtr
[
nIndex
+
0
]
=
ColorToByte
(
oRGB
.
b
);
pBufferPtr
[
nIndex
+
1
]
=
ColorToByte
(
oRGB
.
g
);
pBufferPtr
[
nIndex
+
2
]
=
ColorToByte
(
oRGB
.
r
);
if
(
unMask
&&
!
bMaskInvert
)
pBufferPtr
[
nIndex
+
3
]
=
0
;
else
pBufferPtr
[
nIndex
+
3
]
=
255
;
}
}
}
}
}
...
@@ -3362,7 +3414,7 @@ namespace PdfReader
...
@@ -3362,7 +3414,7 @@ namespace PdfReader
double
arrMatrix
[
6
];
double
arrMatrix
[
6
];
double
*
pCTM
=
pGState
->
GetCTM
();
double
*
pCTM
=
pGState
->
GetCTM
();
// Исходное предобразование
// Исходное предобразование
// |1 0 0| |pCTM[0] pCTM[1] 0|
// |1 0 0| |pCTM[0] pCTM[1] 0|
// arrMatrix = |0 -1 0| * |pCTM[2] pCTM[3] 0|
// arrMatrix = |0 -1 0| * |pCTM[2] pCTM[3] 0|
// |0 1 1| |pCTM[4] pCTM[5] 1|
// |0 1 1| |pCTM[4] pCTM[5] 1|
arrMatrix
[
0
]
=
pCTM
[
0
];
arrMatrix
[
0
]
=
pCTM
[
0
];
...
...
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