本文整理匯總了Python中Picture.getPictureWithHeight方法的典型用法代碼示例。如果您正苦於以下問題:Python Picture.getPictureWithHeight方法的具體用法?Python Picture.getPictureWithHeight怎麽用?Python Picture.getPictureWithHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Picture
的用法示例。
在下文中一共展示了Picture.getPictureWithHeight方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Test_Picture_GIF
# 需要導入模塊: import Picture [as 別名]
# 或者: from Picture import getPictureWithHeight [as 別名]
#.........這裏部分代碼省略.........
def testPictureCopyB(self):
'''Test Picture(copyPicture) constructor (gif) [all]'''
self.pict = Picture(WHITE_GIF)
self.pict2 = Picture(self.pict)
self.assertEqual(self.pict2.getFileName(), WHITE_GIF, 'Filename %s != %s' % (
self.pict2.getFileName(), WHITE_GIF))
self.assertEqual(self.pict2.getExtension(), 'gif',
'File extension %s != gif' % self.pict2.getExtension())
self.assertEqual(self.pict2.getTitle(), WHITE_GIF_TITLE, 'Title %s != %s' % (
self.pict2.getTitle(), WHITE_GIF_TITLE))
self.height = self.pict.getHeight()
self.assertEqual(self.height, 50, 'Height %s != 50' % self.height)
self.width = self.pict.getWidth()
self.assertEqual(self.width, 50, 'Width %s != 50' % self.width)
self.assertNotEqual(self.pict2.getWidth(), 49, 'Width is 49?')
self.assertEqual(self.pict.toString(), 'Picture, filename %s height 50 width 50' % WHITE_GIF,
'toString %s != Picture, filename %s height 50 width 50' % (self.pict.toString(), WHITE_GIF))
for i in range(self.width):
for j in range(self.height):
self.pix1 = self.pict.getPixel(i, j)
self.pix2 = self.pict2.getPixel(i, j)
self.assertEqual(self.pix1.getRed(), self.pix2.getRed(
), 'Pixel (%s,%s): Red = %s != %s' % (i, j, self.pix1.getRed(), self.pix2.getRed()))
self.assertEqual(self.pix1.getBlue(), self.pix2.getBlue(
), 'Pixel (%s,%s): Blue = %s != %s' % (i, j, self.pix1.getBlue(), self.pix2.getBlue()))
self.assertEqual(self.pix1.getGreen(), self.pix2.getGreen(
), 'Pixel (%s,%s): Green = %s != %s' % (i, j, self.pix1.getGreen(), self.pix2.getGreen()))
self.pix1array = self.pict.getPixels()
self.pix2array = self.pict2.getPixels()
self.assertEqual(len(self.pix1array), len(
self.pix2array), 'Error, pixel arrays are different sizes')
for k in range(len(self.pix1array)):
self.pix1 = self.pix1array[k]
self.pix2 = self.pix2array[k]
self.assertEqual(self.pix1.getRed(), self.pix2.getRed(
), 'Pixel (k:%s): Red = %s != %s' % (k, self.pix1.getRed(), self.pix2.getRed()))
self.assertEqual(self.pix1.getBlue(), self.pix2.getBlue(
), 'Pixel (k:%s): Blue = %s != %s' % (k, self.pix1.getBlue(), self.pix2.getBlue()))
self.assertEqual(self.pix1.getGreen(), self.pix2.getGreen(
), 'Pixel (k:%s): Green = %s != %s' % (k, self.pix1.getGreen(), self.pix2.getGreen()))
def testTitlePsB(self):
'''Test picture - changing title from Picture(String) (gif)'''
self.pict = Picture(WHITE_GIF)
self.assertEqual(self.pict.getTitle(), WHITE_GIF_TITLE, 'Title %s != %s' % (
self.pict.getTitle(), WHITE_GIF_TITLE))
self.pict.setTitle("Not white.gif")
self.assertNotEqual(
self.pict.getTitle(), WHITE_GIF_TITLE, 'Title is still %s' % WHITE_GIF)
self.assertEqual(self.pict.getTitle(), 'Not white.gif',
'Title %s != Not white.gif' % self.pict.getTitle())
def testGetPictureWithHeightB1(self):
'''Test Picture.getPictureWithHeight(int) (gif) [1] - smaller'''
self.pict = Picture()
self.loaded = self.pict.load(PICTURES + "addMsg.gif")
self.assertEqual(self.loaded, 1, "Load is broken")
self.heightSm = self.pict.getHeight() - 20
self.pictSm1 = self.pict.getPictureWithHeight(self.heightSm)
self.assertEqual(self.pictSm1.getHeight(), self.heightSm, 'Height %s!=%s' % (
self.pictSm1.getHeight(), self.heightSm))
self.pictSm3 = Picture(PICTURES + "addMsgSm.gif")
self.assertEqual(self.pictSm1.getHeight(), self.pictSm3.getHeight(
), 'Height %s != %s' % (self.pictSm1.getHeight(), self.pictSm3.getHeight()))
self.widthSm = self.pictSm1.getWidth()
self.assertEqual(self.widthSm, self.pictSm1.getWidth(), 'Width %s != %s' % (
self.widthSm, self.pictSm1.getWidth()))
self.assertEqual(self.pictSm1.getWidth(), self.pictSm3.getWidth(
), 'Width %s != %s' % (self.pictSm1.getWidth(), self.pictSm3.getWidth()))
for i in range(self.widthSm):
for j in range(self.heightSm):
self.pix1 = self.pictSm1.getBasicPixel(i, j)
self.pix2 = self.pictSm3.getBasicPixel(i, j)
self.assertEqual(
self.pix1, self.pix2, 'Pixel (%s,%s): %s!=%s' % (i, j, self.pix1, self.pix2))
def testGetPictureWithHeightB2(self):
'''Test Picture.getPictureWithHeight(int) (gif) [2] - larger'''
self.pict = Picture()
self.loaded = self.pict.load(PICTURES + "addMsg.gif")
self.assertEqual(self.loaded, 1, "Load is broken")
self.heightLg = self.pict.getHeight() + 20
self.pictLg1 = self.pict.getPictureWithHeight(self.heightLg)
self.assertEqual(self.pictLg1.getHeight(), self.heightLg, 'Height %s!=%s' % (
self.pictLg1.getHeight(), self.heightLg))
self.pictLg3 = Picture(PICTURES + "addMsgLg.gif")
self.assertEqual(self.pictLg1.getHeight(), self.pictLg3.getHeight(
), 'Height %s != %s' % (self.pictLg1.getHeight(), self.pictLg3.getHeight()))
self.widthLg = self.pictLg1.getWidth()
self.assertEqual(self.widthLg, self.pictLg1.getWidth(), 'Width %s != %s' % (
self.widthLg, self.pictLg1.getWidth()))
self.assertEqual(self.pictLg1.getWidth(), self.pictLg3.getWidth(
), 'Width %s != %s' % (self.pictLg1.getWidth(), self.pictLg3.getWidth()))
for i in range(self.widthLg):
for j in range(self.heightLg):
self.pix1 = self.pictLg1.getBasicPixel(i, j)
self.pix2 = self.pictLg3.getBasicPixel(i, j)
self.assertEqual(
self.pix1, self.pix2, 'Pixel (%s,%s): %s!=%s' % (i, j, self.pix1, self.pix2))
示例2: Test_Picture_BMP
# 需要導入模塊: import Picture [as 別名]
# 或者: from Picture import getPictureWithHeight [as 別名]
#.........這裏部分代碼省略.........
"Pixel (%s,%s): Green = %s != %s" % (i, j, self.pix1.getGreen(), self.pix2.getGreen()),
)
self.pix1array = self.pict.getPixels()
self.pix2array = self.pict2.getPixels()
self.assertEqual(len(self.pix1array), len(self.pix2array), "Error, pixel arrays are different sizes")
for k in range(len(self.pix1array)):
self.pix1 = self.pix1array[k]
self.pix2 = self.pix2array[k]
self.assertEqual(
self.pix1.getRed(),
self.pix2.getRed(),
"Pixel (k:%s): Red = %s != %s" % (k, self.pix1.getRed(), self.pix2.getRed()),
)
self.assertEqual(
self.pix1.getBlue(),
self.pix2.getBlue(),
"Pixel (k:%s): Blue = %s != %s" % (k, self.pix1.getBlue(), self.pix2.getBlue()),
)
self.assertEqual(
self.pix1.getGreen(),
self.pix2.getGreen(),
"Pixel (k:%s): Green = %s != %s" % (k, self.pix1.getGreen(), self.pix2.getGreen()),
)
def testTitlePsB(self):
"""Test picture - changing title from Picture(String) (bmp)"""
self.pict = Picture("white.bmp")
self.assertEqual(self.pict.getTitle(), "white.bmp", "Title %s != white.bmp" % self.pict.getTitle())
self.pict.setTitle("Not white.bmp")
self.assertNotEqual(self.pict.getTitle(), "white.bmp", "Title is still white.bmp")
self.assertEqual(self.pict.getTitle(), "Not white.bmp", "Title %s != Not white.bmp" % self.pict.getTitle())
def testGetPictureWithHeightB1(self):
"""Test Picture.getPictureWithHeight(int) (bmp) [1] - smaller"""
self.pict = Picture()
self.loaded = self.pict.load("addMsg.bmp")
self.assertEqual(self.loaded, 1, "Load is broken")
self.heightSm = self.pict.getHeight() - 20
self.pictSm1 = self.pict.getPictureWithHeight(self.heightSm)
self.assertEqual(
self.pictSm1.getHeight(), self.heightSm, "Height %s!=%s" % (self.pictSm1.getHeight(), self.heightSm)
)
self.pictSm1.write("addMsgSmOut.bmp")
self.pictSm2 = Picture()
self.loaded = self.pictSm2.load("addMsgSmOut.bmp")
self.assertEqual(self.loaded, 1, "Write seems to be broken")
self.pictSm3 = Picture("addMsgSm.bmp")
self.assertEqual(
self.pictSm2.getHeight(),
self.heightSm,
"Either write or load seems to be broken (Height %s != %s)" % (self.pictSm2.getHeight(), self.heightSm),
)
self.assertEqual(
self.pictSm2.getHeight(),
self.pictSm3.getHeight(),
"Height %s != %s" % (self.pictSm2.getHeight(), self.pictSm3.getHeight()),
)
self.widthSm = self.pictSm1.getWidth()
self.assertEqual(
self.widthSm, self.pictSm2.getWidth(), "Width %s != %s" % (self.widthSm, self.pictSm2.getWidth())
)
self.assertEqual(
self.pictSm2.getWidth(),