Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 42e07af

Browse files
committed
Vrec.py: sv now raises sv.error instead of RuntimeError.
VFile.py: support for showing partial frames.
1 parent 66122d2 commit 42e07af

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

Demo/sgi/video/VFile.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def init(self):
273273
# setinfo() must reset some internal flags
274274

275275
def setinfo(self, values):
276-
VideoParams.setinfo(values)
276+
VideoParams.setinfo(self, values)
277277
self.colormapinited = 0
278278
self.skipchrom = 0
279279
self.color0 = None
@@ -282,33 +282,41 @@ def setinfo(self, values):
282282
# Show one frame, initializing the window if necessary
283283

284284
def showframe(self, data, chromdata):
285+
self.showpartframe(data, chromdata, \
286+
(0,0,self.width,self.height))
287+
288+
def showpartframe(self, data, chromdata, (x,y,w,h)):
285289
if not self.colormapinited:
286290
self.initcolormap()
287291
if self.fixcolor0:
288292
gl.mapcolor(self.color0)
289293
self.fixcolor0 = 0
290-
w, h, pf = self.width, self.height, self.packfactor
294+
pf = self.packfactor
291295
factor = self.magnify
292296
if pf: factor = factor * pf
293297
if chromdata and not self.skipchrom:
294298
cp = self.chrompack
299+
cx = int(x*factor*cp) + self.xorigin
300+
cy = int(y*factor*cp) + self.yorigin
295301
cw = (w+cp-1)/cp
296302
ch = (h+cp-1)/cp
297303
gl.rectzoom(factor*cp, factor*cp)
298304
gl.pixmode(GL.PM_SIZE, 16)
299305
gl.writemask(self.mask - ((1 << self.c0bits) - 1))
300-
gl.lrectwrite(self.xorigin, self.yorigin, \
301-
self.xorigin + cw - 1, self.yorigin + ch - 1, \
302-
chromdata)
306+
gl.lrectwrite(cx, cy, cx + cw - 1, cy + ch - 1, \
307+
chromdata)
303308
#
304309
if pf:
305310
gl.writemask((1 << self.c0bits) - 1)
306311
gl.pixmode(GL.PM_SIZE, 8)
307312
w = w/pf
308313
h = h/pf
314+
x = x/pf
315+
y = y/pf
309316
gl.rectzoom(factor, factor)
310-
gl.lrectwrite(self.xorigin, self.yorigin, \
311-
self.xorigin + w - 1, self.yorigin + h - 1, data)
317+
x = int(x*factor)+self.xorigin
318+
y = int(y*factor)+self.yorigin
319+
gl.lrectwrite(x, y, x + w - 1, y + h - 1, data)
312320
gl.gflush()
313321

314322
# Initialize the window: set RGB or colormap mode as required,

Demo/sgi/video/Vrec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def record(v, info, filename, audiofilename):
183183
while not gl.qtest():
184184
try:
185185
cd, id = v.GetCaptureData()
186-
except RuntimeError:
186+
except sv.error:
187187
time.millisleep(10) # XXX is this necessary?
188188
continue
189189
id = id + 2*rate

0 commit comments

Comments
 (0)