Note that there are some explanatory texts on larger screens.

plurals
  1. POcopying screen contents
    primarykey
    data
    text
    <p>i need a certain area of the screen to be drawn in my app...although my code works fine, its very very slow...takes more than 20 seconds with inferior quality and around 30-40 with best quality... is there a quicker way of doing the same...i want it to b e done within .5 seconds max ...</p> <p>by taking ba screenshot ... i can do it in 5 seconds...but i need it within 0.5 seconds...</p> <p>xlib is not a necessity for me...it'll be great if you could suggest something beter and quicker !</p> <pre><code>class Window: def __init__(self, display, msg): self.display = display self.msg = msg self.screen = self.display.screen() self.window = self.screen.root.create_window( 10, 10, 300, 300, 1, self.screen.root_depth, background_pixel=self.screen.white_pixel, event_mask=X.ExposureMask | X.KeyPressMask, ) self.colormap = self.screen.default_colormap color = self.colormap.alloc_color(0, 0, 65535) xor_color = color.pixel ^ 0xffffff self.gc = self.window.create_gc( line_width = 2, line_style = X.LineSolid, fill_style = X.FillOpaqueStippled, fill_rule = X.WindingRule, cap_style = X.CapButt, join_style = X.JoinMiter, foreground = xor_color, background = self.screen.black_pixel, function = X.GXxor, graphics_exposures = False, subwindow_mode = X.IncludeInferiors, ) self.window.map() def loop(self): while True: e = self.display.next_event() if e.type == X.Expose: i=10 j=10 h=10 k=10 skip=0 while j&lt;121: while i&lt;121: if skip==0: o_x_image=self.screen.root.get_image(i, j, 1, 1, Xlib.X.ZPixmap, 0xffffffff) o_pil_image_rgb = PIL.Image.fromstring("RGB", (1, 1), o_x_image.data, "raw", "BGRX") b = PIL.ImageStat.Stat(o_pil_image_rgb).mean b=map(int, b) r=b[0]*255 g=b[1]*255 b=b[2]*255 color = self.colormap.alloc_color(r,g,b) xor_color = color.pixel ^ 0xffffff self.gc = self.window.create_gc( foreground = xor_color, function = X.GXxor ) skip=1 #print "not skipping" elif skip==1: skip=0 #print "skipped" self.window.point(self.gc,h,k) h+=1 i+=1 j+=1 i=10 k+=1 h=10 elif e.type == X.KeyPress: raise SystemExit </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload