예제 #1
0
파일: gui.py 프로젝트: rudresh2319/Xpra
def get_CG_imagewrapper(rect=None):
    from xpra.codecs.image_wrapper import ImageWrapper
    assert CG, "cannot capture without Quartz.CoreGraphics"
    if rect is None:
        x = 0
        y = 0
        region = CG.CGRectInfinite
    else:
        x, y, w, h = rect
        region = CG.CGRectMake(x, y, roundup(w, 2), roundup(h, 2))
    image = CG.CGWindowListCreateImage(
        region, CG.kCGWindowListOptionOnScreenOnly, CG.kCGNullWindowID,
        CG.kCGWindowImageNominalResolution)  #CG.kCGWindowImageDefault)
    width = CG.CGImageGetWidth(image)
    height = CG.CGImageGetHeight(image)
    bpc = CG.CGImageGetBitsPerComponent(image)
    bpp = CG.CGImageGetBitsPerPixel(image)
    rowstride = CG.CGImageGetBytesPerRow(image)
    alpha = CG.CGImageGetAlphaInfo(image)
    alpha_str = ALPHA.get(alpha, alpha)
    log(
        "get_CG_imagewrapper(..) image size: %sx%s, bpc=%s, bpp=%s, rowstride=%s, alpha=%s",
        width, height, bpc, bpp, rowstride, alpha_str)
    prov = CG.CGImageGetDataProvider(image)
    argb = CG.CGDataProviderCopyData(prov)
    return ImageWrapper(x, y, width, height, argb, "BGRX", 24, rowstride)
예제 #2
0
 def get_image(self, x, y, width, height, logger=None):
     #region = CG.CGRectMake(0, 0, 100, 100)
     region = CG.CGRectInfinite
     image = CG.CGWindowListCreateImage(region,
                 CG.kCGWindowListOptionOnScreenOnly,
                 CG.kCGNullWindowID,
                 CG.kCGWindowImageDefault)
     width = CG.CGImageGetWidth(image)
     height = CG.CGImageGetHeight(image)
     bpc = CG.CGImageGetBitsPerComponent(image)
     bpp = CG.CGImageGetBitsPerPixel(image)
     rowstride = CG.CGImageGetBytesPerRow(image)
     alpha = CG.CGImageGetAlphaInfo(image)
     alpha_str = ALPHA.get(alpha, alpha)
     if logger:
         logger("OSXRootWindowModel.get_image(..) image size: %sx%s, bpc=%s, bpp=%s, rowstride=%s, alpha=%s", width, height, bpc, bpp, rowstride, alpha_str)
     prov = CG.CGImageGetDataProvider(image)
     argb = CG.CGDataProviderCopyData(prov)
     return ImageWrapper(0, 0, width, height, argb, "BGRX", 24, rowstride)