mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
oops, didn't work with preload-textures 0
This commit is contained in:
parent
9e25cda240
commit
3c120dc701
@ -1978,6 +1978,11 @@ do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
|||||||
// image anyway, so we don't even need to make the size right.
|
// image anyway, so we don't even need to make the size right.
|
||||||
x_size = 1;
|
x_size = 1;
|
||||||
y_size = 1;
|
y_size = 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
consider_rescale(image, fullpath.get_basename());
|
||||||
|
x_size = image.get_read_x_size();
|
||||||
|
y_size = image.get_read_y_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
image = PNMImage(x_size, y_size, image.get_num_channels(),
|
image = PNMImage(x_size, y_size, image.get_num_channels(),
|
||||||
@ -2001,6 +2006,15 @@ do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
|||||||
get_expected_mipmap_y_size(n));
|
get_expected_mipmap_y_size(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (image.get_x_size() != image.get_read_x_size() ||
|
||||||
|
image.get_y_size() != image.get_read_y_size()) {
|
||||||
|
gobj_cat.info()
|
||||||
|
<< "Implicitly rescaling " << fullpath.get_basename() << " from "
|
||||||
|
<< image.get_x_size() << " by " << image.get_y_size() << " to "
|
||||||
|
<< image.get_read_x_size() << " by " << image.get_read_y_size()
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (!image.read(fullpath, NULL, false)) {
|
if (!image.read(fullpath, NULL, false)) {
|
||||||
gobj_cat.error()
|
gobj_cat.error()
|
||||||
<< "Texture::read() - couldn't read: " << fullpath << endl;
|
<< "Texture::read() - couldn't read: " << fullpath << endl;
|
||||||
@ -2020,15 +2034,10 @@ do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
|||||||
<< "Texture::read() - couldn't read: " << alpha_fullpath << endl;
|
<< "Texture::read() - couldn't read: " << alpha_fullpath << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int x_size = alpha_image.get_x_size();
|
int x_size = image.get_x_size();
|
||||||
int y_size = alpha_image.get_y_size();
|
int y_size = image.get_y_size();
|
||||||
if (textures_header_only) {
|
|
||||||
x_size = 1;
|
|
||||||
y_size = 1;
|
|
||||||
}
|
|
||||||
alpha_image = PNMImage(x_size, y_size, alpha_image.get_num_channels(),
|
alpha_image = PNMImage(x_size, y_size, alpha_image.get_num_channels(),
|
||||||
alpha_image.get_maxval(),
|
alpha_image.get_maxval(), alpha_image.get_type());
|
||||||
alpha_image.get_type());
|
|
||||||
alpha_image.fill(1.0);
|
alpha_image.fill(1.0);
|
||||||
if (alpha_image.has_alpha()) {
|
if (alpha_image.has_alpha()) {
|
||||||
alpha_image.alpha_fill(1.0);
|
alpha_image.alpha_fill(1.0);
|
||||||
@ -2910,11 +2919,6 @@ consider_rescale(PNMImage &pnmimage, const string &name) {
|
|||||||
|
|
||||||
if (pnmimage.get_x_size() != new_x_size ||
|
if (pnmimage.get_x_size() != new_x_size ||
|
||||||
pnmimage.get_y_size() != new_y_size) {
|
pnmimage.get_y_size() != new_y_size) {
|
||||||
gobj_cat.info()
|
|
||||||
<< "Implicitly rescaling " << name << " from "
|
|
||||||
<< pnmimage.get_x_size() << " by " << pnmimage.get_y_size() << " to "
|
|
||||||
<< new_x_size << " by " << new_y_size << "\n";
|
|
||||||
|
|
||||||
pnmimage.set_read_size(new_x_size, new_y_size);
|
pnmimage.set_read_size(new_x_size, new_y_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,40 @@ clear_read_size() {
|
|||||||
_has_read_size = false;
|
_has_read_size = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMImage::has_read_size
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns true if set_read_size() has been called.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool PNMImage::
|
||||||
|
has_read_size() const {
|
||||||
|
return _has_read_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMImage::get_read_x_size
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the requested x_size of the image if
|
||||||
|
// set_read_size() has been called, or the image x_size
|
||||||
|
// otherwise (if it is known).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE int PNMImage::
|
||||||
|
get_read_x_size() const {
|
||||||
|
return _has_read_size ? _read_x_size : get_x_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMImage::get_read_y_size
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the requested y_size of the image if
|
||||||
|
// set_read_size() has been called, or the image y_size
|
||||||
|
// otherwise (if it is known).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE int PNMImage::
|
||||||
|
get_read_y_size() const {
|
||||||
|
return _has_read_size ? _read_y_size : get_y_size();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PNMImage::is_valid
|
// Function: PNMImage::is_valid
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -93,6 +93,9 @@ PUBLISHED:
|
|||||||
|
|
||||||
INLINE void set_read_size(int x_size, int y_size);
|
INLINE void set_read_size(int x_size, int y_size);
|
||||||
INLINE void clear_read_size();
|
INLINE void clear_read_size();
|
||||||
|
INLINE bool has_read_size() const;
|
||||||
|
INLINE int get_read_x_size() const;
|
||||||
|
INLINE int get_read_y_size() const;
|
||||||
|
|
||||||
bool read(const Filename &filename, PNMFileType *type = NULL,
|
bool read(const Filename &filename, PNMFileType *type = NULL,
|
||||||
bool report_unknown_type = true);
|
bool report_unknown_type = true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user