Browse Source

Documented PCX reader

Thomas Buck 10 years ago
parent
commit
7df7a7fd08
2 changed files with 13 additions and 8 deletions
  1. 8
    1
      include/utils/pcx.h
  2. 5
    7
      src/utils/pcx.cpp

+ 8
- 1
include/utils/pcx.h View File

@@ -11,7 +11,14 @@
11 11
 #ifndef _UTILS_PCX_H_
12 12
 #define _UTILS_PCX_H_
13 13
 
14
-// Returns 0 on success
14
+/*!
15
+ * \brief Load a PCX image file into a RGBA buffer
16
+ * \param filename path of file to read
17
+ * \param image place where allocated buffer of size (width * height * 4) will be allocated
18
+ * \param width place where image width will be stored
19
+ * \param height place where image height will be stored
20
+ * \returns 0 on success
21
+ */
15 22
 int pcxLoad(const char *filename, unsigned char **image, unsigned int *width, unsigned int *height);
16 23
 
17 24
 #endif

+ 5
- 7
src/utils/pcx.cpp View File

@@ -154,9 +154,9 @@ int pcxLoad(const char *filename, unsigned char **image, unsigned int *width, un
154 154
                 } else {
155 155
                     pcxPrint("Unsupported number of planes (%d)", nPlanes);
156 156
                     delete [] buffer;
157
+                    delete [] palette;
157 158
                     delete [] *image;
158
-                    if (palette != NULL)
159
-                        delete [] palette;
159
+                    *image = NULL;
160 160
                     return -10;
161 161
                 }
162 162
             } else {
@@ -171,9 +171,9 @@ int pcxLoad(const char *filename, unsigned char **image, unsigned int *width, un
171 171
                 } else {
172 172
                     pcxPrint("Unsupported number of planes (%d)", nPlanes);
173 173
                     delete [] buffer;
174
+                    delete [] palette;
174 175
                     delete [] *image;
175
-                    if (palette != NULL)
176
-                        delete [] palette;
176
+                    *image = NULL;
177 177
                     return -11;
178 178
                 }
179 179
             }
@@ -186,9 +186,7 @@ int pcxLoad(const char *filename, unsigned char **image, unsigned int *width, un
186 186
     }
187 187
 
188 188
     delete [] buffer;
189
-
190
-    if (palette != NULL)
191
-        delete [] palette;
189
+    delete [] palette;
192 190
 
193 191
     return 0;
194 192
 }

Loading…
Cancel
Save