當前位置: 首頁>>代碼示例>>Python>>正文


Python Picture類代碼示例

本文整理匯總了Python中Picture的典型用法代碼示例。如果您正苦於以下問題:Python Picture類的具體用法?Python Picture怎麽用?Python Picture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Picture類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testPictureCopyB

 def testPictureCopyB(self):
     '''Test Picture(copyPicture) constructor (jpg) [all]'''
     self.pict = Picture("white.jpg")
     self.pict2 = Picture(self.pict)
     self.assertEqual(self.pict2.getFileName(), 'white.jpg', 'Filename %s != white.jpg' % self.pict2.getFileName())
     self.assertEqual(self.pict2.getExtension(), 'jpg', 'File extension %s != jpg' % self.pict2.getExtension())
     self.assertEqual(self.pict2.getTitle(), 'white.jpg', 'Title %s != white.jpg' % self.pict2.getTitle())
     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 white.jpg height 50 width 50', 
         'toString %s != Picture, filename white.jpg height 50 width 50' % self.pict.toString())
     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()))
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:30,代碼來源:Test_Picture_JPG.py

示例2: testGetPictureWithHeightB2

 def testGetPictureWithHeightB2(self):
     '''Test Picture.getPictureWithHeight(int) (bmp) [2] - larger'''
     self.pict = Picture()
     self.loaded = self.pict.load(PICTURES + "addMsg.bmp")
     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.pictLg1.write(OUTPUT + "addMsgLgOut.bmp")
     self.pictLg2 = Picture()
     self.loaded = self.pictLg2.load(OUTPUT + "addMsgLgOut.bmp")
     self.assertEqual(self.loaded, 1, "Write seems to be broken")
     self.pictLg3 = Picture(PICTURES + "addMsgLg.bmp")
     self.assertEqual(self.pictLg2.getHeight(), self.heightLg, 'Either write or load seems to be broken (Height %s != %s)' % (
         self.pictLg2.getHeight(), self.heightLg))
     self.assertEqual(self.pictLg2.getHeight(), self.pictLg3.getHeight(
     ), 'Height %s != %s' % (self.pictLg2.getHeight(), self.pictLg3.getHeight()))
     self.widthLg = self.pictLg1.getWidth()
     self.assertEqual(self.widthLg, self.pictLg2.getWidth(), 'Width %s != %s' % (
         self.widthLg, self.pictLg2.getWidth()))
     self.assertEqual(self.pictLg2.getWidth(), self.pictLg3.getWidth(
     ), 'Width %s != %s' % (self.pictLg2.getWidth(), self.pictLg3.getWidth()))
     for i in range(self.widthLg):
         for j in range(self.heightLg):
             self.pix1 = self.pictLg2.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))
開發者ID:HenryStevens,項目名稱:jes,代碼行數:29,代碼來源:Test_Picture_BMP.py

示例3: testGetPictureWithHeightB1

    def testGetPictureWithHeightB1(self):
        '''Test Picture.getPictureWithHeight(int) (bmp) [1] - smaller'''
        self.pict = Picture()
        self.loaded = self.pict.load(PICTURES + "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(OUTPUT + "addMsgSmOut.bmp")
        self.pictSm2 = Picture()
        self.loaded = self.pictSm2.load(OUTPUT + "addMsgSmOut.bmp")
        self.assertEqual(self.loaded, 1, "Write seems to be broken")

        self.pictSm3 = Picture(PICTURES + "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(), self.pictSm3.getWidth(
        ), 'Width %s != %s' % (self.pictSm2.getWidth(), self.pictSm3.getWidth()))

        for i in range(self.widthSm):
            for j in range(self.heightSm):
                self.pix1 = self.pictSm2.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))
開發者ID:HenryStevens,項目名稱:jes,代碼行數:33,代碼來源:Test_Picture_BMP.py

示例4: testPictureCopyB8

 def testPictureCopyB8(self):
     '''Test Picture(copyPicture) constructor (gif) [8] - pixels'''
     self.pict = Picture(WHITE_GIF)
     self.pict2 = Picture(self.pict)
     self.height = self.pict.getHeight()
     self.width = self.pict.getWidth()
     if(self.height != 50):
         print('Warning: height not correct')
     if(self.width != 50):
         print('Warning: width not correct')
     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()))
開發者ID:HenryStevens,項目名稱:jes,代碼行數:33,代碼來源:Test_Picture_GIF.py

示例5: testPictureCopyB7

 def testPictureCopyB7(self):
     """Test Picture(copyPicture) constructor (bmp) [7] - toString"""
     self.pict = Picture("white.bmp")
     self.pict2 = Picture(self.pict)
     self.assertEqual(
         self.pict.toString(),
         "Picture, filename white.bmp height 50 width 50",
         "toString %s != Picture, filename white.bmp height 50 width 50" % self.pict.toString(),
     )
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:9,代碼來源:Test_Picture_BMP.py

示例6: testPictureCopyB

 def testPictureCopyB(self):
     """Test Picture(copyPicture) constructor (bmp) [all]"""
     self.pict = Picture("white.bmp")
     self.pict2 = Picture(self.pict)
     self.assertEqual(self.pict2.getFileName(), "white.bmp", "Filename %s != white.bmp" % self.pict2.getFileName())
     self.assertEqual(self.pict2.getExtension(), "bmp", "File extension %s != bmp" % self.pict2.getExtension())
     self.assertEqual(self.pict2.getTitle(), "white.bmp", "Title %s != white.bmp" % self.pict2.getTitle())
     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 white.bmp height 50 width 50",
         "toString %s != Picture, filename white.bmp height 50 width 50" % self.pict.toString(),
     )
     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()),
         )
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:57,代碼來源:Test_Picture_BMP.py

示例7: makePicture

def makePicture(filename):
    global mediaFolder
    if not os.path.isabs(filename):
        filename = mediaFolder + filename
    if not os.path.isfile(filename):
        print "makePicture(filename): There is no file at "+filename
        raise ValueError
    picture = Picture()
    picture.loadOrFail(filename)
    return picture
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:10,代碼來源:media.py

示例8: testClearBlue

 def testClearBlue(self):
     '''Test BOOK - Clear blue'''
     self.pict = Picture("barbara.jpg")
     for p in self.pict.getPixels():
         p.setBlue(0)
     self.pict.write("testclrblue.jpg")
     self.picttest1 = Picture("testclrblue.jpg")
     self.picttest2 = Picture("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)))
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:13,代碼來源:Test_Picture_BOOK.py

示例9: testPictureCopyB8

 def testPictureCopyB8(self):
     """Test Picture(copyPicture) constructor (bmp) [8] - pixels"""
     self.pict = Picture("white.bmp")
     self.pict2 = Picture(self.pict)
     self.height = self.pict.getHeight()
     self.width = self.pict.getWidth()
     if self.height != 50:
         print("Warning: height not correct")
     if self.width != 50:
         print("Warning: width not correct")
     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()),
         )
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:50,代碼來源:Test_Picture_BMP.py

示例10: testLighten

    def testLighten(self):
        '''Test BOOK - Lighten'''
	JESConfig.getInstance().setSessionWrapAround(0)
        self.pict = Picture("barbara.jpg")
        for p in self.pict.getPixels():
            color = p.getColor()
            p.setColor(color.brighter())
        self.pict.write("testlighten.jpg")
        self.picttest1 = Picture("testlighten.jpg")
        self.picttest2 = Picture("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(),'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 testlighten.jpg'%(i,j,self.picttest1.getBasicPixel(i,j),self.picttest2.getBasicPixel(i,j)))
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:15,代碼來源:Test_Picture_BOOK.py

示例11: testIncreaseRed

    def testIncreaseRed(self):
        '''Test BOOK - Increase red (by 20%)'''
	JESConfig.getInstance().setSessionWrapAround(0)
        self.pict = Picture("barbara.jpg")
        for p in self.pict.getPixels():
            value = p.getRed()
            p.setRed(int(value * 1.2))
        self.pict.write("testincred.jpg")
        self.picttest1 = Picture("testincred.jpg")
        self.picttest2 = Picture("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)))
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:15,代碼來源:Test_Picture_BOOK.py

示例12: testTitlePsB

 def testTitlePsB(self):
     '''Test picture - changing title from Picture(String) (jpg)'''
     self.pict = Picture("white.jpg")
     self.assertEqual(self.pict.getTitle(), 'white.jpg','Title %s != white.jpg' % self.pict.getTitle())
     self.pict.setTitle("Not white.jpg")
     self.assertNotEqual(self.pict.getTitle(), 'white.jpg', 'Title is still white.jpg')
     self.assertEqual(self.pict.getTitle(), 'Not white.jpg', 'Title %s != Not white.jpg' % self.pict.getTitle())
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:7,代碼來源:Test_Picture_JPG.py

示例13: testPictureStrB

 def testPictureStrB(self):
     '''Test Picture(String) constructor (jpg) [all]'''
     self.pict = Picture("white.jpg")
     self.assertEqual(self.pict.getFileName(), 'white.jpg', 'Filename %s != white.jpg' % self.pict.getFileName())
     self.assertEqual(self.pict.getExtension(), 'jpg', 'File extension %s != jpg' % self.pict.getExtension())
     self.assertEqual(self.pict.getTitle(), 'white.jpg', 'Title %s != white.jpg' % self.pict.getTitle())
     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.width, 49, 'Width is 49?')
     self.assertEqual(self.pict.toString(), 'Picture, filename white.jpg height 50 width 50', 
                 'toString %s != Picture, filename white.jpg height 50 width 50' % self.pict.toString())
     for i in range(self.width):
         for j in range(self.height):
             self.pix = self.pict.getPixel(i,j)
             self.assertEqual(self.pix.getRed(), 255, 'Pixel (%s,%s): Red = %s != 255' % (i,j,self.pix.getRed()))
             self.assertEqual(self.pix.getBlue(), 255, 'Pixel (%s,%s): Blue = %s != 255' % (i,j,self.pix.getRed()))
             self.assertEqual(self.pix.getGreen(), 255, 'Pixel (%s,%s): Green = %s != 255' % (i,j,self.pix.getRed()))
     self.pixarray = self.pict.getPixels()
     self.len = len(self.pixarray)
     self.assertEqual(self.len, 50*50, 'Pixel array size %s != %s' % (self.len,50*50))
     for k in range(self.len):
         self.pix = self.pixarray[k]
         self.assertEqual(self.pix.getRed(), 255, 'Pixel (k:%s): Red = %s != 255' % (k,self.pix.getRed()))
         self.assertEqual(self.pix.getBlue(), 255, 'Pixel (k:%s): Blue = %s != 255' % (k,self.pix.getBlue()))
         self.assertEqual(self.pix.getGreen(), 255, 'Pixel (k:%s): Green = %s != 255' % (k,self.pix.getGreen()))
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:27,代碼來源:Test_Picture_JPG.py

示例14: testTitlePII

 def testTitlePII(self):
     '''Test picture - changing title from Picture(int,int)'''
     self.pict = Picture(20,20)
     self.assertEqual('%s'%self.pict.getTitle(),'None','Title %s != None' % self.pict.getTitle())
     self.pict.setTitle("Blank object")
     self.assertNotEqual('%s'%self.pict.getTitle(), 'None', 'Title did not change')
     self.assertEqual(self.pict.getTitle(), 'Blank object', 'Title %s != Blank object' % self.pict.getTitle())
開發者ID:Alli1223,項目名稱:Comp120-moodboard,代碼行數:7,代碼來源:Test_Picture_NEW.py

示例15: testPictureStrB8

 def testPictureStrB8(self):
     '''Test Picture(String) constructor (gif) [8] - pixels'''
     self.pict = Picture(WHITE_GIF)
     self.height = self.pict.getHeight()
     self.width = self.pict.getWidth()
     if(self.height != 50):
         print('Warning: height not correct')
     if(self.width != 50):
         print('Warning: width not correct')
     for i in range(self.width):
         for j in range(self.height):
             self.pix = self.pict.getPixel(i, j)
             self.assertEqual(self.pix.getRed(), 255, 'Pixel (%s,%s): Red = %s != 255' % (
                 i, j, self.pix.getRed()))
             self.assertEqual(self.pix.getBlue(), 255, 'Pixel (%s,%s): Blue = %s != 255' % (
                 i, j, self.pix.getRed()))
             self.assertEqual(self.pix.getGreen(), 255, 'Pixel (%s,%s): Green = %s != 255' % (
                 i, j, self.pix.getRed()))
     self.pixarray = self.pict.getPixels()
     self.len = len(self.pixarray)
     self.assertEqual(
         self.len, 50 * 50, 'Pixel array size %s != %s' % (self.len, 50 * 50))
     for k in range(self.len):
         self.pix = self.pixarray[k]
         self.assertEqual(
             self.pix.getRed(), 255, 'Pixel (k:%s): Red = %s != 255' % (k, self.pix.getRed()))
         self.assertEqual(self.pix.getBlue(), 255, 'Pixel (k:%s): Blue = %s != 255' % (
             k, self.pix.getBlue()))
         self.assertEqual(self.pix.getGreen(), 255, 'Pixel (k:%s): Green = %s != 255' % (
             k, self.pix.getGreen()))
開發者ID:HenryStevens,項目名稱:jes,代碼行數:30,代碼來源:Test_Picture_GIF.py


注:本文中的Picture類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。