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


Python Image.fromstring方法代碼示例

本文整理匯總了Python中PIL.Image.fromstring方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.fromstring方法的具體用法?Python Image.fromstring怎麽用?Python Image.fromstring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PIL.Image的用法示例。


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

示例1: screen_game

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def screen_game(region, save_to=None):
	x, y, width, height = region
	try:
		raw = root.get_image(x, y, width, height, X.ZPixmap, 0xffffffff)
		if hasattr(Image, 'frombytes'):
			# for Pillow
			screenshot = Image.frombytes('RGB', (width, height), raw.data, 'raw', 'BGRX')
		else:
			# for PIL
			screenshot = Image.fromstring('RGB', (width, height), raw.data, 'raw', 'BGRX')
		if save_to is not None:
			screenshot.save(save_to + '.png')
	except:
		filename = save_to + '.png' if save_to is not None else None
		screenshot = pyautogui.screenshot(filename, region)
	return screenshot

# Return pixel color of given x, y coordinates 
開發者ID:AXeL-dev,項目名稱:Dindo-Bot,代碼行數:20,代碼來源:tools.py

示例2: dots

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def dots(self):
        dotsF = numpy.zeros((156,208))
        dotsI = dotsF.astype('uint8')
        k = 10

        for i in range(0,155,1):
            for j in range(k,206,15):
#                print i,j
		    dotsI[i,j] = 255
		    k = k - 4
    	    if k < 0: k = k + 15

	return dotsI
# display it to see if it matches the Seek black dot hex pattern

#	zz = Image.fromstring("I", (208,156), dotsI, "raw", "I;8")
#	toimage(zz).show()
#        print dotsI
##################################################################### 
開發者ID:lod,項目名稱:seek-thermal-documentation,代碼行數:21,代碼來源:Seek_2.0.matlab_export.py

示例3: _test

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def _test():
    import EasyDialogs
    try:
        from PIL import Image
    except ImportError:
        Image = None
    import MacOS
    Qt.EnterMovies()
    path = EasyDialogs.AskFileForOpen(message='Video to convert')
    if not path: sys.exit(0)
    rdr = reader(path)
    if not rdr:
        sys.exit(1)
    dstdir = EasyDialogs.AskFileForSave(message='Name for output folder')
    if not dstdir: sys.exit(0)
    num = 0
    os.mkdir(dstdir)
    videofmt = rdr.GetVideoFormat()
    imgfmt = videofmt.getformat()
    imgw, imgh = videofmt.getsize()
    timestamp, data = rdr.ReadVideo()
    while data:
        fname = 'frame%04.4d.jpg'%num
        num = num+1
        pname = os.path.join(dstdir, fname)
        if not Image: print 'Not',
        print 'Writing %s, size %dx%d, %d bytes'%(fname, imgw, imgh, len(data))
        if Image:
            img = Image.fromstring("RGBA", (imgw, imgh), data)
            img.save(pname, 'JPEG')
            timestamp, data = rdr.ReadVideo()
            MacOS.SetCreatorAndType(pname, 'ogle', 'JPEG')
            if num > 20:
                print 'stopping at 20 frames so your disk does not fill up:-)'
                break
    print 'Total frames:', num 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:38,代碼來源:videoreader.py

示例4: test_fromstring

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def test_fromstring(self):
        self.assertRaises(NotImplementedError, Image.fromstring) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:4,代碼來源:test_image.py

示例5: test_not_implemented

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def test_not_implemented(self):
        self.assertRaises(NotImplementedError, Image.fromstring) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:4,代碼來源:test_image_frombytes.py

示例6: _fingerprint

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def _fingerprint(data, frame, size):
    # python 2
    data_str = "".join(chr(p) for p in data)
    im = Image.fromstring("L", (frame.w, frame.h), data_str, "raw", "L", 0, 1)
    im = im.resize(size, resample=Image.BILINEAR)
    return list(im.getdata()) 
開發者ID:googlefonts,項目名稱:nototools,代碼行數:8,代碼來源:glyph_image_pair.py

示例7: save

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def save(filename, width, height, fmt, pixels, flipped=False):
        image = PILImage.fromstring(fmt.upper(), (width, height), pixels)
        if flipped:
            image = image.transpose(PILImage.FLIP_TOP_BOTTOM)
        image.save(filename)
        return True


# register 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:11,代碼來源:img_pil.py

示例8: preprocess_captcha_part

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def preprocess_captcha_part(file):
    letter_algo = []
    letters = split_captcha(file)
    
    for i in range (len(letters)):

        #letter = Image.fromstring("L", cv.GetSize(letters[i]), letters[i].tostring())
        letter = Image.open(letters[i])
        letter_algo.append(letter.point(lambda i: (i/255.)))

    return letters 
開發者ID:00nanhai,項目名稱:captchacker2,代碼行數:13,代碼來源:break_captcha_utils.py

示例9: take_pic

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def take_pic():
    video = v4l2capture.Video_device("/dev/video0")
    size_x, size_y = video.set_format(1280, 1024)
    video.create_buffers(1)
    video.queue_all_buffers()
    video.start()
    select.select((video,), (), ())
    image_data = video.read()
    video.close()
    image = Image.fromstring("RGB", (size_x, size_y), image_data)
    in_mem_file = io.BytesIO()
    logger.info("In_men_file pre saved size {}".format(len(in_mem_file.getvalue())))
    image.save(in_mem_file, "JPEG")
    logger.info("In_men_filepost saved size {}".format(len(in_mem_file.getvalue())))
    return in_mem_file 
開發者ID:aws-samples,項目名稱:aws-builders-fair-projects,代碼行數:17,代碼來源:pinned.py

示例10: getImage

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def getImage(self):
        buffer, width, height = self.dev.getbuffer()
        if buffer:
            im = Image.fromstring('RGB', (width, height), buffer, 'raw', 'BGR', 0, -1)
            return im 
開發者ID:Jackeriss,項目名稱:Email_My_PC,代碼行數:7,代碼來源:capture.py

示例11: get_image

# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import fromstring [as 別名]
def get_image():
    global im2arrF
    while True:
        # Send read frame request
        send_msg(0x41, 0x53, 0, 0, '\xC0\x7E\x00\x00')

        try:
            ret9  = dev.read(0x81, 0x3F60, 1000)
            ret9 += dev.read(0x81, 0x3F60, 1000)
            ret9 += dev.read(0x81, 0x3F60, 1000)
            ret9 += dev.read(0x81, 0x3F60, 1000)
        except usb.USBError as e:
            sys.exit()

        #  Let's see what type of frame it is
        #  1 is a Normal frame, 3 is a Calibration frame
        #  6 may be a pre-calibration frame
        #  5, 10 other... who knows.
        status = ret9[20]
        #print ('%5d'*21 ) % tuple([ret9[x] for x in range(21)])

        if status == 1:
            #  Convert the raw calibration data to a string array
            calimg = Image.fromstring("I", (208,156), ret9, "raw", "I;16")

            #  Convert the string array to an unsigned numpy int16 array
            im2arr = numpy.asarray(calimg)
            im2arrF = im2arr.astype('uint16')

        if status == 3:
            #  Convert the raw calibration data to a string array
            img = Image.fromstring("I", (208,156), ret9, "raw", "I;16")

            #  Convert the string array to an unsigned numpy int16 array
            im1arr = numpy.asarray(img)
            im1arrF = im1arr.astype('uint16')

            #  Subtract the calibration array from the image array and add an offset
            additionF = (im1arrF-im2arrF)+ 800

            #  convert to an image and display with imagemagick
            disp_img = toimage(additionF)
            #disp_img.show()
            
            return disp_img 
開發者ID:Fry-kun,項目名稱:pyseek,代碼行數:47,代碼來源:seek.py


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