add bmp-bpp

This commit is contained in:
David Rose 2001-08-02 20:01:58 +00:00
parent 04334687dd
commit f612d6c510
3 changed files with 41 additions and 23 deletions

View File

@ -94,6 +94,11 @@ const int jpeg_quality = config_pnmimagetypes.GetInt("jpeg-quality", 95);
const int jpeg_scale_num = config_pnmimagetypes.GetInt("jpeg-scale-num", 1);
const int jpeg_scale_denom = config_pnmimagetypes.GetInt("jpeg-scale-denom", 1);
// This controls how many bits per pixel are written out for BMP
// files. If this is zero, the default, the number of bits per pixel
// is based on the image.
const int bmp_bpp = config_pnmimagetypes.GetInt("bmp-bpp", 0);
ConfigureFn(config_pnmimagetypes) {
init_libpnmimagetypes();
}

View File

@ -48,6 +48,8 @@ extern const int jpeg_quality;
extern const int jpeg_scale_num;
extern const int jpeg_scale_denom;
extern const int bmp_bpp;
enum IMGHeaderType {
IHT_none,
IHT_short,

View File

@ -48,6 +48,9 @@ extern "C" {
* without express or implied warranty.
*
* $Log$
* Revision 1.5 2001/08/02 20:01:58 drose
* add bmp-bpp
*
* Revision 1.4 2001/05/25 21:30:42 drose
* Update copyright header
*
@ -455,6 +458,9 @@ BMPEncode(
int bpp; /* bits per pixel */
unsigned long nbyte = 0;
bpp = bmp_bpp;
if (bpp == 0) {
bpp = colorstobpp(colors);
/*
@ -479,6 +485,7 @@ BMPEncode(
bpp = 8;
break;
}
}
pm_message("Using %d bits per pixel", bpp);
@ -612,7 +619,11 @@ write_data(xel *array, xelval *) {
/* Figure out the colormap. */
chv = ppm_computecolorhist(pixels, _x_size, _y_size, MAXCOLORS, &colors);
if (chv == (colorhist_vector) 0) {
if (bmp_bpp > 8) {
// Quietly generate a 24-bit image.
BMPEncode24(_file, classv, _x_size, _y_size, pixels);
} else if (chv == (colorhist_vector) 0) {
pnmimage_bmp_cat.debug()
<< "too many colors; generating 24-bit BMP file\n";