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


Python png.from_array方法代碼示例

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


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

示例1: _generate_time_steps

# 需要導入模塊: import png [as 別名]
# 或者: from png import from_array [as 別名]
def _generate_time_steps(self, trajectory_list):
    """Transforms time step observations to frames of a video."""
    for time_step in gym_env_problem.GymEnvProblem._generate_time_steps(
        self, trajectory_list):
      # Convert the rendered observations from numpy to png format.
      frame_np = np.array(time_step.pop(env_problem.OBSERVATION_FIELD))
      frame_np = frame_np.reshape(
          [self.frame_height, self.frame_width, self.num_channels])
      # TODO(msaffar) Add support for non RGB rendered environments
      frame = png.from_array(frame_np, "RGB", info={"bitdepth": 8})
      frame_buffer = six.BytesIO()
      frame.save(frame_buffer)

      # Put the encoded frame back.
      time_step[_IMAGE_ENCODED_FIELD] = [frame_buffer.getvalue()]
      time_step[_IMAGE_FORMAT_FIELD] = [_FORMAT]
      time_step[_IMAGE_HEIGHT_FIELD] = [self.frame_height]
      time_step[_IMAGE_WIDTH_FIELD] = [self.frame_width]

      # Add the frame number
      time_step[_FRAME_NUMBER_FIELD] = time_step[env_problem.TIMESTEP_FIELD]
      yield time_step 
開發者ID:tensorflow,項目名稱:tensor2tensor,代碼行數:24,代碼來源:rendered_env_problem.py

示例2: main

# 需要導入模塊: import png [as 別名]
# 或者: from png import from_array [as 別名]
def main():
	if len(sys.argv) != 2:
		print "python %s <filename>" % sys.argv[0]
		sys.exit(1)

	try:
		filename = sys.argv[1]
		with open(filename, 'rb') as f:
			saved_state = pickle.load(f)
		
		bitmap = saved_state['bitmap']

	except:
		print "[!] Could not load bitmap"
		sys.exit(1)

	# Get rough code coverage value
	coverage = get_coverage(bitmap)
	print "[*] Code coverage (basic block calls): %.2f" % coverage

	if HAS_PYPNG:		
		# Create PNG image from bitmap values
		p = populate_array(bitmap)
		img = png.from_array(p, 'RGB')
		img.save('status_graph.png')

		print "[*] Created PNG file" 
開發者ID:carlosgprado,項目名稱:BrundleFuzz,代碼行數:29,代碼來源:CreateStatusGraph.py

示例3: main

# 需要導入模塊: import png [as 別名]
# 或者: from png import from_array [as 別名]
def main(wb):
    wb.open()
    regs = wb.regs
    # # #
    print("dumping framebuffer memory...")
    dump = []
    for n in range(DUMP_SIZE//(WORDS_PER_PACKET*4)):
        data = wb.read(SDRAM_BASE + n*WORDS_PER_PACKET*4, WORDS_PER_PACKET)
        for pixel in data:
            dump += extract_rgb(pixel)
    dump = [dump[x:x+LINE_SIZE] for x in range(0, len(dump), LINE_SIZE)]
    print("dumping to png file...")
    png.from_array(dump, "RGB").save("dump.png")
    # # #
    wb.close() 
開發者ID:timvideos,項目名稱:HDMI2USB-litex-firmware,代碼行數:17,代碼來源:test_dump.py


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