~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/plugins/formats/psd/psd_colormode_block.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "psd_utils.h"
22
22
 
23
23
PSDColorModeBlock::PSDColorModeBlock(PSDColorMode colormode)
24
 
    : m_blocksize(0)
25
 
    , m_colormode(colormode)
 
24
    : blocksize(0)
 
25
    , colormode(colormode)
26
26
{
27
27
}
28
28
 
29
29
bool PSDColorModeBlock::read(QIODevice* io)
30
30
{
31
31
    // get length
32
 
    psdread(io, &m_blocksize);
 
32
    psdread(io, &blocksize);
33
33
 
34
 
    if (m_blocksize == 0) {
35
 
        if (m_colormode == Indexed || m_colormode == DuoTone) {
 
34
    if (blocksize == 0) {
 
35
        if (colormode == Indexed || colormode == DuoTone) {
36
36
            error = "Blocksize of 0 and Indexed or DuoTone colormode";
37
37
            return false;
38
38
        }
40
40
            return true;
41
41
        }
42
42
    }
43
 
    if (m_colormode == Indexed && m_blocksize != 768) {
44
 
        error = QString("Indexed mode, but block size is %1.").arg(m_blocksize);
 
43
    if (colormode == Indexed && blocksize != 768) {
 
44
        error = QString("Indexed mode, but block size is %1.").arg(blocksize);
45
45
        return false;
46
46
    }
47
47
 
48
 
    m_data = io->read(m_blocksize);
49
 
    if ((quint32)m_data.size() != m_blocksize) return false;
 
48
    data = io->read(blocksize);
 
49
    if ((quint32)data.size() != blocksize) return false;
50
50
 
51
 
    if (m_colormode == Indexed) {
 
51
    if (colormode == Indexed) {
52
52
        qFatal("TODO: Compute the colormap");
53
53
        return false;
54
54
    }
71
71
 
72
72
bool PSDColorModeBlock::valid()
73
73
{
74
 
    if (m_blocksize == 0 && (m_colormode == Indexed || m_colormode == DuoTone)) {
 
74
    if (blocksize == 0 && (colormode == Indexed || colormode == DuoTone)) {
75
75
        error = "Blocksize of 0 and Indexed or DuoTone colormode";
76
76
        return false;
77
77
    }
78
 
    if (m_colormode == Indexed && m_blocksize != 768) {
79
 
        error = QString("Indexed mode, but block size is %1.").arg(m_blocksize);
 
78
    if (colormode == Indexed && blocksize != 768) {
 
79
        error = QString("Indexed mode, but block size is %1.").arg(blocksize);
80
80
        return false;
81
81
    }
82
 
    if (m_colormode == DuoTone && m_blocksize == 0) {
 
82
    if (colormode == DuoTone && blocksize == 0) {
83
83
        error == QString("DuoTone mode, but data block is empty");
84
84
        return false;
85
85
    }
86
 
    if ((quint32)m_data.size() != m_blocksize) {
87
 
        error = QString("Data size is %1, but block size is %2").arg(m_data.size()).arg(m_blocksize);
 
86
    if ((quint32)data.size() != blocksize) {
 
87
        error = QString("Data size is %1, but block size is %2").arg(data.size()).arg(blocksize);
88
88
        return false;
89
89
    }
90
90
    return true;