Documentation is available at class.imgswf.php
1 <?php
2
3 class Image_base_funktions{
4
5 function Cr_jpg($image){
6
7 $this->image_array = @GetImageSize($image);
8 if(!is_array($this->image_array)){
9 $image_handle = $this->Make_error($image);
10 }
11 else{
12 switch($this->image_array[2]){
13 case 1:
14 $image_handle = $this->Gif2jpg($image);
15 break;
16 case 2:
17 $image_handle = $this->Makejpg($image);
18 break;
19 case 3:
20 $image_handle = $this->Png2jpg($image);
21 break;
22 default:
23 $image_handle = $this->Make_error($image);
24 break;
25 }
26 }
27 if($this->Check_prog($image_handle)=== true){
28 $this->Jpg_prog2jpg($image_handle);
29 }
30 return $image_handle;
31 }
32
33 function Check_prog($image_handle){
34 if (imageinterlace($image_handle) == 1){
35 return true;
36 }
37 else{
38 return false;
39 }
40 }
41
42
43 function Makejpg($image){
44
45 $image_handle = @imagecreatefromjpeg($image);
46 if (!$image_handle) {
47 $image_handle = $this->Make_error($image);
48 }
49 return $image_handle;
50 }
51
52
53 function Png2jpg($image){
54
55 $image_handle = @imagecreatefrompng($image);
56 if (!$image_handle) {
57 $image_handle = $this->Make_error($image);
58 }
59 return $image_handle;
60 }
61
62
63 function Jpg_prog2jpg($image_handle){
64
65 imageinterlace($image_handle,0);
66 }
67
68
69 function Gif2jpg($image){
70
71 $image_handle = @imagecreatefromgif($image);
72 if (!$image_handle) {
73 $image_handle = $this->Make_error($image);
74 }
75 return $image_handle;
76 }
77
78
79 function Make_error($image){
80
81 /* script from an vic@zymsys.com, thanks */
82 $image_handle = ImageCreate (150, 30);
83 $bgc = ImageColorAllocate ($image_handle, 255, 255, 255);
84 $tc = ImageColorAllocate ($image_handle, 0, 0, 0);
85 ImageFilledRectangle ($image_handle, 0, 0, 150, 30, $bgc);
86 /* Ausgabe einer Fehlermeldung */
87 ImageString($image_handle, 1, 5, 5, "Fehler beim Öffnen von: $image", $tc);
88 $this->image_array[0] = 150;
89 $this->image_array[1] = 30;
90 }
91 }
92
93
94
95 class Image2swf extends Image_base_funktions{
96 var $image_array;
97
98
99 function Main($image,$swf_name){
100
101 $image_handle = $this->Cr_jpg($image);
102
103
104 $this->Make_swf($image_handle,$swf_name);
105 return true;
106 }
107
108
109 function Make_swf($image_handle,$swf_name){
110
111 $temp_image_name = uniqid(time()).".jpg";
112 imagejpeg ($image_handle, $temp_image_name, 100);
113 ImageDestroy($image_handle);
114 $s = new SWFShape();
115
116 /*if (!is_object(@new SWFBitmap($temp_image_name))){
117 echo "Konnte Temporäres Bild nicht anlegen / lesen";
118 }
119 else{
120 $b = new SWFBitmap($temp_image_name);
121 }*/
122
123 $fp = fopen($temp_image_name,"r");
124 $i = fread($fp,9999999);
125 $b = new SWFBitmap($i);
126 fclose($fp);
127
128 $f = $s->addFill($b);
129
130 $s->setRightFill($f);
131
132 $s->drawLine($this->image_array[0], 0);
133 $s->drawLine(0, $this->image_array[1]);
134 $s->drawLine(-$this->image_array[0], 0);
135 $s->drawLine(0, -$this->image_array[1]);
136
137 $m = new SWFMovie();
138 $m->setDimension($this->image_array[0], $this->image_array[1]);
139 $m->add($s);
140
141 $m->save($swf_name);
142 @unlink($temp_image_name);
143 }
144
145 }
146
147 ?>
Documentation generated on Thu, 9 Jun 2005 06:51:41 +0200 by phpDocumentor 1.2.3