mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
add bmp-bpp
This commit is contained in:
parent
04334687dd
commit
f612d6c510
@ -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();
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,29 +458,33 @@ BMPEncode(
|
||||
int bpp; /* bits per pixel */
|
||||
unsigned long nbyte = 0;
|
||||
|
||||
bpp = colorstobpp(colors);
|
||||
bpp = bmp_bpp;
|
||||
|
||||
/*
|
||||
* I have found empirically at least one BMP-displaying program
|
||||
* that can't deal with (for instance) using 3 bits per pixel.
|
||||
* I have seen no programs that can deal with using 3 bits per
|
||||
* pixel. I have seen programs which can deal with 1, 4, and
|
||||
* 8 bits per pixel.
|
||||
*
|
||||
* Based on this, I adjust actual the number of bits per pixel
|
||||
* as follows. If anyone knows better, PLEASE tell me!
|
||||
*/
|
||||
switch(bpp)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
bpp = 4;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
bpp = 8;
|
||||
break;
|
||||
if (bpp == 0) {
|
||||
bpp = colorstobpp(colors);
|
||||
|
||||
/*
|
||||
* I have found empirically at least one BMP-displaying program
|
||||
* that can't deal with (for instance) using 3 bits per pixel.
|
||||
* I have seen no programs that can deal with using 3 bits per
|
||||
* pixel. I have seen programs which can deal with 1, 4, and
|
||||
* 8 bits per pixel.
|
||||
*
|
||||
* Based on this, I adjust actual the number of bits per pixel
|
||||
* as follows. If anyone knows better, PLEASE tell me!
|
||||
*/
|
||||
switch(bpp)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
bpp = 4;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
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";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user