19 return _num_channels != 0 && (_x_size * _y_size * _num_channels <= (int)_table.size());
25 INLINE PN_float32 PfmFile::
45 return _has_point(
this, x, y);
53 nassertr(x >= 0 && x < _x_size &&
54 y >= 0 && y < _y_size &&
55 c >= 0 && c < _num_channels, 0.0f);
56 return _table[(y * _x_size + x) * _num_channels + c];
64 nassertv(x >= 0 && x < _x_size &&
65 y >= 0 && y < _y_size &&
66 c >= 0 && c < _num_channels);
67 _table[(y * _x_size + x) * _num_channels + c] = value;
75 nassertr(x >= 0 && x < _x_size &&
76 y >= 0 && y < _y_size, 0.0);
77 return _table[(y * _x_size + x) * _num_channels];
86 nassertv(x >= 0 && x < _x_size &&
87 y >= 0 && y < _y_size);
88 _table[(y * _x_size + x) * _num_channels] = point;
97 nassertr(x >= 0 && x < _x_size &&
98 y >= 0 && y < _y_size, LPoint2f::zero());
99 return *(LPoint2f *)&_table[(y * _x_size + x) * _num_channels];
109 nassertv(x >= 0 && x < _x_size &&
110 y >= 0 && y < _y_size);
111 switch (_num_channels) {
113 _table[(y * _x_size + x)] = point[0];
117 *(LPoint2f *)&_table[(y * _x_size + x) * _num_channels] = point;
121 (*(LPoint3f *)&_table[(y * _x_size + x) * _num_channels]).set(point[0], point[1], 0.0);
125 (*(LPoint4f *)&_table[(y * _x_size + x) * _num_channels]).set(point[0], point[1], 0.0, 0.0);
145 static LPoint2f dummy_value = LPoint2f::zero();
146 nassertr(x >= 0 && x < _x_size &&
147 y >= 0 && y < _y_size, dummy_value);
150 return *(LPoint2f *)&_table[(y * _x_size + x) * _num_channels];
194 nassertr(x >= 0 && x < _x_size &&
195 y >= 0 && y < _y_size, LPoint3f::zero());
196 return *(LPoint3f *)&_table[(y * _x_size + x) * _num_channels];
206 nassertv(x >= 0 && x < _x_size &&
207 y >= 0 && y < _y_size);
208 switch (_num_channels) {
210 _table[(y * _x_size + x)] = point[0];
214 (*(LPoint2f *)&_table[(y * _x_size + x) * _num_channels]).set(point[0], point[1]);
218 *(LPoint3f *)&_table[(y * _x_size + x) * _num_channels] = point;
222 (*(LPoint4f *)&_table[(y * _x_size + x) * _num_channels]).set(point[0], point[1], 0.0f, 0.0f);
242 static LPoint3f dummy_value = LPoint3f::zero();
243 nassertr(x >= 0 && x < _x_size &&
244 y >= 0 && y < _y_size, dummy_value);
247 return *(LPoint3f *)&_table[(y * _x_size + x) * _num_channels];
256 nassertr(x >= 0 && x < _x_size &&
257 y >= 0 && y < _y_size, LPoint4f::zero());
258 return *(LPoint4f *)&_table[(y * _x_size + x) * _num_channels];
268 nassertv(x >= 0 && x < _x_size &&
269 y >= 0 && y < _y_size);
270 switch (_num_channels) {
272 _table[(y * _x_size + x)] = point[0];
276 (*(LPoint2f *)&_table[(y * _x_size + x) * _num_channels]).set(point[0], point[1]);
280 (*(LPoint3f *)&_table[(y * _x_size + x) * _num_channels]).set(point[0], point[1], point[2]);
284 *(LPoint4f *)&_table[(y * _x_size + x) * _num_channels] = point;
304 static LPoint4f dummy_value = LPoint4f::zero();
305 nassertr(x >= 0 && x < _x_size &&
306 y >= 0 && y < _y_size, dummy_value);
309 return *(LPoint4f *)&_table[(y * _x_size + x) * _num_channels];
317 fill(LPoint4f(value, 0.0f, 0.0f, 0.0f));
325 fill(LPoint4f(value[0], value[1], 0.0f, 0.0f));
333 fill(LPoint4f(value[0], value[1], value[2], 0.0f));
344 int x_begin, x_end, y_begin, y_end;
346 range.set(x_begin, x_end, y_begin, y_end);
358 int x_begin, x_end, y_begin, y_end;
360 range.set(x_begin, x_end, y_begin, y_end);
388 if (chan4 && _num_channels == 4) {
389 _has_no_data_value =
true;
390 _has_no_data_threshold =
false;
391 _no_data_value.set(0.0, 0.0, 0.0, -1.0);
392 _has_point = has_point_chan4;
422 _has_no_data_value =
false;
423 _has_no_data_threshold =
false;
424 _no_data_value = LPoint4f::zero();
425 _has_point = has_point_noop;
434 return _has_no_data_value;
443 return _has_no_data_threshold;
452 nassertr(_has_no_data_value, LPoint4f::zero());
453 return _no_data_value;
461 xform(LCAST(PN_float32, transform));
479 compute_planar_bounds(
const LPoint2d ¢er, PN_float32 point_dist, PN_float32 sample_radius,
bool points_only)
const {
480 return compute_planar_bounds(LCAST(PN_float32, center), point_dist, sample_radius, points_only);
488 INLINE
void PfmFile::
489 gamma_correct(
float from_gamma,
float to_gamma) {
518 apply_exponent(gray_exponent, gray_exponent, gray_exponent, alpha_exponent);
557 INLINE
void PfmFile::
558 setup_sub_image(
const PfmFile ©,
int &xto,
int &yto,
559 int &xfrom,
int &yfrom,
int &x_size,
int &y_size,
560 int &xmin,
int &ymin,
int &xmax,
int &ymax) {
590 x_size = std::min(x_size, copy.
get_x_size() - xfrom);
591 y_size = std::min(y_size, copy.
get_y_size() - yfrom);
void apply_exponent(float gray_exponent)
Adjusts each channel of the image by raising the corresponding component value to the indicated expon...
bool has_point(int x, int y) const
Returns true if there is a valid point at x, y.
void set_point4(int x, int y, const LVecBase4f &point)
Replaces the 4-component point value at the indicated point.
const LPoint3f & get_point(int x, int y) const
Returns the 3-component point value at the indicated point.
void set_no_data_chan4(bool chan4)
Sets the no_data_chan4 flag.
void set_point2(int x, int y, const LVecBase2f &point)
Replaces the 2-component point value at the indicated point.
const LPoint4f & get_point4(int x, int y) const
Returns the 4-component point value at the indicated point.
void set_point3(int x, int y, const LVecBase3f &point)
Replaces the 3-component point value at the indicated point.
const LPoint3f & get_point3(int x, int y) const
Returns the 3-component point value at the indicated point.
const LPoint2f & get_point2(int x, int y) const
Returns the 2-component point value at the indicated point.
void swap_table(vector_float &table)
This is a very low-level function that completely exchanges the PfmFile's internal table of floating-...
LPoint4f & modify_point4(int x, int y)
Returns a modifiable 4-component point value at the indicated point.
PN_float32 get_point1(int x, int y) const
Returns the 1-component point value at the indicated point.
void set_point1(int x, int y, PN_float32 point)
Replaces the 1-component point value at the indicated point.
LPoint3f & modify_point3(int x, int y)
Returns a modifiable 3-component point value at the indicated point.
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
PN_float32 get_channel(int x, int y, int c) const
Returns the cth channel of the point value at the indicated point.
const vector_float & get_table() const
This is a very low-level function that returns a read-only reference to the internal table of floatin...
bool has_no_data_value() const
Returns whether a "no data" value has been established by set_no_data_value().
void fill(PN_float32 value)
Fills the table with all of the same value.
void set_point(int x, int y, const LVecBase3f &point)
Replaces the 3-component point value at the indicated point.
void set_channel(int x, int y, int c, PN_float32 value)
Replaces the cth channel of the point value at the indicated point.
bool has_no_data_threshold() const
Returns whether a "no data" threshold value has been established by set_no_data_threshold().
PT(BoundingHexahedron) PfmFile
Computes the minmax bounding volume of the points in 3-D space, assuming the points represent a mostl...
void xform(const LMatrix4f &transform)
Applies the indicated transform matrix to all points in-place.
LPoint3f & modify_point(int x, int y)
Returns a modifiable 3-component point value at the indicated point.
void set_zero_special(bool zero_special)
Sets the zero_special flag.
void clear_no_data_value()
Removes the special value that means "no data" when it appears in the pfm file.
void set_no_data_threshold(const LPoint4f &no_data_value)
Sets the special threshold value.
LPoint2f & modify_point2(int x, int y)
Returns a modifiable 2-component point value at the indicated point.
bool calc_autocrop(int &x_begin, int &x_end, int &y_begin, int &y_end) const
Computes the minimum range of x and y across the PFM file that include all points.
set_scale
The "scale" is reported in the pfm header and is probably meaningless.
void gamma_correct_alpha(float from_gamma, float to_gamma)
Assuming the image was constructed with a gamma curve of from_gamma in the alpha channel,...
This defines a bounding convex hexahedron.
const LPoint4f & get_no_data_value() const
If has_no_data_value() returns true, this returns the particular "no data" value.
void set_no_data_value(const LPoint4f &no_data_value)
Sets the special value that means "no data" when it appears in the pfm file.