コード例 #1
0
ファイル: photo_editor.py プロジェクト: idcxb/python
def decrease_brightness_GUI (label):
    '''Implement the decrease_brightness function from img_manip.'''
    
    #Clear all the temp pics in front of the current pic current_pic
    global temp_label
    global current_pic
    temp_label = temp_label[0:current_pic+1]
    #Implement the function decrease_brightness
    label.picture = img_manip.decrease_brightness(label.picture)
    #Keep a copy of the current pic for the functions Undo and Redo
    temp_label.append(label.picture)
    current_pic += 1
    #update the label
    update_label(label)
コード例 #2
0
def test_decrease_brightness():
    '''Test the function decrase_brightness in img_manip.'''
    
    new_pic = create_pic(4, 4)
    new_pic_decrease_bright = img_manip.decrease_brightness(new_pic)
    
    #The average brightness of new_pic_increased_brightness will likely not be 
    #exactly 10 less than that of new_pic because some RGB values may already be
    #0 and cannot decrease, so the function tests for a difference of 10 with
    #an error of 2 rather than for strict difference of 10.
    old_avg_brightness = avg_bright.average_brightness(new_pic)
    new_avg_brightness = avg_bright.average_brightness(new_pic_decrease_bright)
    assert  old_avg_brightness - new_avg_brightness- 10 < 2, \
           "decrease_brightness failed to decrease the picture's average \