Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Tusooa Zhu
Krita
Commits
a1e59d2d
Commit
a1e59d2d
authored
Aug 12, 2015
by
Dmitry Kazakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement a placeholder for loading layer info block from 'Lr16' and 'Lr32' additional sections
parent
306229a9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
36 deletions
+83
-36
krita/plugins/formats/psd/psd_additional_layer_info_block.cpp
...a/plugins/formats/psd/psd_additional_layer_info_block.cpp
+13
-1
krita/plugins/formats/psd/psd_additional_layer_info_block.h
krita/plugins/formats/psd/psd_additional_layer_info_block.h
+10
-0
krita/plugins/formats/psd/psd_layer_record.cpp
krita/plugins/formats/psd/psd_layer_record.cpp
+1
-1
krita/plugins/formats/psd/psd_layer_section.cpp
krita/plugins/formats/psd/psd_layer_section.cpp
+58
-34
krita/plugins/formats/psd/psd_layer_section.h
krita/plugins/formats/psd/psd_layer_section.h
+1
-0
No files found.
krita/plugins/formats/psd/psd_additional_layer_info_block.cpp
View file @
a1e59d2d
...
...
@@ -34,6 +34,11 @@ PsdAdditionalLayerInfoBlock::PsdAdditionalLayerInfoBlock(const PSDHeader& header
{
}
void
PsdAdditionalLayerInfoBlock
::
setExtraLayerInfoBlockHandler
(
ExtraLayerInfoBlockHandler
handler
)
{
m_layerInfoBlockHandler
=
handler
;
}
bool
PsdAdditionalLayerInfoBlock
::
read
(
QIODevice
*
io
)
{
bool
result
=
true
;
...
...
@@ -90,7 +95,14 @@ void PsdAdditionalLayerInfoBlock::readImpl(QIODevice* io)
}
keys
<<
key
;
if
(
key
==
"SoCo"
)
{
if
(
key
==
"Lr16"
||
key
==
"Lr32"
)
{
if
(
m_layerInfoBlockHandler
)
{
int
offset
=
m_header
.
version
>
1
?
8
:
4
;
io
->
seek
(
io
->
pos
()
-
offset
);
m_layerInfoBlockHandler
(
io
);
}
}
else
if
(
key
==
"SoCo"
)
{
}
else
if
(
key
==
"GdFl"
)
{
...
...
krita/plugins/formats/psd/psd_additional_layer_info_block.h
View file @
a1e59d2d
...
...
@@ -30,6 +30,9 @@
#include <kis_paint_device.h>
#include <kis_node.h>
#include <boost/function.hpp>
#include "psd.h"
#include "psd_header.h"
...
...
@@ -255,6 +258,11 @@ class PsdAdditionalLayerInfoBlock
{
public:
PsdAdditionalLayerInfoBlock
(
const
PSDHeader
&
header
);
typedef
boost
::
function
<
bool
(
QIODevice
*
)
>
ExtraLayerInfoBlockHandler
;
void
setExtraLayerInfoBlockHandler
(
ExtraLayerInfoBlockHandler
handler
);
bool
read
(
QIODevice
*
io
);
bool
write
(
QIODevice
*
io
,
KisNodeSP
node
);
...
...
@@ -280,6 +288,8 @@ public:
private:
void
readImpl
(
QIODevice
*
io
);
private:
ExtraLayerInfoBlockHandler
m_layerInfoBlockHandler
;
};
#endif // PSD_ADDITIONAL_LAYER_INFO_BLOCK_H
krita/plugins/formats/psd/psd_layer_record.cpp
View file @
a1e59d2d
...
...
@@ -885,7 +885,7 @@ QMap<quint16, QByteArray> fetchChannelsBytes(QIODevice *io, QVector<ChannelInfo*
channelInfo
->
channelOffset
+=
rleLength
;
}
else
{
QString
error
=
"Unsupported Compression mode:
"
+
channelInfo
->
compressionType
;
QString
error
=
QString
(
"Unsupported Compression mode:
%1"
).
arg
(
channelInfo
->
compressionType
)
;
dbgFile
<<
"ERROR: fetchChannelsBytes:"
<<
error
;
throw
KisAslReaderUtils
::
ASLParseException
(
error
);
}
...
...
krita/plugins/formats/psd/psd_layer_section.cpp
View file @
a1e59d2d
...
...
@@ -17,6 +17,8 @@
*/
#include "psd_layer_section.h"
#include <boost/bind.hpp>
#include <QIODevice>
#include <KoColorSpace.h>
...
...
@@ -68,39 +70,8 @@ bool PSDLayerMaskSection::read(QIODevice* io)
return
retval
;
}
bool
PSDLayerMaskSection
::
readImpl
(
QIODevice
*
io
)
bool
PSDLayerMaskSection
::
read
LayerInfo
Impl
(
QIODevice
*
io
)
{
dbgFile
<<
"reading layer section. Pos:"
<<
io
->
pos
()
<<
"bytes left:"
<<
io
->
bytesAvailable
();
layerMaskBlockSize
=
0
;
if
(
m_header
.
version
==
1
)
{
quint32
_layerMaskBlockSize
=
0
;
if
(
!
psdread
(
io
,
&
_layerMaskBlockSize
)
||
_layerMaskBlockSize
>
(
quint64
)
io
->
bytesAvailable
())
{
error
=
QString
(
"Could not read layer + mask block size. Got %1. Bytes left %2"
)
.
arg
(
_layerMaskBlockSize
).
arg
(
io
->
bytesAvailable
());
return
false
;
}
layerMaskBlockSize
=
_layerMaskBlockSize
;
}
else
if
(
m_header
.
version
==
2
)
{
if
(
!
psdread
(
io
,
&
layerMaskBlockSize
)
||
layerMaskBlockSize
>
(
quint64
)
io
->
bytesAvailable
())
{
error
=
QString
(
"Could not read layer + mask block size. Got %1. Bytes left %2"
)
.
arg
(
layerMaskBlockSize
).
arg
(
io
->
bytesAvailable
());
return
false
;
}
}
quint64
start
=
io
->
pos
();
dbgFile
<<
"layer + mask section size"
<<
layerMaskBlockSize
;
if
(
layerMaskBlockSize
==
0
)
{
dbgFile
<<
"No layer + mask info, so no layers, only a background layer"
;
return
true
;
}
KIS_ASSERT_RECOVER
(
m_header
.
version
==
1
)
{
return
false
;
}
quint32
layerInfoSectionSize
=
0
;
SAFE_READ_EX
(
io
,
layerInfoSectionSize
);
...
...
@@ -109,7 +80,6 @@ bool PSDLayerMaskSection::readImpl(QIODevice* io)
layerInfoSectionSize
++
;
}
{
SETUP_OFFSET_VERIFIER
(
layerInfoSectionTag
,
io
,
layerInfoSectionSize
,
0
);
dbgFile
<<
"Layer info block size"
<<
layerInfoSectionSize
;
...
...
@@ -224,6 +194,46 @@ bool PSDLayerMaskSection::readImpl(QIODevice* io)
}
}
return
true
;
}
bool
PSDLayerMaskSection
::
readImpl
(
QIODevice
*
io
)
{
dbgFile
<<
"reading layer section. Pos:"
<<
io
->
pos
()
<<
"bytes left:"
<<
io
->
bytesAvailable
();
layerMaskBlockSize
=
0
;
if
(
m_header
.
version
==
1
)
{
quint32
_layerMaskBlockSize
=
0
;
if
(
!
psdread
(
io
,
&
_layerMaskBlockSize
)
||
_layerMaskBlockSize
>
(
quint64
)
io
->
bytesAvailable
())
{
error
=
QString
(
"Could not read layer + mask block size. Got %1. Bytes left %2"
)
.
arg
(
_layerMaskBlockSize
).
arg
(
io
->
bytesAvailable
());
return
false
;
}
layerMaskBlockSize
=
_layerMaskBlockSize
;
}
else
if
(
m_header
.
version
==
2
)
{
if
(
!
psdread
(
io
,
&
layerMaskBlockSize
)
||
layerMaskBlockSize
>
(
quint64
)
io
->
bytesAvailable
())
{
error
=
QString
(
"Could not read layer + mask block size. Got %1. Bytes left %2"
)
.
arg
(
layerMaskBlockSize
).
arg
(
io
->
bytesAvailable
());
return
false
;
}
}
quint64
start
=
io
->
pos
();
dbgFile
<<
"layer + mask section size"
<<
layerMaskBlockSize
;
if
(
layerMaskBlockSize
==
0
)
{
dbgFile
<<
"No layer + mask info, so no layers, only a background layer"
;
return
true
;
}
KIS_ASSERT_RECOVER
(
m_header
.
version
==
1
)
{
return
false
;
}
if
(
!
readLayerInfoImpl
(
io
))
{
return
false
;
}
quint32
globalMaskBlockLength
;
if
(
!
psdread
(
io
,
&
globalMaskBlockLength
))
{
error
=
"Could not read global mask info block"
;
...
...
@@ -255,7 +265,21 @@ bool PSDLayerMaskSection::readImpl(QIODevice* io)
}
}
// second try to read additional sections
// global additional sections
/**
* Newer versions of PSD have layers info block wrapped into
* 'Lr16' or 'Lr32' additional section, while the main block is
* absent.
*
* Here we pass the callback which should be used when such
* additional section is recognized.
*
* NOTE: atm, we do not support ZIP compression, which is used in
* this block, so we just comment it out for now!
*/
// globalInfoSection.setExtraLayerInfoBlockHandler(boost::bind(&PSDLayerMaskSection::readLayerInfoImpl, this, _1));
globalInfoSection
.
read
(
io
);
/* put us after this section so reading the next section will work even if we mess up */
...
...
krita/plugins/formats/psd/psd_layer_section.h
View file @
a1e59d2d
...
...
@@ -60,6 +60,7 @@ public:
PsdAdditionalLayerInfoBlock
globalInfoSection
;
private:
bool
readLayerInfoImpl
(
QIODevice
*
io
);
bool
readImpl
(
QIODevice
*
io
);
void
writeImpl
(
QIODevice
*
io
,
KisNodeSP
rootLayer
);
private:
...
...
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