mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
add -2
This commit is contained in:
parent
161e2cd5b3
commit
679e73b012
@ -30,6 +30,13 @@ ImageInfo() {
|
|||||||
set_program_description
|
set_program_description
|
||||||
("This program reads the headers of a series of one or more "
|
("This program reads the headers of a series of one or more "
|
||||||
"image files and reports the image sizes to standard output.");
|
"image files and reports the image sizes to standard output.");
|
||||||
|
|
||||||
|
add_option
|
||||||
|
("2", "", 0,
|
||||||
|
"Report only images that have a non-power-of-two size in either "
|
||||||
|
"dimension. Images whose dimensions are both a power of two will "
|
||||||
|
"not be mentioned.",
|
||||||
|
&ImageInfo::dispatch_none, &_report_power_2, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -52,12 +59,16 @@ run() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Successfully read the image header.
|
// Successfully read the image header.
|
||||||
|
if (!_report_power_2 ||
|
||||||
|
!is_power_2(header.get_x_size()) ||
|
||||||
|
!is_power_2(header.get_y_size())) {
|
||||||
nout << filename << ": " << header.get_x_size() << " x "
|
nout << filename << ": " << header.get_x_size() << " x "
|
||||||
<< header.get_y_size() << " x " << header.get_num_channels()
|
<< header.get_y_size() << " x " << header.get_num_channels()
|
||||||
<< " (maxval = " << header.get_maxval() << ")\n";
|
<< " (maxval = " << header.get_maxval() << ")\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: ImageInfo::handle_args
|
// Function: ImageInfo::handle_args
|
||||||
@ -78,6 +89,17 @@ handle_args(ProgramBase::Args &args) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ImageInfo::is_power_2
|
||||||
|
// Access: Private
|
||||||
|
// Description: Returns true if the indicated value is a power of 2,
|
||||||
|
// false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool ImageInfo::
|
||||||
|
is_power_2(int value) const {
|
||||||
|
return (value & (value - 1)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// A call to pystub() to force libpystub.so to be linked in.
|
// A call to pystub() to force libpystub.so to be linked in.
|
||||||
|
@ -38,7 +38,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual bool handle_args(Args &args);
|
virtual bool handle_args(Args &args);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool is_power_2(int value) const;
|
||||||
|
|
||||||
Args _filenames;
|
Args _filenames;
|
||||||
|
bool _report_power_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user