0

さて、私は自分がプレイするゲームの「署名」を作成しようとしてきました。唯一の落とし穴は、アバターとオンライン/オフラインの画像を挿入したいときに、かなりの数の問題が発生したことです。

私がやろうとしている2つのことは次のとおりです。

  1. habbo_offline.gifが存在するかどうかを確認して、Webページhabplus.com/home/[username]からユーザーステータスを取得します。

    if(strpos(file_get_contents('http://www.habpl.us/home/'.$username.''), 
              'habbo_offline.gif') == true) {
    
  2. ユーザーの画像を取得して、最終的な画像に表示します

    function habSigFigure($username){
            $omgfig = 'http://www.habpl.us/figure.php?user='.$username.'&img_format=gif';
            return $omgfig; 
    
    //place habbo avatar
        $habsigfig = imagecreatefromgif($omgfig);
        imagecopy($img, $habsigfig, 13, 32, 0, 0, imagesx($habsigfig), imagesy($habsigfig));*/
        //place habbo avatar
    

ソースコード全体を含めました。ページにはここからアクセスできます -変数が含まれている別のリンク

あなたが助けることができることを願っています..心からあなたの、中央駅

<?php
include 'config.php';
$username=$_REQUEST["user"];
$grabstat3 = fopen("http://habplus.com/fansitetools/userStats.php?user={$username}&stat=motto", "r"); 
while (!feof($grabstat3)){ $motto1 = fgets($grabstat3);
}   
fclose($grabstat3);
$username=$_REQUEST["user"];
$grabstat2 = fopen("http://habplus.com/fansitetools/userStats.php?user={$username}&stat=pixels", "r"); 
while (!feof($grabstat2)){ $pixels1 = fgets($grabstat2);
}
fclose($grabstat2);
$username=$_REQUEST["user"];
$grabstat1 = fopen("http://habplus.com/fansitetools/userStats.php?user={$username}&stat=credits", "r"); 
while (!feof($grabstat1)){ $credits1 = fgets($grabstat1);
}
fclose($grabstat1);



$pixels = 'Pixels: '.$pixels1.'';
$credits = 'Credits: '.$credits1.'';
$motto = 'Motto: '.$motto1.'';
/* Get custom img */
if(empty($_REQUEST['img'])){
    $img = 'default.png';
}else{ 
    $img =$_REQUEST['img'];
}

/* TEXT COLORS */
$red =$_REQUEST['red'];
$green =$_REQUEST['green'];
$blue =$_REQUEST['blue'];

/* Font size */
$fsize =$_REQUEST['fsize'];


    /*function habSigStatus($username){
        if(strpos(file_get_contents('http://www.habpl.us/home/'.$username.''), 'habbo_offline.gif') == true){
            return false;
        }else{
            return true;


    function habSigFigure($username){
        $omgfig = 'http://www.habpl.us/figure.php?user='.$username.'&img_format=gif';
        return $omgfig;
    }
    }
}*/


/*

    //place habbo avatar
    $habsigfig = imagecreatefromgif($omgfig);
    imagecopy($img, $habsigfig, 13, 32, 0, 0, imagesx($habsigfig), imagesy($habsigfig));*/
    //place habbo avatar



    //habbo status
    if(strpos(file_get_contents('http://www.habpl.us/home/'.$username.''), 'habbo_offline.gif') == true){
        $status_img = imagecreatefromgif('habbo_offline.gif');
    }else{
        $status_img = imagecreatefromgif('habbo_online.gif');
    }
    imagecopy($image, $status_img, 403, 96, 0, 0, 50, 16);
    //habbo status


$image = imagecreatefrompng($img); 
$font_color = imagecolorallocate($image, $red, $green, $blue); 
imagefttext($image, $fsize, 0, 3, 12, $font_color, './volt.ttf', $credits);  /* top left     */
imagefttext($image, $fsize, 0, 403, 12, $font_color, './volt.ttf', $pixels); /* top right    */
imagefttext($image, $fsize, 0, 3, 96, $font_color, './volt.ttf', $motto);    /* bottom left  */
imagefttext($image, $fsize, 0, 403, 96, $font_color, './volt.ttf', $online); /* bottom right */
/* imagefttext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text [, array $extrainfo]) */
header('Content-type: image/png'); 
imagepng($image); 
imagedestroy($image); 


?>
4

2 に答える 2

1

これがあなたの問題です、正直に言うとかなりダーピーです:

imagecopy($image, $status_img, 403, 96, 0, 0, 50, 16);
$image = imagecreatefrompng($img); 

画像にコピーする前に、画像を作成する必要があります。これらの2行を入れ替えれば、問題ないはずです。

于 2012-11-03T23:44:41.903 に答える
1

$ imageは有効なリソースである必要があります。コードでは、$imageはnullです。

  $image = imagecreatefrompng($img); 
  imagecopy($image, $status_img, 403, 96, 0, 0, 50, 16);

あなたが使用することができます

   $image = imagecreatetruecolor(50, 16); //width,height
   imagecopy($image, $status_img, 403, 96, 0, 0, 50, 16);
于 2012-11-04T00:09:39.920 に答える