- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
<html>
<head>
<style>
body{
background-color: #3366CC; /* Цвет фона веб-страницы */
}
</style>
</head>
<body>
<?php
/*error_reporting(E_ALL);*/
class Mirror{
public $sizeX;
public $sizeY;
public $filenameI;
public $filenameO;
public $red;
public $green;
public $blue;
public $alpha;
function __construct($f){
$this->filenameI=$f.".png";
$this->filenameO=$f."2.png";
$size=getimagesize($this->filenameI);
$this->sizeX=$size[0];
$this->sizeY=$size[1];
}
function saveImg(){
if(!file_exists($this->filenameO)){
$xx=$this->sizeX;
$yy=($this->sizeY)*2;
$im = imagecreatetruecolor($xx, $yy);
imageAlphaBlending($im, false);
imageSaveAlpha($im, true);
for($x=0;$x<$xx;$x++){
for($y=0;$y<$yy;$y++){
$r=$this->red[$x][$y];
$g=$this->green[$x][$y];
$b=$this->blue[$x][$y];
$alph=$this->alpha[$x][$y];
$color=ImageColorAllocateAlpha($im, $r, $g, $b, $alph);
imagesetpixel($im, $x, $y, $color);
}
}
imagepng($im, $this->filenameO);
imagedestroy($im);
}
echo "<img src=\"".$this->filenameI."\" /><hr>\n";
echo "<img src=\"".$this->filenameO."\" /><br>\n";
}
function loadImg(){
$im = imagecreatefrompng($this->filenameI);
for($x=0;$x<$this->sizeX;$x++){
for($y=0;$y<$this->sizeY;$y++){
$rgb = imagecolorat($im, $x, $y);
$color=imagecolorsforindex($im, $rgb);
$this->red[$x][$y]=$color['red'];
$this->green[$x][$y]=$color['green'];
$this->blue[$x][$y]=$color['blue'];
$this->alpha[$x][$y]=$color['alpha'];
}
}
imagedestroy($im);
}
function createMirror(){
if(!file_exists($this->filenameO)){
$yy=($this->sizeY*2);
for($x=0;$x<$this->sizeX;$x++){
$alph=0;
for($y=$this->sizeY;$y<$yy;$y++){
if($alph<126){
$alph++;
}
$this->red[$x][$y]=$this->red[$x][$this->sizeY-($y-$this->sizeY)-1];
$this->green[$x][$y]=$this->green[$x][$this->sizeY-($y-$this->sizeY)-1];
$this->blue[$x][$y]=$this->blue[$x][$this->sizeY-($y-$this->sizeY)-1];
$this->alpha[$x][$y]=$alph+$this->alpha[$x][$this->sizeY-($y-$this->sizeY)-1];
if($this->alpha[$x][$y]>127) $this->alpha[$x][$y]=127;
}
}
}
}
}
$filename="alpha";
$mirror=new Mirror($filename);
$mirror->loadImg();
$mirror->createMirror();
$mirror->saveImg();
?>
</body>
</html>
Делал для одного сайта зеркальное отражение картинки (photoshop использовать не умеем-с). Почему-то сервер часто падал.
Как оно работает, можно посмотреть здесь http://xcont.com/perc/newperceptron/cell/mirror.php