首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >图像质量差

图像质量差
EN

Stack Overflow用户
提问于 2014-07-07 11:30:28
回答 2查看 1.5K关注 0票数 0

我正在尝试从我们的服务器创建一个状态映像,但是“背景图像”的质量看起来非常糟糕。下面是指向php文件的链接,之后是指向我正在使用的图像的链接。

http://www.tijmenschoemaker.nl/steamStatus/monitor.php

因为某种原因,这真的很糟糕。这是真实的图像:http://www.tijmenschoemaker.nl/steamStatus/waspforum.png

代码语言:javascript
复制
<?php

/**
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2010-2013, Sebastian Staudt
 *
 * @author  Sebastian Staudt
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @package steam-condenser
 */

define('STEAM_CONDENSER_PATH', dirname(__FILE__) . '/');
define('STEAM_CONDENSER_VERSION', '1.3.7');

require_once STEAM_CONDENSER_PATH . 'steam/servers/GoldSrcServer.php';
require_once STEAM_CONDENSER_PATH . 'steam/servers/MasterServer.php';
require_once STEAM_CONDENSER_PATH . 'steam/servers/SourceServer.php';
require_once STEAM_CONDENSER_PATH . 'steam/community/SteamId.php';

// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));

// Name the font to be used (note the lack of the .ttf extension)
$font = 'arial.ttf';


try{
    $server = new GoldSrcServer('127.0.0.1', 27016);
    $server->initialize();
    $playersMax = $server->infoHash['maxPlayers'];
    $servername = $server->infoHash['serverName'];
    $playersOnline = $server->infoHash['numberOfPlayers'];
    $serverName = $server->infoHash[ 'serverName'];
    $gameVersion = $server->infoHash['gameVersion'];
    $serverIP = "149.210.163.62";
    $serverPort = $server->infoHash['serverPort'];


$im = imagecreatefrompng('http://www.tijmenschoemaker.nl/steamStatus/waspforum.png')
    or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 0,0,0);
imagestring($im, 1, 5, 12, "Server Name ".$serverName, $text_color);
imagestring($im, 1, 5, 25, "Server Adress ".$serverIP.":".$serverPort, $text_color);
imagestring($im, 1, 5, 35, "Status: Online", $text_color);
imagestring($im, 1, 5, 45, "Players ".$playersOnline."/".$playersMax."",$text_color);
imagestring($im, 1, 5, 55, "Version: ".$gameVersion, $text_color);

header("Content-Type: image/png");
imagepng($im);
imagedestroy($im);

    }
    catch(Exception $e)
    {
$im = @imagecreatefrompng('http://www.tijmenschoemaker.nl/steamStatus/waspforum.png')
    or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "Offline" , $text_color);
header("Content-Type: image/png");
imagepng($im);
imagedestroy($im);

    }




?>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-07-07 11:38:17

可以使用以下代码设置透明背景:

代码语言:javascript
复制
    $trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
    imagesavealpha($im, true);
    imagefill($im, 0, 0, $trans);
票数 1
EN

Stack Overflow用户

发布于 2014-07-07 11:36:11

此函数应接受“压缩”参数。试着换行-

代码语言:javascript
复制
imagepng($im);

至:

代码语言:javascript
复制
 imagepng($im, NULL, 0);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24609568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档