本文整理汇总了Python中java.awt.image.BufferedImage.flush方法的典型用法代码示例。如果您正苦于以下问题:Python BufferedImage.flush方法的具体用法?Python BufferedImage.flush怎么用?Python BufferedImage.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.BufferedImage
的用法示例。
在下文中一共展示了BufferedImage.flush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: outputFiles
# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import flush [as 别名]
def outputFiles(self, filename, attachLogo=False, logoText=None):
rendered = self.getTarget().screenshot()
if attachLogo:
from java.awt.image import BufferedImage
from com.raytheon.uf.common.localization import PathManagerFactory
noaa = 'pyViz/logos/noaalogo2.png'
nws = 'pyViz/logos/nwslogo.png'
pathMgr = PathManagerFactory.getPathManager()
noaa = pathMgr.getStaticFile(noaa)
nws = pathMgr.getStaticFile(nws)
noaaImage = ImageIO.read(noaa)
nwsImage = ImageIO.read(nws)
height = rendered.getHeight() + noaaImage.getHeight()
finalBuf = BufferedImage(rendered.getWidth(), height, BufferedImage.TYPE_INT_ARGB)
graphics = finalBuf.createGraphics()
graphics.drawImage(rendered, 0, 0, None)
graphics.drawImage(noaaImage, 0, rendered.getHeight(), None)
graphics.fillRect(noaaImage.getWidth(), rendered.getHeight(), rendered.getWidth() - noaaImage.getWidth() - nwsImage.getWidth(), rendered.getHeight())
if logoText is not None:
from java.awt import Color
from com.raytheon.uf.viz.core.font import FontAdapter
graphics.setColor(Color.BLACK)
graphics.setFont(FontAdapter.getAWTFont(self.getTarget().getDefaultFont()))
fm = graphics.getFontMetrics()
textBounds = fm.getStringBounds(logoText, graphics)
graphics.drawString(logoText, int((rendered.getWidth() - textBounds.getWidth()) / 2), \
int(rendered.getHeight() + (noaaImage.getHeight() / 2) + textBounds.getHeight() / 2))
graphics.drawImage(nwsImage, finalBuf.getWidth() - nwsImage.getWidth(), rendered.getHeight(), None)
finalBuf.flush()
self.outputImage(finalBuf, filename)
else:
self.outputImage(rendered, filename)
示例2: run
# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import flush [as 别名]
def run(title):
gd = GenericDialog("Record Window")
gd.addMessage("Maximum number of frames to record.\nZero means infinite, interrupt with ESC key.")
gd.addNumericField("Max. frames:", 50, 0)
gd.addNumericField("Milisecond interval:", 300, 0)
gd.addSlider("Start in (seconds):", 0, 20, 5)
frames = []
titles = []
for f in Frame.getFrames():
if f.isEnabled() and f.isVisible():
frames.append(f)
titles.append(f.getTitle())
gd.addChoice("Window:", titles, titles[0])
gd.addCheckbox("To file", False)
gd.showDialog()
if gd.wasCanceled():
return
n_frames = int(gd.getNextNumber())
interval = gd.getNextNumber() / 1000.0 # in seconds
frame = frames[gd.getNextChoiceIndex()]
delay = int(gd.getNextNumber())
tofile = gd.getNextBoolean()
dir = None
if tofile:
dc = DirectoryChooser("Directory to store image frames")
dir = dc.getDirectory()
if dir is None:
return # dialog canceled
snaps = []
borders = None
executors = Executors.newFixedThreadPool(1)
try:
while delay > 0:
IJ.showStatus("Starting in " + str(delay) + "s.")
time.sleep(1) # one second
delay -= 1
IJ.showStatus("Capturing frame borders...")
bounds = frame.getBounds()
robot = Robot()
frame.toFront()
time.sleep(0.5) # half a second
borders = robot.createScreenCapture(bounds)
IJ.showStatus("Recording " + frame.getTitle())
# Set box to the inside borders of the frame
insets = frame.getInsets()
box = bounds.clone()
box.x = insets.left
box.y = insets.top
box.width -= insets.left + insets.right
box.height -= insets.top + insets.bottom
start = System.currentTimeMillis() / 1000.0 # in seconds
last = start
intervals = []
real_interval = 0
i = 1
fus = None
if tofile:
fus = []
# 0 n_frames means continuous acquisition
while 0 == n_frames or (len(snaps) < n_frames and last - start < n_frames * interval):
now = System.currentTimeMillis() / 1000.0 # in seconds
real_interval = now - last
if real_interval >= interval:
last = now
img = snapshot(frame, box)
if tofile:
fus.append(executors.submit(Saver(i, dir, bounds, borders, img, insets))) # will flush img
i += 1
else:
snaps.append(img)
intervals.append(real_interval)
else:
time.sleep(interval / 5)
# interrupt capturing:
if IJ.escapePressed():
IJ.showStatus("Recording user-interrupted")
break
# debug:
# print "insets:", insets
# print "bounds:", bounds
# print "box:", box
# print "snap dimensions:", snaps[0].getWidth(), snaps[0].getHeight()
# Create stack
stack = None
if tofile:
for fu in snaps:
fu.get() # wait on all
stack = VirtualStack(bounds.width, bounds.height, None, dir)
files = File(dir).list(TifFilter())
Arrays.sort(files)
for f in files:
#.........这里部分代码省略.........