def resize_image(self, image, x_size, y_size): """ Resize an image using the Gaussian blur algorithm. :image: A PNMImage representing your image data. :x_size: The desired X size of the texture. :y_size: The desired Y size of the texture. """ if image.get_x_size() == x_size and image.get_y_size() == y_size: # This image does not need to be resized! return image print(f'Implicit resize from ({image.get_x_size()}, {image.get_y_size()}) to {x_size, y_size}') # Resize the image using Panda3D's gaussian filter algorithm, to fit our x_size and y_size. # WARNING! This blurs the image if too small!!! (Gaussian blur) new_image = PNMImage(x_size, y_size, image.get_num_channels(), image.get_maxval(), image.get_type()) new_image.gaussian_filter_from(1.0, image) return new_image
def resize_image(self, image, x_size, y_size): """ Resize an image using the Gaussian blur algorithm. :image: A PNMImage representing your image data. :x_size: The desired X size of the texture. :y_size: The desired Y size of the texture. """ if image.get_x_size() == x_size and image.get_y_size() == y_size: # This image does not need to be resized! return image # Resize the image using Panda3D's gaussian filter algorithm, to fit our x_size and y_size. # WARNING! This blurs the image if too small!!! (Gaussian blur) new_image = PNMImage(x_size, y_size, image.get_num_channels(), image.get_maxval(), image.get_type()) if self.blur_amount > 0: new_image.gaussian_filter_from(self.blur_amount, image) else: new_image.quick_filter_from(image) return new_image