[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.graphic.bmp.php
index 90cbb38..dc7b30d 100644 (file)
@@ -1,11 +1,11 @@
 <?php
+
 /////////////////////////////////////////////////////////////////
 /// getID3() by James Heinrich <info@getid3.org>               //
-//  available at http://getid3.sourceforge.net                 //
-//            or http://www.getid3.org                         //
-//          also https://github.com/JamesHeinrich/getID3       //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details                             //
+//  available at https://github.com/JamesHeinrich/getID3       //
+//            or https://www.getid3.org                        //
+//            or http://getid3.sourceforge.net                 //
+//  see readme.txt for more details                            //
 /////////////////////////////////////////////////////////////////
 //                                                             //
 // module.graphic.bmp.php                                      //
@@ -20,6 +20,9 @@ class getid3_bmp extends getid3_handler
        public $ExtractPalette = false;
        public $ExtractData    = false;
 
+       /**
+        * @return bool
+        */
        public function Analyze() {
                $info = &$this->getid3->info;
 
@@ -528,6 +531,7 @@ class getid3_bmp extends getid3_handler
                                                                                        // high- and low-order 4 bits, one color index for each pixel. In absolute mode,
                                                                                        // each run must be aligned on a word boundary.
                                                                                        unset($paletteindexes);
+                                                                                       $paletteindexes = array();
                                                                                        for ($i = 0; $i < ceil($secondbyte / 2); $i++) {
                                                                                                $paletteindexbyte = getid3_lib::LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
                                                                                                $paletteindexes[] = ($paletteindexbyte & 0xF0) >> 4;
@@ -625,7 +629,11 @@ class getid3_bmp extends getid3_handler
                return true;
        }
 
-
+       /**
+        * @param array $BMPinfo
+        *
+        * @return bool
+        */
        public function PlotBMP(&$BMPinfo) {
                $starttime = time();
                if (!isset($BMPinfo['bmp']['data']) || !is_array($BMPinfo['bmp']['data'])) {
@@ -633,15 +641,15 @@ class getid3_bmp extends getid3_handler
                        return false;
                }
                set_time_limit(intval(round($BMPinfo['resolution_x'] * $BMPinfo['resolution_y'] / 10000)));
-               if ($im = ImageCreateTrueColor($BMPinfo['resolution_x'], $BMPinfo['resolution_y'])) {
+               if ($im = imagecreatetruecolor($BMPinfo['resolution_x'], $BMPinfo['resolution_y'])) {
                        for ($row = 0; $row < $BMPinfo['resolution_y']; $row++) {
                                for ($col = 0; $col < $BMPinfo['resolution_x']; $col++) {
                                        if (isset($BMPinfo['bmp']['data'][$row][$col])) {
                                                $red   = ($BMPinfo['bmp']['data'][$row][$col] & 0x00FF0000) >> 16;
                                                $green = ($BMPinfo['bmp']['data'][$row][$col] & 0x0000FF00) >> 8;
                                                $blue  = ($BMPinfo['bmp']['data'][$row][$col] & 0x000000FF);
-                                               $pixelcolor = ImageColorAllocate($im, $red, $green, $blue);
-                                               ImageSetPixel($im, $col, $row, $pixelcolor);
+                                               $pixelcolor = imagecolorallocate($im, $red, $green, $blue);
+                                               imagesetpixel($im, $col, $row, $pixelcolor);
                                        } else {
                                                //echo 'ERROR: no data for pixel '.$row.' x '.$col.'<BR>';
                                                //return false;
@@ -650,18 +658,23 @@ class getid3_bmp extends getid3_handler
                        }
                        if (headers_sent()) {
                                echo 'plotted '.($BMPinfo['resolution_x'] * $BMPinfo['resolution_y']).' pixels in '.(time() - $starttime).' seconds<BR>';
-                               ImageDestroy($im);
+                               imagedestroy($im);
                                exit;
                        } else {
                                header('Content-type: image/png');
-                               ImagePNG($im);
-                               ImageDestroy($im);
+                               imagepng($im);
+                               imagedestroy($im);
                                return true;
                        }
                }
                return false;
        }
 
+       /**
+        * @param int $compressionid
+        *
+        * @return string
+        */
        public function BMPcompressionWindowsLookup($compressionid) {
                static $BMPcompressionWindowsLookup = array(
                        0 => 'BI_RGB',
@@ -674,6 +687,11 @@ class getid3_bmp extends getid3_handler
                return (isset($BMPcompressionWindowsLookup[$compressionid]) ? $BMPcompressionWindowsLookup[$compressionid] : 'invalid');
        }
 
+       /**
+        * @param int $compressionid
+        *
+        * @return string
+        */
        public function BMPcompressionOS2Lookup($compressionid) {
                static $BMPcompressionOS2Lookup = array(
                        0 => 'BI_RGB',