Esempio n. 1
0
    def recvScreenshot(self, filename, screenshotSize=(None, None)):
        ppmfilename = filename + ".ppm"

        if screenshotSize == (None, None):
            screenshotSize = self._screenshotSize

        width, height, zdata = self._agent.eval_in(
            self._agent_ns, "screenshotZYBGR(%s)" % (repr(screenshotSize), ))

        data = zlib.decompress(zdata)

        fmbtgti.eye4graphics.wbgr2rgb(data, width, height)
        if fmbtpng != None:
            file(filename,
                 "wb").write(fmbtpng.raw2png(data, width, height, 8, "RGB"))
        else:
            ppm_header = "P6\n%d %d\n%d\n" % (width, height, 255)

            f = file(filename + ".ppm", "wb")
            f.write(ppm_header)
            f.write(data)
            f.close()
            _run([fmbt_config.imagemagick_convert, ppmfilename, filename],
                 expectedExitStatus=[0])
            os.remove(ppmfilename)
        return True
Esempio n. 2
0
    def recvScreenshot(self, fmt="FMBTRAWX11"):
        image_p = libX11.XGetImage(self._display, self._root_window, 0, 0,
                                   self._width, self._height, _X_AllPlanes,
                                   _X_ZPixmap)
        image = image_p[0]
        if fmt.upper() == "FMBTRAWX11" or fmbtpng == None:
            # FMBTRAWX11 image format header:
            # FMBTRAWX11 [width] [height] [color depth] [bits per pixel]<linefeed>
            # Binary data
            rawfmbt_header = "FMBTRAWX11 %d %d %d %d\n" % (
                image.width, image.height, self._depth, image.bits_per_pixel)
            rawfmbt_data = ctypes.string_at(
                image.data, image.height * image.bytes_per_line)
            compressed_image = rawfmbt_header + zlib.compress(rawfmbt_data, 3)
        elif fmt.upper() == "PNG" and fmbtpng != None:
            rawdata = ctypes.string_at(image.data,
                                       image.height * image.bytes_per_line)
            compressed_image = fmbtpng.raw2png(rawdata, image.width,
                                               image.height,
                                               image.bits_per_pixel / 4,
                                               "BGR_")
        else:
            compressed_image = None

        libX11.XDestroyImage(image_p)
        return compressed_image
Esempio n. 3
0
    def recvScreenshot(self, filename, screenshotSize=(None, None)):
        ppmfilename = filename + ".ppm"

        if screenshotSize == (None, None):
            screenshotSize = self._screenshotSize

        width, height, zdata = self._agent.eval_in(
            self._agent_ns, "screenshotZYBGR(%s)" % (repr(screenshotSize),))

        data = zlib.decompress(zdata)

        fmbtgti.eye4graphics.wbgr2rgb(data, width, height)
        if fmbtpng != None:
            file(filename, "wb").write(
                fmbtpng.raw2png(data, width, height, 8, "RGB"))
        else:
            ppm_header = "P6\n%d %d\n%d\n" % (width, height, 255)

            f = file(filename + ".ppm", "wb")
            f.write(ppm_header)
            f.write(data)
            f.close()
            _run([fmbt_config.imagemagick_convert, ppmfilename, filename], expectedExitStatus=[0])
            os.remove(ppmfilename)
        return True
Esempio n. 4
0
    def recvScreenshot(self, filename):
        gdi = self.context.gdi.contents
        w = gdi.width
        h = gdi.height

        with self._thread_lock:
            png_data = fmbtpng.raw2png(gdi.primary_buffer, w, h, fmt="RGBA")

        file(filename, "wb").write(png_data)
        return True
Esempio n. 5
0
    def recvScreenshot(self, filename):
        gdi = self.context.gdi.contents
        w = gdi.width
        h = gdi.height

        with self._thread_lock:
            png_data = fmbtpng.raw2png(gdi.primary_buffer, w, h, fmt="RGBA")

        file(filename, "wb").write(png_data)
        return True
Esempio n. 6
0
    def recvScreenshot(self, fmt="FMBTRAWX11"):
        image_p = libX11.XGetImage(self._display, self._root_window,
                                   0, 0, self._width, self._height,
                                   _X_AllPlanes, _X_ZPixmap)
        image = image_p[0]
        if fmt.upper() == "FMBTRAWX11" or fmbtpng == None:
            # FMBTRAWX11 image format header:
            # FMBTRAWX11 [width] [height] [color depth] [bits per pixel]<linefeed>
            # Binary data
            rawfmbt_header = "FMBTRAWX11 %d %d %d %d\n" % (
                image.width, image.height, self._depth, image.bits_per_pixel)
            rawfmbt_data = ctypes.string_at(image.data, image.height * image.bytes_per_line)
            compressed_image = rawfmbt_header + zlib.compress(rawfmbt_data, 3)
        elif fmt.upper() == "PNG" and fmbtpng != None:
            rawdata = ctypes.string_at(image.data, image.height * image.bytes_per_line)
            if image.bits_per_pixel == 16:
                compressed_image = fmbtpng.raw2png(rawdata, image.width, image.height, 5, "RGB565")
            else:
                compressed_image = fmbtpng.raw2png(rawdata, image.width, image.height, image.bits_per_pixel / 4, "BGR_")
        else:
            compressed_image = None

        libX11.XDestroyImage(image_p)
        return compressed_image