19 return _num_channels != 0 && (_x_size * _y_size * _num_channels <= (int)_table.size());
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];
63 set_channel(
int x,
int y,
int c, PN_float32 value) {
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];
107 set_point2(
int x,
int y,
const LVecBase2f &point) {
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);
135 set_point2(
int x,
int y,
const LVecBase2d &point) {
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];
167 set_point(
int x,
int y,
const LVecBase3f &point) {
176 set_point(
int x,
int y,
const LVecBase3d &point) {
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];
204 set_point3(
int x,
int y,
const LVecBase3f &point) {
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);
232 set_point3(
int x,
int y,
const LVecBase3d &point) {
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];
266 set_point4(
int x,
int y,
const LVecBase4f &point) {
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;
294 set_point4(
int x,
int y,
const LVecBase4d &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];
316 fill(PN_float32 value) {
317 fill(LPoint4f(value, 0.0f, 0.0f, 0.0f));
324 fill(
const LPoint2f &value) {
325 fill(LPoint4f(value[0], value[1], 0.0f, 0.0f));
332 fill(
const LPoint3f &value) {
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;
460 xform(
const LMatrix4d &transform) {
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);
528 apply_exponent(
float c0_exponent,
float c1_exponent,
float c2_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);