» WAP Мастер Форум
https://forum.wapinet.ru/index.php
» PHP
https://forum.wapinet.ru/viewforum.php?id=3
» Дробовик
https://forum.wapinet.ru/viewtopic.php?id=1308
tipsun » 2011.04.03 15:01
Достает смайлики.
Например отсюда:
Сохраняя прозрачный фон
Код:
1
span style="color: #0000BB"><?php
////////////Автор: TiPsun// icq : 34142776////////////Настройки//
$file
=
'base.png'
;
//Картинка-База
$imgsx
=
16
;
//Смайлов по горизонтали
$imgsy
=
$while
=
12
;
//Смайлов по вертикали//Дополнительные//
$deb_w
=
0
;
//Отступ захвата по X
$deb_h
=
0
;
//Отступ захвата по Y
$deb_x
=
0
;
//Изменение ширины смайла
$deb_y
=
0
;
//Изменение высоты смайла//Настройки//
$table
=
'background-color: #000; border-spacing: 1px; margin: auto;'
;
$td
=
'text-align: center; background-color: #fff; padding: 2px;'
;
$type
=
substr
(
$file
,
strrpos
(
$file
,
'.'
)+
1
);
$input
=
'imagecreatefrom'
.(
'jpg'
==
$type
?
'jpeg'
:
$type
);
$output
=
'image'
.
$type
;
$old
=
$input
(
$file
);
$oldx
=
imageSX
(
$old
);
//Ширина картинки
$oldy
=
imageSY
(
$old
);
//Высота картинки
$newx
= (int)
$oldx
/
$imgsx
+
$deb_x
;
//Ширина смайла
$newy
= (int)
$oldy
/
$imgsy
+
$deb_y
;
//Высота смайла
while(
0
<
$imgsx
) {
$imgsx
-=
1
;
$imgsy
=
$while
;
//Истощается "$imgsy", надо Sprite поливать :)
$printer
.=
'<tr>'
; while(
0
<
$imgsy
) {
$imgsy
-=
1
;
$new
=
imagecreate
(
$newx
,
$newy
);
imagecolortransparent
(
$new
,
imagecolorallocate
(
$new
,
0
,
0
,
0
));
//Прозрачный фон для (*.png)
imagecopy
(
$new
,
$old
,
$deb_w
,
$deb_h
, (
$newx
*
$imgsx
), (
$newy
*
$imgsy
),
$oldx
,
$oldy
);
$x
=
$imgsx
+
1
;
$y
=
$imgsy
+
1
;
$output
(
$new
,
'smilies/x('
.(
$x
).
')_y('
.(
$y
).
').png'
);
imageDestroy
(
$new
);
//Не мусорить
$printer
.=
'<td style="'
.
$td
.
'">('
.(
$x
).
';'
.(
$y
).
')</td>'
; }
//Сканирвание по вертикали
$printer
.=
'</tr>'
; }
//Сканирвание по горизонтали
imageDestroy
(
$old
);
//См. выше...
echo
'<html><body><table style="'
.
$table
.
'">'
.
$printer
.
'</table></body></html>'
;
?>