Checks if the pixel values are within the valid range.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(format_pnm), | intent(inout) | :: | this | |||
integer(kind=ik), | intent(in), | dimension(:,:) | :: | pixels |
pure subroutine check_pixel_range(this, pixels) class(format_pnm), intent(inout) :: this integer(ik), dimension(:,:), intent(in) :: pixels ! Check if the pixel values are within the valid range select case (this%file_format) case ('pbm') if (maxval(pixels) > 1 .or. minval(pixels) < 0)& error stop 'set_pixels: Invalid pixel values. Valid values are 0 and 1.' case ('pgm') if (maxval(pixels) > this%max_color .or. minval(pixels) < 0)& error stop 'set_pixels: Invalid pixel values. Valid values are between 0 and max_color.' case ('ppm') if (maxval(pixels) > this%max_color .or. minval(pixels) < 0)& error stop 'set_pixels: Invalid pixel values. Valid values are between 0 and max_color.' end select end subroutine check_pixel_range