Merhaba, Ziyaretçi. Lütfen giriş yapın veya üye olun.
Aktivasyon mailiniz gelmediyse buraya tıklayın.
Mayıs 13, 2008, 06:20:24 pm
41812 Mesaj 9080 Konu Gönderen: 17479 Üye
Son üye: umit_cbn
Turk-Php.Com Forum  |  Yardım Forumları  |  PHP Yardım Forumu  |  PHP Class Deposu  |  Yuvarlak Köşe Image Class « önceki sonraki »
Sayfa: [1] Yazdır
Yazan Konu: Yuvarlak Köşe Image Class  (Okunma Sayısı 694 defa)
ozgurce
Yeni Kullanıcılar
*
Offline Offline

Mesaj Sayısı: 7


Üyelik Bilgileri
Yuvarlak Köşe Image Class
« : Nisan 13, 2007, 10:06:46 am »

Gerçi bir çok css-web 2.0 muaidili var ama özellikle tablolarımızda yuvarlatılmış imajları kullanmayı bir parça otomotize edecek bir sınıfdır.

Kod:
<?php
/*
 * Created on 15.Ara.2006
 *
 * A simple class that creates rounded corner images for tables
 * Coded By Ozgur Kaya
 * ozgurkaya01@hotmail.com
 */

class roundedCorners {
    var 
$width 50;
    var 
$height 50;
    var 
$bgcolor "#FFFFFF";
    var 
$imagecolor "#ff0000";
    var 
$align;
    var 
$cx;
    var 
$cy;
    var 
$image;
    var 
$type "jpeg";
    var 
$transparent false;

    function 
roundedCorners($width,$height,$align,$bgcolor,$color,$type,$transparent){
        
$this->setWidth($width); // sets image width
        
$this->setHeight($height); // sets image height
        
$this->setAlign($align);  // sets align of image (top-left, top-right, bottom-left, bottom-right)
        
$this->setbgColor($bgcolor); // set image background color
        
$this->setImageColor($color); // set rounded image color
        
$this->setType($type); // set extension for image (jpg,gif,png)
        
$this->setTransparent($transparent); // set transparency of the image
    
}

    function 
setAlign($align){
        
$align = ($align) ? $align $this->align;
if ($this->width == $this->height) {
$align_array = array (
"tl"=>array($this->width,$this->height),
"tr"=>array(0,$this->width),
"bl"=>array($this->height,0),
"br"=>array(0,0)
);
}
elseif ($this->width $this->height) {
$align_array = array (
"tl"=>array($this->width,$this->height),
"tr"=>array(0,$this->height),
"bl"=>array($this->height*2,0),
"br"=>array(0,0)
);
}
elseif ($this->width $this->height) {
$align_array = array (
"tl"=>array($this->width,$this->height),
"tr"=>array(0,$this->height),
"bl"=>array($this->width,0),
"br"=>array(0,0)
);
}
        
$this->cx $align_array[$align][0];
        
$this->cy $align_array[$align][1];
    }

    function 
setWidth($width){
        
$this->width = ($width) ? $width $this->width;
    }

    function 
setHeight($height) {
        
$this->height = ($height) ? $height $this->height;
    }

    function 
setBgColor($bgcolor){
        
$this->bgcolor = ($bgcolor) ? $bgcolor $this->bgcolor;
    }

    function 
setImageColor($color) {
        
$this->imagecolor = ($color) ? $color $this->imagecolor;
    }

    function 
setType($type){
        if (
$type == "jpg")
            
$type "jpeg";
        
$types = array("gif","jpeg","png");
        
$type = (in_array($type,$types)) ? $type "jpeg";
        
$this->type $type;
    }

    function 
setTransparent($transparent){
        if (
$transparent) {
            
$this->type "gif";
            
$this->transparent true;
        }
        else
            
$this->transparent false;
    }

    function 
displayImage($type){
        
$types = array ("gif"=>"gif","png"=>"png","jpg"=>"jpeg");
        
$type $types[$type];
        
header("Content-type: image/png]}");
        
imagepng($this->image);
    }

    function 
createRGBValues($color) {
        
$color str_replace("#","",$color);
        
$rgb["red"] = hexdec(substr($color,0,2));
        
$rgb["green"] = hexdec(substr($color,2,2));
        
$rgb["blue"] = hexdec(substr($color,4,2));
        return 
$rgb;
    }

    function 
createImage() {
        
$this->image imagecreatetruecolor($this->width,$this->height);

        
//
        
$bg_rgb $this->createRGBValues($this->bgcolor);
        
$bg imagecolorallocate($this->image$bg_rgb["red"], $bg_rgb["green"], $bg_rgb["blue"]);
        if (
$this->transparent)
            
$bg imagecolortransparent($this->image,$bg);
        
imagefill($this->image00$bg);

        
//
        
$img_rgb $this->createRGBValues($this->imagecolor);;
        
$col_ellipse imagecolorallocate($this->image$img_rgb["red"], $img_rgb["green"], $img_rgb["blue"]);

        
$w $this->width 2;
        
$h $this->height 2;
        
imagefilledellipse($this->image$this->cx$this->cy$w$h$col_ellipse);

        
header("Content-type: image/{$this->type}");  // set header (you can use different types png,jpeg,gif
        
switch ($this->type){
            case 
"gif":
                
imagegif($this->image);
                break;
            case 
"png":
                
imagepng($this->image);
                break;
            case 
"jpeg":
                
imagejpeg($this->image);
                break;
        }
    }

}
?>


Kullanımı:

Kod:
<?php
//using class
$img = new roundedCorners($_GET['w'],$_GET['h'],$_GET['al'],$_GET['bg'],$_GET['cl'],$_GET['type'],$_GET['tr']); // create a new rounded corner image object with width, height, and align attributes
$img->createImage(); // create image
//

?>

Logged
Sayfa: [1] Yazdır 
« önceki sonraki »
Gitmek istediğiniz yer: