about summary refs log tree commit diff
path: root/converter/bmp.h
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-11-10 03:13:53 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-11-10 03:13:53 +0000
commita537bc3690f5b68e1f65318887787a7ed5421729 (patch)
treeaa40a219013c5d33c33a5604da831cdcb9bdf150 /converter/bmp.h
parentae6f6cd08761a3f2c2b307ae7337da415bcd9f48 (diff)
downloadnetpbm-mirror-a537bc3690f5b68e1f65318887787a7ed5421729.tar.gz
netpbm-mirror-a537bc3690f5b68e1f65318887787a7ed5421729.tar.xz
netpbm-mirror-a537bc3690f5b68e1f65318887787a7ed5421729.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1365 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/bmp.h')
-rw-r--r--converter/bmp.h50
1 files changed, 34 insertions, 16 deletions
diff --git a/converter/bmp.h b/converter/bmp.h
index 8b2aa302..80e93fba 100644
--- a/converter/bmp.h
+++ b/converter/bmp.h
@@ -88,12 +88,30 @@ enum bmpClass {C_WIN=1, C_OS2=2};
 static char const er_internal[] = "%s: internal error!";
 
 /* Values of the "compression" field of the BMP info header */
-#define COMP_RGB       0
-#define COMP_RLE8      1
-#define COMP_RLE4      2
-#define COMP_BITFIELDS 3
-#define COMP_JPEG      4
-#define COMP_PNG       5
+typedef enum BMPCompType {
+    BMPCOMP_RGB       = 0,
+    BMPCOMP_RLE8      = 1,
+    BMPCOMP_RLE4      = 2,
+    BMPCOMP_BITFIELDS = 3,
+    BMPCOMP_JPEG      = 4,
+    BMPCOMP_PNG       = 5
+} BMPCompType;
+
+static __inline__ const char *
+BMPCompTypeName(BMPCompType const compression) {
+
+    switch (compression) {
+    case BMPCOMP_RGB:       return "none (RBG)";
+    case BMPCOMP_RLE4:      return "4 bit run-length coding";
+    case BMPCOMP_RLE8:      return "8 bit run-length coding";
+    case BMPCOMP_BITFIELDS: return "none (bitfields)";
+    case BMPCOMP_JPEG:      return "JPEG (not supported)";
+    case BMPCOMP_PNG:       return "PNG (not supported)";   
+    }
+    return 0;  /* Default compiler warning */
+}
+
+
 
 static __inline__ unsigned int
 BMPlenfileheader(enum bmpClass const class) {
@@ -214,21 +232,21 @@ BMPoffbits(enum bmpClass const class,
 
 
 static __inline__ unsigned int
-BMPlenfileGen(enum bmpClass     const class,
-              unsigned int      const bitcount, 
-              unsigned int      const cmapsize,
-              unsigned int      const x,
-              unsigned int      const y,
-              unsigned int      const imageSize,
-              unsigned long int const compression) {
+BMPlenfileGen(enum bmpClass const class,
+              unsigned int  const bitcount, 
+              unsigned int  const cmapsize,
+              unsigned int  const x,
+              unsigned int  const y,
+              unsigned int  const imageSize,
+              BMPCompType   const compression) {
 /*----------------------------------------------------------------------------
   Return the size of the BMP file in bytes.
 -----------------------------------------------------------------------------*/
     unsigned int retval;
 
     switch (compression) {
-    case COMP_RGB:
-    case COMP_BITFIELDS:
+    case BMPCOMP_RGB:
+    case BMPCOMP_BITFIELDS:
         retval =
             BMPoffbits(class, bitcount, cmapsize) +
             BMPlenbits(class, bitcount, x, y);
@@ -250,7 +268,7 @@ BMPlenfile(enum bmpClass const class,
 /*----------------------------------------------------------------------------
   return the size of the BMP file in bytes; no compression
 -----------------------------------------------------------------------------*/
-    return BMPlenfileGen(class, bitcount, cmapsize, x, y, 0, COMP_RGB);
+    return BMPlenfileGen(class, bitcount, cmapsize, x, y, 0, BMPCOMP_RGB);
 }
 
 #endif