Ejemplo n.º 1
0
        block.append(('Left:', xoff, 0, image.size[0]))
        block.append(('Bottom:', yoff, 0, image.size[1]))
        block.append(('Width:', width, 0, maxx))
        block.append(('Height:', height, 0, maxy))

        while Draw.PupBlock('Create new region', block):
            if not width.val or not height.val or 2**int(
                    log(width.val, 2)) != width.val or 2**int(
                        log(height.val, 2)) != height.val:
                if isinstance(block[-1], tuple): block.extend(['', ''])
                block[-2] = 'Width & Height must'
                block[-1] = 'be powers of 2'
            elif xoff.val + width.val > image.size[0]:
                if isinstance(block[-1], tuple): block.extend(['', ''])
                block[-2] = 'Left + Width must'
                block[-1] = 'be less than %d' % image.size[0]
            elif yoff.val + height.val > image.size[1]:
                if isinstance(block[-1], tuple): block.extend(['', ''])
                block[-2] = 'Bottom + Height must'
                block[-1] = 'be less than %d' % image.size[1]
            else:
                Window.WaitCursor(1)
                if not h.isPanel(image):
                    h = h.New(image)
                h.addRegion(xoff.val, yoff.val, width.val,
                            height.val).makeCurrent()
                Window.WaitCursor(0)
                break
    elif r == 3:
        h.regenerate()
Ejemplo n.º 2
0
        width=Draw.Create(min(maxx,1024))
        height=Draw.Create(min(maxy,1024))
        block=[]
        block.append(('Left:',   xoff,   0, image.size[0]))
        block.append(('Bottom:', yoff,   0, image.size[1]))
        block.append(('Width:',  width,  0, maxx))
        block.append(('Height:', height, 0, maxy))

        while Draw.PupBlock('Create new region', block):
            if not width.val or not height.val or 2**int(log(width.val,2))!=width.val or 2**int(log(height.val,2))!=height.val:
                if isinstance(block[-1], tuple): block.extend(['',''])
                block[-2]='Width & Height must'
                block[-1]='be powers of 2'
            elif xoff.val+width.val>image.size[0]:
                if isinstance(block[-1], tuple): block.extend(['',''])
                block[-2]='Left + Width must'
                block[-1]='be less than %d' % image.size[0]
            elif yoff.val+height.val>image.size[1]:
                if isinstance(block[-1], tuple): block.extend(['',''])
                block[-2]='Bottom + Height must'
                block[-1]='be less than %d' % image.size[1]
            else:
                Window.WaitCursor(1)
                if not h.isPanel(image):
                    h=h.New(image)
                h.addRegion(xoff.val, yoff.val, width.val, height.val).makeCurrent()
                Window.WaitCursor(0)
                break
    elif r==3:
        h.regenerate()