当前位置: 首页>>代码示例>>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;未经允许,请勿转载。