php 막대그래프 프로그래밍(png 파일 문제?)

kjw7945의 이미지

php 그래프 프로그래밍을 해보았습니다. 여기서는 그래프를 png파일로
그리는 건데요. 그러나 모질라, 인터넷 익스플로러 브라우저에서 모두 확인해
본 결과 그림이 나오지 않았습니다. 대신 공간은 잡는거 까지는 나왔습니다.
화면에서 블럭지정을 하면 이미지 공간은 잡히는 것은 보였습니다. 그러나
그림이 안나와서 지금 문제 입니다......음...현제 생각은 libpng라이브러리가
잘못되었는지 그 생각이 나는데요. 그러나 분명 소스 설치 할때 아무런 문제도
없었고 php 소스설치때도 문제 없이 잘 되었습니다... 어떤 문제인지 어떻게
해야 할지 잘 몰라서 답답한 상태입니다...

소스가 너무 길어서....올리지 말까 생각하다 너무 길어서 혹시나 보아야 할지도
몰라서 마지막에 올립니다...

항상 답변해 주시는 분들께 감사드립니다.

<?
header("Content-type: image/png");//이미지 공간형성
$width = 480;
$height = 250;
$image = imagecreate($width, $height); // 색깔 설정

$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$navy = imagecolorallocate($image, 0x00, 0x00, 0x80);
$black = imagecolorallocate($image, 0x00, 0x00, 0x00);
$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);

imagepng($image);
imagedestroy($image);

$data = array( "Jan" => 55, "Feb" => 54, "Mar" => 53, "Apr" => 33, "May" => 13, "Jun" => 15, "Jul" => 23, "Aug" => 28, "Sep" => 32, "Oct" => 45, "Nov" => 73, "Dec" => 71 );

$maxval = max($data);
$nval = sizeof($data);
$vmargin = 20;
$hmargin = 38;
$base = floor(($width - $hmargin) / $nval);

$ysize = $height - 2 * $vmargin;
$xsize = $nval * $base;
imagerectangle($image, $hmargin, $vmargin, $hmargin + $xsize, $vmargin + $ysize, $black);

$titlefont = 3;
$title = "Amount of sell";
$txtsz = imagefontwidth($titlefont) * strlen($title);
$xpos = (int)($hmargin + ($xsize-$txtsz)/2);
$xpos = max(1, $xpos);
$ypos = 3;
imagestring($image, $titlefont, $xpos, $ypos, $title, $black); 

$labelfont = 2;
$ngrid = 4;
$dydat = $maxval / $ngrid;
$dypix = $ysize / ($ngrid + 1); 
for ($i = 0; $i <= ($ngrid + 1); $i++) {
$ydat = (int)($i * $dydat);
$ypos = $vmargin + $ysize - (int)($i*$dypix);
$txtsz = imagefontwidth($labelfont) * strlen($ydat);
$txtht = imagefontheight($labelfont);
$xpos = (int)(($hmargin - $txtsz) / 2);
$xpos = max(1, $xpos);
imagestring($image, $labelfont, $xpos, $ypos - (int)($txtht/2), $ydat, $black);

if (!($i == 0) &&!($i >$ngrid))
imageline($image, $hmargin - 3, $ypos, $hmargin + $xsize,&nbsp;$ypos, $gray);  }

$padding = 3; 
$yscale = $ysize / (($ngrid+1) * $dydat);
for ($i = 0; list($xval, $yval) = each($data); $i++) {

$ymax = $vmargin + $ysize;
$ymin = $ymax - (int)($yval*$yscale);
$xmax = $hmargin + ($i+1)*$base - $padding;
$xmin = $hmargin + $i*$base + $padding
imagefilledrectangle($image, $xmin, $ymin, $xmax, x,&nbsp;$navy);

$txtsz = imagefontwidth($labelfont) * strlen($xval);
$xpos = $xmin + (int)(($base - $txtsz) / 2);
$xpos = max($xmin, $xpos);
$ypos = $ymax + 3;
imagestring($image, $labelfont, $xpos, $ypos, $xval,$black);

?}
kall의 이미지

12-13라인의

imagepng($image);
imagedestroy($image);

코드를 마지막 부분으로 옮기세요.

----
자신을 이길 수 있는자는
무슨짓이든 할수있다..
즉..무서운 넘이란 말이지 ^-_-^
나? 아직 멀었지 ㅠㅠ

익명 사용자의 이미지

답변해 주셔서 감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.