diff -u8 -p -w -B -r netpbm-10.26-orig/converter/ppm/ppmtobmp.c netpbm-10.26/converter/ppm/ppmtobmp.c
--- netpbm-10.26-orig/converter/ppm/ppmtobmp.c	2004-10-22 11:46:07.000000000 -0400
+++ netpbm-10.26/converter/ppm/ppmtobmp.c	2005-01-10 16:52:00.000000000 -0500
@@ -77,17 +77,19 @@ parse_command_line(int argc, char ** arg
         cmdline_p->class = C_WIN;
     else if (os2Spec)
         cmdline_p->class = C_OS2;
     else 
         cmdline_p->class = C_WIN;
 
 
     if (cmdline_p->bppSpec) {
-        if (cmdline_p->bpp != 1 && cmdline_p->bpp != 4 && 
+	if (cmdline_p->bpp == 16) {
+	  fprintf(stderr, "Using 16 bit TrueColor, R5G6B5.\n");
+	} else if (cmdline_p->bpp != 1 && cmdline_p->bpp != 4 &&
             cmdline_p->bpp != 8 && cmdline_p->bpp != 24)
         pm_error("Invalid -bpp value specified: %u.  The only values valid\n"
                  "in the BMP format are 1, 4, 8, and 24 bits per pixel",
                  cmdline_p->bpp);
     }
 
     if (argc - 1 == 0)
         cmdline_p->input_filename = strdup("-");  /* he wants stdin */
@@ -328,16 +330,17 @@ BMPwriterow_palette(FILE *          cons
     }
     return retval;
 }
 
 
 
 static int
 BMPwriterow_truecolor(FILE *        const fp, 
+		      int	    bpp,
                       const pixel * const row, 
                       unsigned long const cols,
                       pixval        const maxval) {
 /*----------------------------------------------------------------------------
   Write a row of a truecolor BMP image to the file 'fp'.  The row is 
   'row', which is 'cols' columns long.
 
   Return the number of bytes written.
@@ -346,16 +349,33 @@ BMPwriterow_truecolor(FILE *        cons
 -----------------------------------------------------------------------------*/
     /* This works only for 24 bits per pixel.  To implement this for the
        general case (which is only hypothetical -- this program doesn't
        write any truecolor images except 24 bit and apparently no one
        else does either), you would move this function into 
        BMPwriterow_palette, which writes arbitrary bit strings.  But
        that would be a lot slower and less robust.
     */
+    // AAD: use R5G6B5 16-bit TrueColor
+    if (bpp == 16) {
+	int nbyte = 0;  /* Number of bytes we have written to file so far */
+	int col;
+	for (col = 0; col < cols; col++) {
+	    // NOTE: for 5:5:5, decrement the 'g' downshift and
+	    // increment the 'r' upshift.
+	    unsigned short b = ((unsigned) PPM_GETB(row[col])) >> 3; // 5 bits
+	    unsigned short g = ((unsigned) PPM_GETG(row[col])) >> 2; // 6 bits
+	    unsigned short r = ((unsigned) PPM_GETR(row[col])) >> 3; // 5 bits
+	    unsigned short val = (b<<0) | (g<<5) | (r<<11);
+	    PutByte(fp, val & 0xff);
+	    PutByte(fp, val >> 8);
+	    nbyte += 2;
+	}
+	return nbyte;
+    }
 
     int nbyte;  /* Number of bytes we have written to file so far */
     int col;  
         
     nbyte = 0;  /* initial value */
     for (col = 0; col < cols; col++) {
         /* We scale to the BMP maxval, which is always 255. */
         PutByte(fp, PPM_GETB(row[col]) * 255 / maxval);
@@ -400,17 +420,17 @@ BMPwritebits(FILE *          const fp, 
     /* The picture is stored bottom line first, top line last */
 
     for (y = cy - 1; y >= 0; --y) {
         int rc;
         if (colortype == PALETTE)
             rc = BMPwriterow_palette(fp, pixels[y], cx, 
                                      cBitCount, cht);
         else 
-            rc = BMPwriterow_truecolor(fp, pixels[y], cx, maxval);
+            rc = BMPwriterow_truecolor(fp, cBitCount, pixels[y], cx, maxval);
 
         if (rc == -1)
             pm_error("couldn't write row %ld", y);
         if (rc % 4 != 0)
             pm_error("row had bad number of bytes: %d", rc);
         nbyte += rc;
     }
 
@@ -499,17 +519,17 @@ analyze_colors(const pixel **    const p
     colorhist_vector chv;
     int i;
 
     pm_message("analyzing colors...");
     chv = ppm_computecolorhist((pixel**)pixels, cols, rows, MAXCOLORS, 
                                colors_p);
     if (chv == NULL) {
         pm_message("More than %d colors found", MAXCOLORS);
-        *minimum_bpp_p = 24;
+        *minimum_bpp_p = 16;// XXX ADONOVAN 24;
         *cht_p = NULL;
     } else {
         unsigned int const minbits = pm_maxvaltobits(*colors_p-1);
 
         pm_message("%d colors found", *colors_p);
 
            implement and other bpp's have in fact been seen to confuse
@@ -551,30 +571,33 @@ choose_colortype_bpp(struct cmdline_info
                      int *               const bits_per_pixel_p) {
 
     if (!cmdline.bppSpec) {
         /* User has no preference as to bits per pixel.  Choose the
            smallest number possible for this image.
         */
         *bits_per_pixel_p = minimum_bpp;
     } else {
-        if (cmdline.bpp < minimum_bpp)
+        if (cmdline.bpp < minimum_bpp) {
+	    fprintf(stderr, "%i %i\n", cmdline.bpp, minimum_bpp);
             pm_error("There are too many colors in the image to "
                      "represent in the\n"
                      "number of bits per pixel you requested: %d.\n"
                      "You may use Ppmquant to reduce the number of "
                      "colors in the image.",
                      cmdline.bpp);
+	}
         else
             *bits_per_pixel_p = cmdline.bpp;
     }
 
     assert(*bits_per_pixel_p == 1 || 
            *bits_per_pixel_p == 4 || 
            *bits_per_pixel_p == 8 || 
+           *bits_per_pixel_p == 16 ||
            *bits_per_pixel_p == 24);
 
     if (*bits_per_pixel_p > 8) 
         *colortype_p = TRUECOLOR;
     else {
         *colortype_p = PALETTE;
     }
 }
