Пример #1
0
    def __init__(self, profile_file):
        if not wpproc.RESOLUTION_ARRAY:
            msg = "Cannot parse profile, monitor resolution data is missing."
            show_message_dialog(msg)
            sp_logging.G_LOGGER(msg)
            exit()

        self.file = profile_file
        self.name = "default_profile"
        self.spanmode = "single"  # single / multi
        self.slideshow = True
        self.delay_list = [600]
        self.sortmode = "shuffle"  # shuffle ( random , sorted? )
        self.ppimode = False
        self.ppi_array = wpproc.NUM_DISPLAYS * [100]
        self.ppi_array_relative_density = []
        self.inches = []
        self.manual_offsets = wpproc.NUM_DISPLAYS * [(0, 0)]
        self.manual_offsets_useronly = []
        self.bezels = []
        self.bezel_px_offsets = []
        self.hk_binding = None
        self.paths_array = []

        self.parse_profile(self.file)
        if self.ppimode is True:
            self.compute_relative_densities()
            if self.bezels:
                self.compute_bezel_px_offsets()
        self.file_handler = self.Filehandler(self.paths_array, self.sortmode)
Пример #2
0
    def compute_bezel_px_offsets(self):
        """Computes bezel sizes in pixels based on display PPIs."""
        if self.ppi_array:
            max_ppi = max(self.ppi_array)
        else:
            sp_logging.G_LOGGER("Couldn't compute relative densities: %s, %s",
                                self.name, self.file)
            return 1

        bez_px_offs = [0]  # never offset 1st disp, anchor to it.
        inch_per_mm = 1.0 / 25.4
        for bez_mm in self.bezels:
            bez_px_offs.append(round(float(max_ppi) * inch_per_mm * bez_mm))
        if sp_logging.DEBUG:
            sp_logging.G_LOGGER.info(
                "Bezel px calculation: initial manual offset: %s, \
                and bezel pixels: %s", self.manual_offsets, bez_px_offs)
        if len(bez_px_offs) < wpproc.NUM_DISPLAYS:
            if sp_logging.DEBUG:
                sp_logging.G_LOGGER.info(
                    "Bezel px calculation: Too few bezel mm values given! "
                    "Appending zeros.")
            while (len(bez_px_offs) < wpproc.NUM_DISPLAYS):
                bez_px_offs.append(0)
        elif len(bez_px_offs) > wpproc.NUM_DISPLAYS:
            if sp_logging.DEBUG:
                sp_logging.G_LOGGER.info(
                    "Bezel px calculation: Got more bezel mm values than expected!"
                )
            # Currently ignore list tail if there are too many bezel values
        # Add these horizontal offsets to manual_offsets:
        # Avoid offsetting the leftmost anchored display i==0
        for i in range(1, min(len(bez_px_offs), wpproc.NUM_DISPLAYS)):
            # Add previous offsets to ones further away to the right.
            # Each display needs to be offset by the given bezel relative to
            # the display to its left, which can be shifted relative to
            # the anchor.
            bez_px_offs[i] += bez_px_offs[i - 1]
            self.manual_offsets[i] = (self.manual_offsets[i][0] +
                                      bez_px_offs[i],
                                      self.manual_offsets[i][1])
        self.bezel_px_offsets = bez_px_offs
        if sp_logging.DEBUG:
            sp_logging.G_LOGGER.info(
                "Bezel px calculation: resulting combined manual offset: %s",
                self.manual_offsets)
Пример #3
0
    def compute_relative_densities(self):
        """
        Normalizes the ppi_array list such that the max ppi has the relative value 1.0.

        This means that every other display has an equal relative density or a lesser
        value. The benefit of this normalization is that the resulting corrected
        image sections never have to be scaled up in the end, which would happen with
        relative densities of over 1.0. This presumably yields a slight improvement
        in the resulting image quality in some worst case scenarios.
        """
        if self.ppi_array:
            max_density = max(self.ppi_array)
        else:
            sp_logging.G_LOGGER("Couldn't compute relative densities: %s, %s",
                                self.name, self.file)
            return 1
        for ppi in self.ppi_array:
            self.ppi_array_relative_density.append(
                (1 / max_density) * float(ppi))