本文整理汇总了Python中Picture.explore方法的典型用法代码示例。如果您正苦于以下问题:Python Picture.explore方法的具体用法?Python Picture.explore怎么用?Python Picture.explore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Picture
的用法示例。
在下文中一共展示了Picture.explore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Test_Picture_BOOK
# 需要导入模块: import Picture [as 别名]
# 或者: from Picture import explore [as 别名]
class Test_Picture_BOOK(unittest.TestCase):
# def setUp(self):
# No code needed here
# Would run at the start of every individual test
def testDistance(self):
'''Test Book - Color distances'''
self.color1 = Color(81, 63, 51)
self.color2 = Color(255, 51, 51)
self.distance = Pixel.colorDistance(self.color1, self.color2)
self.assertEqual(self.distance, 174.41330224498358, 'Distances: %s != %s' % (
self.distance, 174.41330224498358))
def testShow(self):
'''Test Showing - YOU SHOULD NOW SEE A PICTURE WINDOW WITH BARBARA.JPG'''
self.pict = Picture(PICTURES + "barbara.jpg")
self.pict.show()
success = swing.JOptionPane.showConfirmDialog(
None, 'Does a window show barbara.jpg?', 'TestShowPicOP', swing.JOptionPane.YES_NO_OPTION)
self.assertEqual(
success, swing.JOptionPane.YES_OPTION, 'Failed to show barbara.jpg in window.')
def testExplore(self):
'''Test Browsing - YOU SHOULD NOW SEE A PICTURE EXPLORER WINDOW WITH BARBARA.JPG'''
self.pict = Picture(PICTURES + "barbara.jpg")
self.pict.explore()
success = swing.JOptionPane.showConfirmDialog(
None, 'Does the explorer start with barbara.jpg?', 'TestExplorerOP', swing.JOptionPane.YES_NO_OPTION)
self.assertEqual(success, swing.JOptionPane.YES_OPTION,
'Failed to show barbara.jpg in explorer.')
def testDecreaseRed(self):
'''Test BOOK - Decrease red (by 50%)'''
JESConfig.getInstance().setSessionWrapAround(0)
self.pict = Picture(PICTURES + "barbara.jpg")
for p in self.pict.getPixels():
value = p.getRed()
p.setRed(int(value * 0.5))
self.pict.write(OUTPUT + "testdecred.jpg")
self.picttest1 = Picture(OUTPUT + "testdecred.jpg")
self.picttest2 = Picture(PICTURES + "barb-decred.jpg")
self.assertEqual(self.picttest1.getWidth(), self.picttest2.getWidth(
), 'Widths are not the same (%s != %s)' % (self.picttest1.getWidth(), self.picttest2.getWidth()))
self.assertEqual(self.picttest1.getHeight(), self.picttest2.getHeight(
), 'Heights are not the same (%s != %s)' % (self.picttest1.getHeight(), self.picttest2.getHeight()))
for i in range(self.picttest1.getWidth()):
for j in range(self.picttest1.getHeight()):
self.assertEqual(self.picttest1.getBasicPixel(i, j), self.picttest2.getBasicPixel(
i, j), 'Pixels (%s, %s) do not match (%s != %s) - see output file testdecred.jpg' % (i, j, self.picttest1.getBasicPixel(i, j), self.picttest2.getBasicPixel(i, j)))
def testIncreaseRed(self):
'''Test BOOK - Increase red (by 20%)'''
JESConfig.getInstance().setSessionWrapAround(0)
self.pict = Picture(PICTURES + "barbara.jpg")
for p in self.pict.getPixels():
value = p.getRed()
p.setRed(int(value * 1.2))
self.pict.write(OUTPUT + "testincred.jpg")
self.picttest1 = Picture(OUTPUT + "testincred.jpg")
self.picttest2 = Picture(PICTURES + "barb-incred.jpg")
self.assertEqual(self.picttest1.getWidth(), self.picttest2.getWidth(
), 'Widths are not the same (%s != %s)' % (self.picttest1.getWidth(), self.picttest2.getWidth()))
self.assertEqual(self.picttest1.getHeight(), self.picttest2.getHeight(
), 'Heights are not the same (%s != %s)' % (self.picttest1.getHeight(), self.picttest2.getHeight()))
for i in range(self.picttest1.getWidth()):
for j in range(self.picttest1.getHeight()):
self.assertEqual(self.picttest1.getBasicPixel(i, j), self.picttest2.getBasicPixel(
i, j), 'Pixels (%s, %s) do not match (%s != %s) - see output file testincred.jpg' % (i, j, self.picttest1.getBasicPixel(i, j), self.picttest2.getBasicPixel(i, j)))
def testClearBlue(self):
'''Test BOOK - Clear blue'''
self.pict = Picture(PICTURES + "barbara.jpg")
for p in self.pict.getPixels():
p.setBlue(0)
self.pict.write(OUTPUT + "testclrblue.jpg")
self.picttest1 = Picture(OUTPUT + "testclrblue.jpg")
self.picttest2 = Picture(PICTURES + "barb-clrblue.jpg")
self.assertEqual(self.picttest1.getWidth(), self.picttest2.getWidth(
), 'Widths are not the same (%s != %s)' % (self.picttest1.getWidth(), self.picttest2.getWidth()))
self.assertEqual(self.picttest1.getHeight(), self.picttest2.getHeight(
), 'Heights are not the same (%s != %s)' % (self.picttest1.getHeight(), self.picttest2.getHeight()))
for i in range(self.picttest1.getWidth()):
for j in range(self.picttest1.getHeight()):
self.assertEqual(self.picttest1.getBasicPixel(i, j), self.picttest2.getBasicPixel(
i, j), 'Pixels (%s, %s) do not match (%s != %s) - see output file testclrblue.jpg' % (i, j, self.picttest1.getBasicPixel(i, j), self.picttest2.getBasicPixel(i, j)))
def testLighten(self):
'''Test BOOK - Lighten'''
JESConfig.getInstance().setSessionWrapAround(0)
self.pict = Picture(PICTURES + "barbara.jpg")
for p in self.pict.getPixels():
color = p.getColor()
p.setColor(color.brighter())
self.pict.write(OUTPUT + "testlighten.jpg")
self.picttest1 = Picture(OUTPUT + "testlighten.jpg")
self.picttest2 = Picture(PICTURES + "barb-lighten.jpg")
self.assertEqual(self.picttest1.getWidth(), self.picttest2.getWidth(
), 'Widths are not the same (%s != %s)' % (self.picttest1.getWidth(), self.picttest2.getWidth()))
self.assertEqual(self.picttest1.getHeight(), self.picttest2.getHeight(
#.........这里部分代码省略.........