def screenshot(self, display_id: Optional[int] = None, error_ok: bool = True) -> Image.Image:
        """ Take a screenshot and return PIL.Image.Image object
        Args:
            display_id: int, default None, see "dumpsys SurfaceFlinger --display-id" for valid display IDs
            error_ok: bool, default True, if True, return a black image when capture failed
        
        Returns:
            PIL.Image.Image object
        
        Raises:
            AdbError: when capture failed and error_ok is False
        """
        try:
            pil_image = self.__screencap(display_id)
            if pil_image.mode == "RGBA":
                pil_image = pil_image.convert("RGB")
            return pil_image
        except UnidentifiedImageError as e:
            logger.warning("screencap error: %s", e)
            if error_ok:
                wsize = self.window_size()
                return Image.new("RGB", wsize, (0, 0, 0))
            else:
                raise AdbError("screencap error") from e
 Take a screenshot and return PIL.Image.Image object
        Args:
            display_id: int, default None, see "dumpsys SurfaceFlinger --display-id" for valid display IDs
            error_ok: bool, default True, if True, return a black image when capture failed
        
        Returns:
            PIL.Image.Image object
        
        Raises:
            AdbError: when capture failed and error_ok is False
        
adbutils/screenshot.py