-rw-r--r-- | noncore/graphics/opie-eye/slave/png_slave.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/graphics/opie-eye/slave/png_slave.cpp b/noncore/graphics/opie-eye/slave/png_slave.cpp index 86e1cdc..21555b4 100644 --- a/noncore/graphics/opie-eye/slave/png_slave.cpp +++ b/noncore/graphics/opie-eye/slave/png_slave.cpp | |||
@@ -37,65 +37,66 @@ __attribute__((unused)) | |||
37 | QT_TR_NOOP("Warning"), | 37 | QT_TR_NOOP("Warning"), |
38 | QT_TR_NOOP("Source"), | 38 | QT_TR_NOOP("Source"), |
39 | QT_TR_NOOP("Comment") | 39 | QT_TR_NOOP("Comment") |
40 | }; | 40 | }; |
41 | 41 | ||
42 | // and for the colors | 42 | // and for the colors |
43 | static const char* colors[] = { | 43 | static const char* colors[] = { |
44 | QT_TR_NOOP("Grayscale"), | 44 | QT_TR_NOOP("Grayscale"), |
45 | QT_TR_NOOP("Unknown"), | 45 | QT_TR_NOOP("Unknown"), |
46 | QT_TR_NOOP("RGB"), | 46 | QT_TR_NOOP("RGB"), |
47 | QT_TR_NOOP("Palette"), | 47 | QT_TR_NOOP("Palette"), |
48 | QT_TR_NOOP("Grayscale/Alpha"), | 48 | QT_TR_NOOP("Grayscale/Alpha"), |
49 | QT_TR_NOOP("Unknown"), | 49 | QT_TR_NOOP("Unknown"), |
50 | QT_TR_NOOP("RGB/Alpha") | 50 | QT_TR_NOOP("RGB/Alpha") |
51 | }; | 51 | }; |
52 | 52 | ||
53 | // and compressions | 53 | // and compressions |
54 | static const char* compressions[] = | 54 | static const char* compressions[] = |
55 | { | 55 | { |
56 | QT_TR_NOOP("Deflate") | 56 | QT_TR_NOOP("Deflate") |
57 | }; | 57 | }; |
58 | 58 | ||
59 | // interlaced modes | 59 | // interlaced modes |
60 | static const char* interlaceModes[] = { | 60 | static const char* interlaceModes[] = { |
61 | QT_TR_NOOP("None"), | 61 | QT_TR_NOOP("None"), |
62 | QT_TR_NOOP("Adam7") | 62 | QT_TR_NOOP("Adam7") |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | static void read_comment( const QString& inf, | 66 | static void read_comment( const QString& inf, |
67 | bool readComments, QString& str ) { | 67 | bool readComments, QString& str ) { |
68 | QFile f(inf); | 68 | QFile f(inf); |
69 | f.open(IO_ReadOnly); | 69 | if (!f.exists()) return; |
70 | if (!f.open(IO_ReadOnly)) return; | ||
70 | 71 | ||
71 | if (f.size() < 26) return; | 72 | if (f.size() < 26) return; |
72 | // the technical group will be read from the first 26 bytes. If the file | 73 | // the technical group will be read from the first 26 bytes. If the file |
73 | // is smaller, we can't even read this. | 74 | // is smaller, we can't even read this. |
74 | 75 | ||
75 | uchar *data = new uchar[f.size()+1]; | 76 | uchar *data = new uchar[f.size()+1]; |
76 | f.readBlock(reinterpret_cast<char*>(data), f.size()); | 77 | f.readBlock(reinterpret_cast<char*>(data), f.size()); |
77 | data[f.size()]='\n'; | 78 | data[f.size()]='\n'; |
78 | 79 | ||
79 | // find the start | 80 | // find the start |
80 | if (data[0] == 137 && data[1] == 80 && data[2] == 78 && data[3] == 71 && | 81 | if (data[0] == 137 && data[1] == 80 && data[2] == 78 && data[3] == 71 && |
81 | data[4] == 13 && data[5] == 10 && data[6] == 26 && data[7] == 10 ) | 82 | data[4] == 13 && data[5] == 10 && data[6] == 26 && data[7] == 10 ) |
82 | { | 83 | { |
83 | // ok | 84 | // ok |
84 | // the IHDR chunk should be the first | 85 | // the IHDR chunk should be the first |
85 | if (!strncmp((char*)&data[12], "IHDR", 4)) | 86 | if (!strncmp((char*)&data[12], "IHDR", 4)) |
86 | { | 87 | { |
87 | // we found it, get the dimensions | 88 | // we found it, get the dimensions |
88 | ulong x,y; | 89 | ulong x,y; |
89 | x = (data[16]<<24) + (data[17]<<16) + (data[18]<<8) + data[19]; | 90 | x = (data[16]<<24) + (data[17]<<16) + (data[18]<<8) + data[19]; |
90 | y = (data[20]<<24) + (data[21]<<16) + (data[22]<<8) + data[23]; | 91 | y = (data[20]<<24) + (data[21]<<16) + (data[22]<<8) + data[23]; |
91 | 92 | ||
92 | uint type = data[25]; | 93 | uint type = data[25]; |
93 | uint bpp = data[24]; | 94 | uint bpp = data[24]; |
94 | 95 | ||
95 | // the bpp are only per channel, so we need to multiply the with | 96 | // the bpp are only per channel, so we need to multiply the with |
96 | // the channel count | 97 | // the channel count |
97 | switch (type) | 98 | switch (type) |
98 | { | 99 | { |
99 | case 0: break; // Grayscale | 100 | case 0: break; // Grayscale |
100 | case 2: bpp *= 3; break; // RGB | 101 | case 2: bpp *= 3; break; // RGB |
101 | case 3: break; // palette | 102 | case 3: break; // palette |