이미지에 박스 넣기

· 2008-01-15 (화) 16:26:22 · 3838 · 2

//이미지에 네모 박스 집어넣기
function draw_box(&$im, $x1, $y1, $x2, $y2, $line_color='', $box_color=''){

  if (!empty($line_color)) {

    $r = hexdec(substr($line_color, 1, 2));
    $g = hexdec(substr($line_color, 3, 2));
    $b = hexdec(substr($line_color, 5, 2));
    $line_color = imagecolorallocate($im, $r, $g, $b);
  }

  if (!empty($box_color)) {

    $r = hexdec(substr($box_color, 1, 2));
    $g = hexdec(substr($box_color, 3, 2));
    $b = hexdec(substr($box_color, 5, 2));
    $box_color = imagecolorallocate($im, $r, $g, $b);
  }

  if (!empty($box_color)) imagefilledrectangle($im, $x1, $y1, $x2, $y2, $box_color);

  if (!empty($line_color)) {

    imageline ($im , $x1, $y1 , $x2 , $y1 , $line_color );//윗줄
    imageline ($im , $x1 , $y2 , $x2 , $y2 , $line_color );//아랫줄
    imageline ($im , $x1 , $y1 , $x1 , $y2 , $line_color );//앞줄
    imageline ($im , $x2 , $y1 , $x2 , $y2 , $line_color );//뒷줄
  }
}

사용법
이미지 생성한후, 생성하는 방법은 여러가지가 있습니다.
$src = @imagecreatefromjpeg($src_path);

이미지에 30*30짜리 박스를 그리고
draw_box(&$src, 0, 0, 30, 30, '#000000', '#FFFFFF');

이미지 생성
imagejpeg($src, $copy_path, 90);

[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]
|

댓글 2개

도움이 많이 되었습니다..감사합니다.
감사합니당~
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
JavaScript 08-02-19 조회 4,926
Flash 08-02-15 조회 4,665
기타 08-02-14 조회 6,534
Flash 08-02-11 조회 5,128
Flash 08-02-09 조회 7,052
Flash 08-02-05 조회 3,844
기타 08-02-04 조회 3,074
MySQL 08-02-03 조회 5,603
JavaScript 08-02-03 조회 4,879
기타 08-02-03 조회 3,654
기타 08-01-30 조회 5,083
기타 08-01-27 조회 2,794
기타 08-01-27 조회 3,260
기타 08-01-26 조회 3,431
기타 08-01-24 조회 6,613
기타 08-01-23 조회 4,275
기타 08-01-21 조회 3,894
기타 08-01-21 조회 3,488
PHP 08-01-18 조회 4,646
기타 08-01-18 조회 4,687
MySQL 08-01-18 조회 7,503
JavaScript 08-01-18 조회 4,764
MySQL 08-01-17 조회 4,378
MySQL 08-01-17 조회 4,045
기타 08-01-16 조회 2,847
JavaScript 08-01-15 조회 3,839
Flash 08-01-14 조회 7,478
기타 08-01-12 조회 4,634
JavaScript 08-01-12 조회 4,752
JavaScript 08-01-12 조회 4,312