使图像抓屏工作 [英] Getting imagegrabscreen to work

查看:69
本文介绍了使图像抓屏工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试 imagegrabscreen (一个GD函数)与我的Apache/Vista一起使用PC.

I'm trying to get imagegrabscreen (a GD function) to work with my Apache/Vista PC.

我正在使用以下代码:

<?php
$im = imagegrabscreen();

header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

此刻,我得到一个稳定的黑色图像,即我的辅助显示器的大小(1024 * 768).我正在使用Apache 2.2,作为服务运行,已关闭UAC的Vista SP1,PHP 5.2.8和GD(以下信息).我已遵循imagegrabscreen页上有关允许Apache访问桌面的说明.我还重新启动了服务和apache服务器.我在imagegrabwindow上得到了相同的结果.

At the moment I get a solid black image, the size of my secondary monitor (1024*768). I'm using Apache 2.2, runing as a service, Vista SP1 with UAC off, PHP 5.2.8 and GD (information below). I've followed the note on the imagegrabscreen page about allowing Apache access to the desktop. I've also restarted the service and the apache server. I get the same results with imagegrabwindow.

这是一个错误(其他人在运行此方法时遇到麻烦吗?)还是我做错了什么?

Is this a bug (do other people have trouble running this method?) or is there something I'm doing wrong?

Array
(
    [GD Version] => bundled (2.0.34 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [T1Lib Support] => 1
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] => 
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] => 
)

Apache Service登录详细信息:

http://www.kalleload.net/uploads/maogfnfnczfh.png http://www.kalleload.net/uploads/maogfnfnczfh.png

推荐答案

我查看了imagegrabscreen();

I looked at the source to imagegrabscreen();

在这一点上,我相信它会失败,因为我们俩都有多显示器设置.

at this point, I believe it is failing because we both have multi-monitor set-ups.

当前代码调用GetDC(0),根据 http://msdn.microsoft.com/en-us /library/dd144871(VS.85).aspx 应该返回整个屏幕"的设备上下文,但是 要获取特定显示器的DC, 使用EnumDisplayMonitors和CreateDC函数"

The current code calls GetDC(0), which according to http://msdn.microsoft.com/en-us/library/dd144871(VS.85).aspx should return the device context for "the entire screen", but "To get the DC for a specific display monitor, use the EnumDisplayMonitors and CreateDC functions"

我将对此做更多测试,看看是否可以提出适用于多显示器的代码.

I am going to do a bit more testing of this and see if I can come up with multi-monitor-friendly code.

这篇关于使图像抓屏工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆