示例#1
0
    def parse_video_window(self,line):
        fields = line.split()
        # check there is a command field
        if len(fields) < 1:
            return 'error','no type field: '+line,'',False,0,0,0,0
            
        # deal with original which has 1
        if fields[0] == 'original':
            if len(fields)  !=  1:
                return 'error','number of fields for original: '+line,'',False,0,0,0,0    
            return 'normal','',fields[0],False,0,0,0,0


        # deal with warp which has 1 or 5  arguments
        # check basic syntax
        if  fields[0]  != 'warp':
            return 'error','not a valid type: '+fields[0],'',False,0,0,0,0
        if len(fields) not in (1,2,5):
            return 'error','wrong number of coordinates for warp: '+ line,'',False,0,0,0,0

        # deal with window coordinates    
        if len(fields) == 1:
            # fullscreen
            has_window=True
            return 'normal','',fields[0],has_window,self.show_canvas_x1,self.show_canvas_y1,self.show_canvas_x2,self.show_canvas_y2
        else:
            # window is specified
            status,message,x1,y1,x2,y2=parse_rectangle(' '.join(fields[1:]))
            if status == 'error':                                   
                return 'error',message,'',False,0,0,0,0
            else:
                has_window=True
                return 'normal','',fields[0],has_window,self.show_canvas_x1+x1,self.show_canvas_y1+y1,self.show_canvas_x1+x2,self.show_canvas_y1+y2
示例#2
0
    def parse_window(self, line):
        # parses warp _ or xy2 or x+y*w*h

        fields = line.split()
        # check there is a command field
        if len(fields) < 1:
            return 'error', 'no type field in ' + line, '', False, 0, 0, 0, 0

        #deal with warp which has 1 or 5  arguments
        # check basic syntax
        if fields[0] <> 'warp':
            return 'error', 'not a valid type:' + fields[
                0], '', False, 0, 0, 0, 0

        # deal with window coordinatesor not
        if len(fields) == 1:
            # fullscreen
            has_window = False
            return 'normal', '', fields[0], has_window, 0, 0, 0, 0
        else:
            print ' '.join(fields[1:])
            status, message, x1, y1, x2, y2 = parse_rectangle(' '.join(
                fields[1:]))
            if status == 'error':
                return 'error', message, '', False, 0, 0, 0, 0
            else:
                has_window = True
                return 'normal', '', fields[0], has_window, x1, y1, x2, y2
    def parse_window(self,line):
        # parses warp _ or xy2 or x+y*w*h
        
        fields = line.split()
        # check there is a command field
        if len(fields) < 1:
            return 'error','no type field in '+ line,'',False,0,0,0,0
            

        #deal with warp which has 1 or 5  arguments
        # check basic syntax
        if  fields[0] <>'warp':
            return 'error','not a valid type:'+ fields[0],'',False,0,0,0,0

        # deal with window coordinatesor not   
        if len(fields) == 1:
            # fullscreen
            has_window=False
            return 'normal','',fields[0],has_window,0,0,0,0
        else:
            print ' '.join(fields[1:])
            status,message,x1,y1,x2,y2 = parse_rectangle(' '.join(fields[1:]))
            if status=='error':
                return 'error',message,'',False,0,0,0,0
            else:
                has_window=True
                return 'normal','',fields[0],has_window,x1,y1,x2,y2                
示例#4
0
    def parse_video_window(self, line, display_id):
        # model other than 4 video is rotated by hdmi_display_rotate in config.txt
        if self.dm.model_of_pi() == 4:
            rotation = self.dm.real_display_orientation(self.omx_display_id)
        else:
            rotation = 'normal'

        if rotation == 'normal':
            self.omx_rotate = ''
        elif rotation == 'right':
            self.omx_rotate = ' --orientation 90 '
        elif rotation == 'left':
            self.omx_rotate = ' --orientation 270 '
        else:
            #inverted
            self.omx_rotate = ' --orientation 180 '
        fields = line.split()
        # check there is a command field
        if len(fields) < 1:
            return 'error', 'no type field: ' + line, '', False, 0, 0, 0, 0

        # deal with types which have no paramters
        if fields[0] in ('original', 'letterbox', 'fill', 'default',
                         'stretch'):
            if len(fields) != 1:
                return 'error', 'number of fields for original: ' + line, '', False, 0, 0, 0, 0
            if fields[0] in ('letterbox', 'fill', 'stretch'):
                self.omx_aspect_mode = ' --aspect-mode ' + fields[0]
            else:
                self.omx_aspect_mode = ''
            return 'normal', '', fields[0], False, 0, 0, 0, 0

        # deal with warp which has 0 or 1 or 4 parameters (1 is x+y+w*h)
        # check basic syntax
        if fields[0] != 'warp':
            return 'error', 'not a valid type: ' + fields[
                0], '', False, 0, 0, 0, 0
        if len(fields) not in (1, 2, 5):
            return 'error', 'wrong number of coordinates for warp: ' + line, '', False, 0, 0, 0, 0

        # deal with window coordinates, just warp
        if len(fields) == 1:
            has_window = True
            x1 = self.show_canvas_x1
            y1 = self.show_canvas_y1
            x2 = self.show_canvas_x2
            y2 = self.show_canvas_y2
        else:
            # window is specified warp + dimesions etc.
            status, message, x1, y1, x2, y2 = parse_rectangle(' '.join(
                fields[1:]))
            if status == 'error':
                return 'error', message, '', False, 0, 0, 0, 0
            has_window = True
        x1_res, y1_res, x2_res, y2_res = self.transform_for_rotation(
            display_id, rotation, x1, y1, x2, y2)
        return 'normal', '', fields[
            0], has_window, x1_res, y1_res, x2_res, y2_res
 def parse_show_canvas(self,text):
     fields = text.split()
     # blank so show canvas is the whole screen
     if len(fields) < 1:
         return 'normal','',0,0,int(self.canvas['width']),int(self.canvas['height'])
          
     elif len(fields) in (1,4):
         # window is specified
         status,message,x1,y1,x2,y2=parse_rectangle(text)
         if status=='error':
             return 'error',message,0,0,0,0
         else:
             return 'normal','',x1,y1,x2,y2
     else:
         # error
         return 'error','Wrong number of fields in Show canvas: '+ text,0,0,0,0
示例#6
0
    def parse_show_canvas(self, text):
        fields = text.split()
        # blank so show canvas is the whole screen
        if len(fields) < 1:
            return 'normal', '', 0, 0, int(self.canvas['width']), int(
                self.canvas['height'])

        elif len(fields) in (1, 4):
            # window is specified
            status, message, x1, y1, x2, y2 = parse_rectangle(text)
            if status == 'error':
                return 'error', message, 0, 0, 0, 0
            else:
                return 'normal', '', x1, y1, x2, y2
        else:
            # error
            return 'error', 'Wrong number of fields in Show canvas: ' + text, 0, 0, 0, 0
示例#7
0
    def parse_show_canvas(self, text):
        fields = text.split()
        # blank so show canvas is the whole screen
        if len(fields) < 1:
            #get canvas dimensions from the display manager
            width, height = self.dm.canvas_dimensions(self.display_id)
            return 'normal', '', 0, 0, width, height

        elif len(fields) in (1, 4):
            # window is specified
            status, message, x1, y1, x2, y2 = parse_rectangle(text)
            if status == 'error':
                return 'error', message, 0, 0, 0, 0
            else:
                return 'normal', '', x1, y1, x2, y2
        else:
            # error
            return 'error', 'Wrong number of fields in Show canvas: ' + text, 0, 0, 0, 0
示例#8
0
 def parse_menu_window(self,line):
     if line != '':
         fields = line.split()
         if len(fields) not in  (1,2,4):
             return 'error','wrong number of fields',0,0,0,0
         if len(fields) in (1,4):
             if fields[0] == 'fullscreen':
                 return 'normal','',0,0,self.canvas_width - 1, self.canvas_height - 1
             else:
                 status,message,x1,y1,x2,y2 = parse_rectangle (' '.join(fields))
                 if status != 'error':
                     return 'normal','',x1,y1,x2,y2
                 else:
                     return 'error',message,0,0,0,0                   
         if len(fields) == 2:                    
             if fields[0].isdigit() and fields[1].isdigit():
                 return 'normal','',int(fields[0]),int(fields[1]),self.canvas_width, self.canvas_height
             else:
                 return 'error','dimension is not a number',0,0,0,0                    
     else:
         return 'error','line is blank',0,0,0,0
示例#9
0
 def parse_menu_window(self, line):
     if line != '':
         fields = line.split()
         if len(fields) not in (1, 2, 4):
             return 'error', 'wrong number of fields', 0, 0, 0, 0
         if len(fields) in (1, 4):
             if fields[0] == 'fullscreen':
                 return 'normal', '', 0, 0, self.canvas_width - 1, self.canvas_height - 1
             else:
                 status, message, x1, y1, x2, y2 = parse_rectangle(
                     ' '.join(fields))
                 if status != 'error':
                     return 'normal', '', x1, y1, x2, y2
                 else:
                     return 'error', message, 0, 0, 0, 0
         if len(fields) == 2:
             if fields[0].isdigit() and fields[1].isdigit():
                 return 'normal', '', int(fields[0]), int(
                     fields[1]), self.canvas_width, self.canvas_height
             else:
                 return 'error', 'dimension is not a number', 0, 0, 0, 0
     else:
         return 'error', 'line is blank', 0, 0, 0, 0
    def parse_window(self, line):

        fields = line.split()
        # check there is a command field
        if len(fields) < 1:
            return 'error', 'No command field', '', False, 0, 0, 0, 0, ''

        # deal with original whch has 0 or 2 arguments
        image_filter = ''
        if fields[0] == 'original':
            if len(fields) not in (1, 3):
                return 'error', 'Original has wrong number of arguments', '', False, 0, 0, 0, 0, ''
            # deal with window coordinates
            if len(fields) == 3:
                # window is specified
                if not (fields[1].isdigit() and fields[2].isdigit()):
                    return 'error', 'coordinates are not numbers', '', False, 0, 0, 0, 0, ''
                has_window = True
                return 'normal', '', fields[0], has_window, float(
                    fields[1]), float(fields[2]), 0, 0, image_filter
            else:
                # no window
                has_window = False
                return 'normal', '', fields[
                    0], has_window, 0, 0, 0, 0, image_filter

        # deal with remainder which has 1, 2, 5 or  6arguments
        # check basic syntax
        if fields[0] not in ('shrink', 'fit', 'warp'):
            return 'error', 'illegal command' + fields[
                0], '', False, 0, 0, 0, 0, ''
        if len(fields) not in (1, 2, 3, 5, 6):
            return 'error', 'wrong number of fields' + str(
                len(fields)), '', False, 0, 0, 0, 0, ''
        if len(fields) == 6 and fields[5] not in ('NEAREST', 'BILINEAR',
                                                  'BICUBIC', 'ANTIALIAS'):
            return 'error', 'wrong filter or params' + fields[
                5], '', False, 0, 0, 0, 0, ''
        if len(fields) == 2 and (fields[1] not in ('NEAREST', 'BILINEAR',
                                                   'BICUBIC', 'ANTIALIAS')
                                 and '*' not in fields[1]):
            return 'error', 'wrong filter or params' + fields[
                1], '', False, 0, 0, 0, 0, ''
        if len(fields) == 3 and fields[2] not in ('NEAREST', 'BILINEAR',
                                                  'BICUBIC', 'ANTIALIAS'):
            return 'error', 'wrong filter or params' + fields[
                2], '', False, 0, 0, 0, 0, ''

        # deal with no window coordinates and no
        if len(fields) == 1:
            has_window = False
            return 'normal', '', fields[
                0], has_window, 0, 0, 0, 0, 'Image.NEAREST'

        # deal with window coordinates in +* format with optional filter
        if len(fields) in (2, 3) and '*' in fields[1]:
            status, message, x1, y1, x2, y2 = parse_rectangle(fields[1])
            if status == 'error':
                return 'error', message, '', False, 0, 0, 0, 0, ''
            else:
                has_window = True
                if len(fields) == 3:
                    image_filter = 'Image.' + fields[2]
                else:
                    image_filter = 'Image.NEAREST'
                return 'normal', '', fields[
                    0], has_window, x1, y1, x2, y2, image_filter

        if len(fields) in (5, 6):
            # window is specified in x1 y1 x2 y2
            if not (fields[1].isdigit() and fields[2].isdigit()
                    and fields[3].isdigit() and fields[4].isdigit()):
                return 'error', 'coords are not numbers', '', False, 0, 0, 0, 0, ''
            has_window = True
            if len(fields) == 6:
                image_filter = 'Image.' + fields[5]
            else:
                image_filter = 'Image.NEAREST'
            return 'normal', '', fields[0], has_window, float(
                fields[1]), float(fields[2]), float(fields[3]), float(
                    fields[4]), image_filter

        else:
            # no window
            has_window = False
            if len(fields) == 2:
                image_filter = 'Image.' + fields[1]
            else:
                image_filter = 'Image.NEAREST'
            return 'normal', '', fields[
                0], has_window, 0, 0, 0, 0, image_filter