让 imagegrabscreen 工作
我正在尝试让 imagegrabscreen
(GD 函数)与我的 Apache 一起使用/Vista 电脑。
我正在使用以下代码:
<?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 得到了相同的结果。
这是一个错误(其他人在运行此方法时遇到问题吗?)还是我做错了什么?
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 服务登录详细信息:
http://www.kalleload.net /uploads/maogfnfnczfh.png http://www.kalleload.net/uploads/maogfnfnczfh.png
I'm trying to get imagegrabscreen
(a GD function) to work with my Apache/Vista PC.
I'm using the following code:
<?php
$im = imagegrabscreen();
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
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 Log On details:
http://www.kalleload.net/uploads/maogfnfnczfh.png http://www.kalleload.net/uploads/maogfnfnczfh.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我查看了 imagegrabscreen(); 的源代码
在这一点上,我认为它失败了,因为我们都有多显示器设置。
当前代码调用 GetDC(0),根据
http://msdn.microsoft.com/en-us /library/dd144871(VS.85).aspx
应该返回“整个屏幕”的设备上下文,但是
“要获取特定显示器的 DC,
使用 EnumDisplayMonitors 和 CreateDC 函数”
我将对此进行更多测试,看看是否可以提出多显示器友好的代码。
I looked at the source to imagegrabscreen();
at this point, I believe it is failing because we both have multi-monitor set-ups.
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.
我认为
imagegrabscreen()
仅适用于 Windows XP,不适用于 Vista。您应该检查这个链接
I think
imagegrabscreen()
only works in Windows XP not Vista.You should check this link