mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
mult_sub_image()
This commit is contained in:
parent
779fceafdd
commit
b16e829044
@ -1007,6 +1007,44 @@ add_sub_image(const PNMImage ©, int xto, int yto,
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMImage::mult_sub_image
|
||||
// Access: Published
|
||||
// Description: Behaves like copy_sub_image(), except the copy pixels
|
||||
// are multiplied to the pixels of the destination, after
|
||||
// scaling by the specified pixel_scale. Unlike
|
||||
// blend_sub_image(), the alpha channel is not treated
|
||||
// specially.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PNMImage::
|
||||
mult_sub_image(const PNMImage ©, int xto, int yto,
|
||||
int xfrom, int yfrom, int x_size, int y_size,
|
||||
double pixel_scale) {
|
||||
int xmin, ymin, xmax, ymax;
|
||||
setup_sub_image(copy, xto, yto, xfrom, yfrom, x_size, y_size,
|
||||
xmin, ymin, xmax, ymax);
|
||||
|
||||
int x, y;
|
||||
if (has_alpha() && copy.has_alpha()) {
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
set_alpha(x, y, get_alpha(x, y) * copy.get_alpha(x, y) * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
LRGBColord rgb1 = get_xel(x, y);
|
||||
LRGBColord rgb2 = copy.get_xel(x, y);
|
||||
set_xel(x, y,
|
||||
rgb1[0] * rgb2[0] * pixel_scale,
|
||||
rgb1[1] * rgb2[1] * pixel_scale,
|
||||
rgb1[2] * rgb2[2] * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMImage::darken_sub_image
|
||||
// Access: Published
|
||||
|
@ -204,6 +204,10 @@ PUBLISHED:
|
||||
int xfrom = 0, int yfrom = 0,
|
||||
int x_size = -1, int y_size = -1,
|
||||
double pixel_scale = 1.0);
|
||||
void mult_sub_image(const PNMImage ©, int xto, int yto,
|
||||
int xfrom = 0, int yfrom = 0,
|
||||
int x_size = -1, int y_size = -1,
|
||||
double pixel_scale = 1.0);
|
||||
void darken_sub_image(const PNMImage ©, int xto, int yto,
|
||||
int xfrom = 0, int yfrom = 0,
|
||||
int x_size = -1, int y_size = -1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user