PHPを使いタイトルにあるようにスキンをPNG化しようとしてます
そしたら【Warning: imagepng() expects parameter 1 to be resource, string given in D:\省略\main.php on line 37
】
と出てきてしまい先に進めませんエラーの原因は何でしょうか?
PHP
1 function onJoin(PlayerJoinEvent $Event){ 2 $Player=$Event->getPlayer(); 3 $this->save($Player->getSkinData(), "./test.png"); 4} 5function save($skin, $file_name){ 6 $width=64; 7 $height= (strlen($skin)==64*64*4 ? 64 : 32); 8 $this->getLogger()->info(strlen($skin)); 9 $image = \imagecreatetruecolor($width, $height); 10 $rgba=[]; 11 for($i=0;$i<strlen($skin);){ 12 $r=ord($skin{$i++}); 13 $g=ord($skin{$i++}); 14 $b=ord($skin{$i++}); 15 $a=ord($skin{$i++}); 16 $rgba[]=[$r,$g,$b,$a]; 17 } 18 for ($y=0;$y<$height;$y++) { 19 for ($x=0;$x<$width;$x++) { 20 $current_rgba=array_shift($rgba); 21 $color=\imagecolorallocatealpha($image, $current_rgba[0],$current_rgba[1],$current_rgba[2],$current_rgba[3]); 22 \imagesetpixel($image,$x,$y,$color); 23 } 24 } 25 エラー箇所→\imagepng($skin, $file_name); 26} 27}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/08 11:04
2017/02/08 11:52