当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageColorsTotal函数代码示例

本文整理汇总了PHP中ImageColorsTotal函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageColorsTotal函数的具体用法?PHP ImageColorsTotal怎么用?PHP ImageColorsTotal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ImageColorsTotal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ImageCopyResampleBicubic

 /**
  * @param $dst_img
  * @param $src_img
  * @param $dst_x
  * @param $dst_y
  * @param $src_x
  * @param $src_y
  * @param $dst_w
  * @param $dst_h
  * @param $src_w
  * @param $src_h
  */
 function ImageCopyResampleBicubic(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
 {
     $palsize = ImageColorsTotal($src_img);
     for ($i = 0; $i < $palsize; $i++) {
         // get palette.
         $colors = ImageColorsForIndex($src_img, $i);
         ImageColorAllocate($dst_img, $colors['red'], $colors['green'], $colors['blue']);
     }
     $scaleX = ($src_w - 1) / $dst_w;
     $scaleY = ($src_h - 1) / $dst_h;
     $scaleX2 = (int) ($scaleX / 2);
     $scaleY2 = (int) ($scaleY / 2);
     for ($j = $src_y; $j < $dst_h; $j++) {
         $sY = (int) ($j * $scaleY);
         $y13 = $sY + $scaleY2;
         for ($i = $src_x; $i < $dst_w; $i++) {
             $sX = (int) ($i * $scaleX);
             $x34 = $sX + $scaleX2;
             $color1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $sX, $y13));
             $color2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $sX, $sY));
             $color3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $x34, $y13));
             $color4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $x34, $sY));
             $red = ($color1['red'] + $color2['red'] + $color3['red'] + $color4['red']) / 4;
             $green = ($color1['green'] + $color2['green'] + $color3['green'] + $color4['green']) / 4;
             $blue = ($color1['blue'] + $color2['blue'] + $color3['blue'] + $color4['blue']) / 4;
             ImageSetPixel($dst_img, $i + $dst_x - $src_x, $j + $dst_y - $src_y, ImageColorClosest($dst_img, $red, $green, $blue));
         }
     }
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:41,代码来源:imagegallib.php

示例2: loadImageFromFile

 function loadImageFromFile($imageInfo)
 {
     $_result = 0;
     $filelocation = $imageInfo['file_location'];
     //$filelocation = dirname($this->_filename).'/'.$filelocation;
     switch ($imageInfo['type']) {
         case 1:
             $_result = @imagecreatefromgif($filelocation);
             break;
         case 2:
             $_result = @imagecreatefromjpeg($filelocation);
             break;
         case 3:
             $_result = @imagecreatefrompng($filelocation);
             break;
         case 4:
             $_result = @imagecreatefromswf($filelocation);
             break;
         case 6:
             $_result = @imagecreatefromwbmp($filelocation);
             break;
         case 15:
             $_result = @imagecreatefromxbm($filelocation);
             break;
     }
     $_colorCount = ImageColorsTotal($_result);
     //$this->log->info[] = 'testing image: '. basename($filelocation) . ' colors: '.$_colorCount .
     //" size:[{$imageInfo['width']}x{$imageInfo['height']}]\n";
     if ($this->_maxColors < $_colorCount) {
         $this->_maxColors = $_colorCount;
     }
     if ($_colorCount == 0) {
         $this->_trueColor = true;
     }
     if (!$_result) {
         die("ERROR: Can not open file: {$filelocation}\n");
     }
     return $_result;
 }
开发者ID:pjkui,项目名称:joycss,代码行数:39,代码来源:smartsprite.php

示例3: resize

 /**
  * From: https://stackoverflow.com/questions/4590441/php-thumbnail-image-resizing-with-proportions
  */
 function resize(&$img, $size)
 {
     if (!is_numeric($size)) {
         $size = explode('x', $size);
     }
     if (is_array($size)) {
         $maxwidth = $size[0];
         $maxheight = $size[1];
     } else {
         if ($size) {
             $maxwidth = $size;
             $maxheight = $size;
         }
     }
     $width = imagesx($img);
     $height = imagesy($img);
     if (!ALLOW_BLOATING) {
         if ($maxwidth > $width) {
             $maxwidth = $width;
         }
         if ($maxheight > $height) {
             $maxheight = $height;
         }
     }
     if ($height > $width) {
         $ratio = $maxheight / $height;
         $newheight = $maxheight;
         $newwidth = $width * $ratio;
     } else {
         $ratio = $maxwidth / $width;
         $newwidth = $maxwidth;
         $newheight = $height * $ratio;
     }
     $newimg = imagecreatetruecolor($newwidth, $newheight);
     $palsize = ImageColorsTotal($img);
     for ($i = 0; $i < $palsize; $i++) {
         $colors = ImageColorsForIndex($img, $i);
         ImageColorAllocate($newimg, $colors['red'], $colors['green'], $colors['blue']);
     }
     imagefill($newimg, 0, 0, IMG_COLOR_TRANSPARENT);
     imagesavealpha($newimg, true);
     imagealphablending($newimg, true);
     imagecopyresampled($newimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
     $img = $newimg;
 }
开发者ID:shyswork,项目名称:pictshare,代码行数:48,代码来源:image.php

示例4: save_resize

function save_resize($tempDir, $imgurl, $w, $h, $destDir)
{
    //print ("save_resize...\n<br />");
    //print ("$tempDir\n<br />");
    //print ("$imgurl\n<br />");
    //print ("$w<br />\n");
    //print ("$h<br />\n");
    //print ("$destDir<br />\n");
    $simg = imagecreatefromjpeg("{$tempDir}" . $imgurl);
    // Make A New Temporary Image To Create The Thumbanil From
    $currwidth = imagesx($simg);
    // Current Image Width
    $currheight = imagesy($simg);
    // Current Image Height
    //print ("$currwidth<br />\n");
    //print ("$currheight<br />\n");
    //if ($currheight > $currwidth) {   // If Height Is Greater Than Width
    //   $zoom = $w / $currheight;   // Length Ratio For Width
    //   $newheight = $h;   // Height Is Equal To Max Height
    //   $newwidth = $currwidth * $zoom;   // Creates The New Width
    //} else {    // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height)
    $zoom = $w / $currwidth;
    // Length Ratio For Height
    $newwidth = $w;
    // Width Is Equal To Max Width
    $newheight = $currheight * $zoom;
    // Creates The New Height
    //}
    //print ("$newwidth<br />\n");
    //print ("$newheight<br />\n");
    $dimg = imagecreate($newwidth, $newheight);
    // Make New Image For Thumbnail
    imagetruecolortopalette($simg, false, 256);
    // Create New Color Pallete
    $palsize = ImageColorsTotal($simg);
    for ($i = 0; $i < $palsize; $i++) {
        // Counting Colors In The Image
        $colors = ImageColorsForIndex($simg, $i);
        // Number Of Colors Used
        ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']);
        // Tell The Server What Colors This Image Will Use
    }
    imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);
    // Copy Resized Image To The New Image (So We Can Save It)
    imagejpeg($dimg, "{$destDir}" . $imgurl);
    // Saving The Image
    //print ("$destDir" . $imgurl . "<br />");
    imagedestroy($simg);
    // Destroying The Temporary Image
    imagedestroy($dimg);
    // Destroying The Other Temporary Image
    return $newheight;
    //print ("save_resize DONE...");
}
开发者ID:rodmaykel,项目名称:Extrabaon,代码行数:54,代码来源:upload_file.php

示例5: inputLevels

 /**
  * Apply input levels to input image pointer (increasing contrast)
  *
  * @param resource $im GDlib Image Pointer
  * @param int $low The "low" value (close to 0)
  * @param int $high The "high" value (close to 255)
  * @return void
  */
 public function inputLevels(&$im, $low, $high)
 {
     if ($low < $high) {
         $low = MathUtility::forceIntegerInRange($low, 0, 255);
         $high = MathUtility::forceIntegerInRange($high, 0, 255);
         $delta = $high - $low;
         $totalCols = ImageColorsTotal($im);
         for ($c = 0; $c < $totalCols; $c++) {
             $cols = ImageColorsForIndex($im, $c);
             $cols['red'] = MathUtility::forceIntegerInRange(($cols['red'] - $low) / $delta * 255, 0, 255);
             $cols['green'] = MathUtility::forceIntegerInRange(($cols['green'] - $low) / $delta * 255, 0, 255);
             $cols['blue'] = MathUtility::forceIntegerInRange(($cols['blue'] - $low) / $delta * 255, 0, 255);
             ImageColorSet($im, $c, $cols['red'], $cols['green'], $cols['blue']);
         }
     }
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:24,代码来源:GraphicalFunctions.php

示例6: traiter_image


//.........这里部分代码省略.........
                $dest_ratio = $dest_height / $height_orig;
                $wo = $dest_width / $dest_ratio;
                $delta_x = ($width_orig - $wo) / 2;
                $width_orig = $wo;
                $next_height = $dest_height;
            } else {
                if ($exact != IMAGE_REDIM_BORDURE) {
                    $dest_height = $next_height;
                }
            }
        }
    }
    if ($exact == IMAGE_REDIM_BORDURE) {
        $border_width = intval(($dest_width - $next_width) / 2);
        $border_height = intval(($dest_height - $next_height) / 2);
    }
    $image_new = imagecreatetruecolor($dest_width, $dest_height);
    switch ($type) {
        case IMAGETYPE_GIF:
            $image_orig = imagecreatefromgif($nomorig);
            break;
        case IMAGETYPE_JPEG:
        default:
            $image_orig = imagecreatefromjpeg($nomorig);
            break;
        case IMAGETYPE_PNG:
            $image_orig = imagecreatefrompng($nomorig);
            break;
    }
    // Preparer la couleur de fond (pour bordures, transparence, miroir)
    if ($couleurfond == '') {
        $couleurfond = 'ffffff';
    }
    $fondrgb = hex2RGB($couleurfond);
    // Définir la couleur de fond générale
    $bgcolor = imagecolorallocate($image_new, $fondrgb['red'], $fondrgb['green'], $fondrgb['blue']);
    // Préserver la transparence des gifs et png
    if ($type != IMAGETYPE_JPEG) {
        $trnprt_indx = imagecolortransparent($image_orig);
        // If we have a specific transparent color
        if ($trnprt_indx >= 0) {
            // Get the original image's transparent color's RGB values
            $trnprt_color = imagecolorsforindex($image_orig, $trnprt_indx);
            // Allocate the same color in the new image resource
            $trnprt_indx = imagecolorallocate($image_new, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
            // Completely fill the background of the new image with allocated color.
            imagefill($image_new, 0, 0, $trnprt_indx);
            // Set the background color for new image to transparent
            imagecolortransparent($image_new, $trnprt_indx);
        } else {
            // Turn off transparency blending (temporarily)
            imagealphablending($image_new, false);
            // Create a new transparent color for image
            $color = imagecolorallocatealpha($image_new, 0, 0, 0, 127);
            // Completely fill the background of the new image with allocated color.
            imagefill($image_new, 0, 0, $color);
            // Restore transparency blending
            imagesavealpha($image_new, true);
            // Remplir avec la couleur de fond
            imagefill($image_new, 0, 0, $bgcolor);
        }
    } else {
        // Remplir avec la couleur de fond
        imagefill($image_new, 0, 0, $bgcolor);
    }
    if ($opacite != "") {
        $opac_img = imagecreatetruecolor($width_orig, $height_orig);
        imagefill($opac_img, 0, 0, $bgcolor);
        imagecopymerge($opac_img, $image_orig, 0, 0, 0, 0, $width_orig, $height_orig, $opacite);
        $image_orig = $opac_img;
    }
    // Redimensionnement, avec ajout éventuel de bordures.
    imagecopyresampled($image_new, $image_orig, $border_width, $border_height, $delta_x, $delta_y, $next_width, $next_height, $width_orig, $height_orig);
    // Noir et blanc
    if ($nb != "") {
        imagetruecolortopalette($image_new, false, 256);
        $total = ImageColorsTotal($image_new);
        for ($i = 0; $i < $total; $i++) {
            $old = ImageColorsForIndex($image_new, $i);
            $commongrey = (int) (($old['red'] + $old['green'] + $old['blue']) / 3);
            ImageColorSet($image_new, $i, $commongrey, $commongrey, $commongrey);
        }
    }
    if ($miroir != "") {
        $mh = intval($miroir) == 1 ? 50 : intval($miroir);
        $largeur = imagesx($image_new);
        $hauteur = imagesy($image_new);
        $temporaireUn = imagecreatetruecolor($largeur, $mh);
        $temporaireDeux = imagecreatetruecolor($largeur, $mh);
        $resultat = imagecreatetruecolor($largeur, $hauteur + $mh);
        imagefill($resultat, 1, 1, $bgcolor);
        imagefill($temporaireDeux, 1, 1, $bgcolor);
        imagecopy($resultat, $image_new, 0, 0, 0, 0, $largeur, $hauteur);
        imagecopy($temporaireUn, $image_new, 0, 0, 0, $hauteur - $mh, $largeur, $mh);
        effet_miroir($temporaireDeux, $temporaireUn);
        imagecopy($resultat, $temporaireDeux, 0, $hauteur, 0, 0, $largeur, $mh);
        $image_new = $resultat;
    }
    return $image_new;
}
开发者ID:anti-conformiste,项目名称:thelia1,代码行数:101,代码来源:image.php

示例7: reduceColors

 /**
  * Reduce colors in image dependend on the actual amount of colors (Only works if we are not in truecolor mode)
  * This function is not needed anymore, as truecolor is now always on.
  *
  * @param	integer		GDlib Image Pointer
  * @param	integer		The max number of colors in the image before a reduction will happen; basically this means that IF the GD image current has the same amount or more colors than $limit define, THEN a reduction is performed.
  * @param	integer		Number of colors to reduce the image to.
  * @return	void
  * @deprecated since TYPO3 4.4, this function will be removed in TYPO3 4.6.
  */
 function reduceColors(&$im, $limit, $cols)
 {
     t3lib_div::logDeprecatedFunction();
     if (!$this->truecolor && ImageColorsTotal($im) >= $limit) {
         $this->makeEffect($im, array('value' => 'colors=' . $cols));
     }
 }
开发者ID:NaveedWebdeveloper,项目名称:Test,代码行数:17,代码来源:class.t3lib_stdgraphic.php

示例8: resampleBicubic

 /**
  * Resample the image 
  * http://www.php.net/manual/en/function.imagecopyresized.php
  */
 protected function resampleBicubic(&$dst, &$src, $dstx, $dsty, $srcx, $srcy, $w, $h, $zoomX, $zoomY = '')
 {
     if (!$zoomY) {
         $zoomY = $zoomX;
     }
     $palsize = ImageColorsTotal($src);
     for ($i = 0; $i < $palsize; $i++) {
         $colors = ImageColorsForIndex($src, $i);
         ImageColorAllocate($dst, $colors['red'], $colors['green'], $colors['blue']);
     }
     $zoomX2 = (int) ($zoomX / 2);
     $zoomY2 = (int) ($zoomY / 2);
     $dstX = imagesx($dst);
     $dstY = imagesy($dst);
     $srcX = imagesx($src);
     $srcY = imagesy($src);
     for ($j = 0; $j < $h - $dsty; $j++) {
         $sY = (int) ($j * $zoomY) + $srcy;
         $y13 = $sY + $zoomY2;
         $dY = $j + $dsty;
         if ($sY >= $srcY or $dY >= $dstY or $y13 >= $srcY) {
             break 1;
         }
         for ($i = 0; $i < $w - $dstx; $i++) {
             $sX = (int) ($i * $zoomX) + $srcx;
             $x34 = $sX + $zoomX2;
             $dX = $i + $dstx;
             if ($sX >= $srcX or $dX >= $dstX or $x34 >= $srcX) {
                 break 1;
             }
             $c1 = ImageColorsForIndex($src, ImageColorAt($src, $sX, $y13));
             $c2 = ImageColorsForIndex($src, ImageColorAt($src, $sX, $sY));
             $c3 = ImageColorsForIndex($src, ImageColorAt($src, $x34, $y13));
             $c4 = ImageColorsForIndex($src, ImageColorAt($src, $x34, $sY));
             $r = ($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4;
             $g = ($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4;
             $b = ($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4;
             ImageSetPixel($dst, $dX, $dY, ImageColorClosest($dst, $r, $g, $b));
         }
     }
 }
开发者ID:burbuja,项目名称:pluf,代码行数:45,代码来源:Thumbnail.php

示例9: inputLevels

 /**
  * Apply input levels to input image pointer (increasing contrast)
  *
  * @param integer $im GDlib Image Pointer
  * @param integer $low The "low" value (close to 0)
  * @param integer $high The "high" value (close to 255)
  * @param boolean $swap If swap, then low and high are swapped. (Useful for negated masks...)
  * @return void
  * @todo Define visibility
  */
 public function inputLevels(&$im, $low, $high, $swap = '')
 {
     if ($low < $high) {
         $low = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($low, 0, 255);
         $high = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($high, 0, 255);
         if ($swap) {
             $temp = $low;
             $low = 255 - $high;
             $high = 255 - $temp;
         }
         $delta = $high - $low;
         $totalCols = ImageColorsTotal($im);
         for ($c = 0; $c < $totalCols; $c++) {
             $cols = ImageColorsForIndex($im, $c);
             $cols['red'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['red'] - $low) / $delta * 255, 0, 255);
             $cols['green'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['green'] - $low) / $delta * 255, 0, 255);
             $cols['blue'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['blue'] - $low) / $delta * 255, 0, 255);
             ImageColorSet($im, $c, $cols['red'], $cols['green'], $cols['blue']);
         }
     }
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:31,代码来源:GraphicalFunctions.php

示例10: imagecreate

     $newwidth = $currwidth * $zoom;
     // Creates The New Width
 } else {
     // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height)
     $zoom = $twidth / $currwidth;
     // Length Ratio For Height
     $newwidth = $twidth;
     // Width Is Equal To Max Width
     $newheight = $currheight * $zoom;
     // Creates The New Height
 }
 $dimg = imagecreate($newwidth, $newheight);
 // Make New Image For Thumbnail
 imagetruecolortopalette($simg, false, 256);
 // Create New Color Pallete
 $palsize = ImageColorsTotal($simg);
 for ($i = 0; $i < $palsize; $i++) {
     // Counting Colors In The Image
     $colors = ImageColorsForIndex($simg, $i);
     // Number Of Colors Used
     ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']);
     // Tell The Server What Colors This Image Will Use
 }
 imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);
 // Copy Resized Image To The New Image (So We Can Save It)
 imagejpeg($dimg, "{$tdir}" . $_SESSION['user']['username'] . '.jpg');
 // Saving The Image
 imagedestroy($simg);
 // Destroying The Temporary Image
 imagedestroy($dimg);
 // Destroying The Other Temporary Image
开发者ID:JJWTimmer,项目名称:BLAM,代码行数:31,代码来源:usermgr.php

示例11: resize

 /**
  * From: https://stackoverflow.com/questions/4590441/php-thumbnail-image-resizing-with-proportions
  */
 function resize(&$img, $size)
 {
     $pm = new PictshareModel();
     $sd = $pm->sizeStringToWidthHeight($size);
     $maxwidth = $sd['width'];
     $maxheight = $sd['height'];
     $width = imagesx($img);
     $height = imagesy($img);
     if (!ALLOW_BLOATING) {
         if ($maxwidth > $width) {
             $maxwidth = $width;
         }
         if ($maxheight > $height) {
             $maxheight = $height;
         }
     }
     if ($height > $width) {
         $ratio = $maxheight / $height;
         $newheight = $maxheight;
         $newwidth = $width * $ratio;
     } else {
         $ratio = $maxwidth / $width;
         $newwidth = $maxwidth;
         $newheight = $height * $ratio;
     }
     $newimg = imagecreatetruecolor($newwidth, $newheight);
     $palsize = ImageColorsTotal($img);
     for ($i = 0; $i < $palsize; $i++) {
         $colors = ImageColorsForIndex($img, $i);
         ImageColorAllocate($newimg, $colors['red'], $colors['green'], $colors['blue']);
     }
     imagefill($newimg, 0, 0, IMG_COLOR_TRANSPARENT);
     imagesavealpha($newimg, true);
     imagealphablending($newimg, true);
     imagecopyresampled($newimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
     $img = $newimg;
 }
开发者ID:cavebeat,项目名称:pictshare,代码行数:40,代码来源:image.php

示例12: __invoke

 public function __invoke()
 {
     $view = $this->view;
     $pixObject = $this->pixObject;
     $id = $pixObject->getId();
     $title = $pixObject->getTitle();
     $pixname = $pixObject->getPicture();
     $filepix = "/usr/local/apache2/html/uploads/";
     $filepix .= $this->username;
     $filepix .= "/pix/";
     $pix = $filepix . $pixname;
     // Check to see that the thumbnail exists.
     $thumbPixName = "large_" . $pixname;
     $thumbPix = $filepix . $thumbPixName;
     if (!file_exists($thumbPix)) {
         $img = imagecreatefromjpeg($pix);
         $width = imagesx($img);
         $height = imagesy($img);
         $whlog = "width: " . $width . " height " . $height;
         //determine which side is the longest to use in calculating length of the shorter side, since the longest will be the max size for whichever side is longest.
         if ($height > $width) {
             $ratio = 160 / $height;
             $newheight = 160;
             $newwidth = $width * $ratio;
         } else {
             $ratio = 160 / $width;
             $newwidth = 160;
             $newheight = $height * $ratio;
         }
         $whlog = "newwidth: " . $newwidth . " newheight " . $newheight;
         //create new image resource to hold the resized image
         $newimg = imagecreatetruecolor($newwidth, $newheight);
         $palsize = ImageColorsTotal($img);
         //Get palette size for original image
         for ($i = 0; $i < $palsize; $i++) {
             $colors = ImageColorsForIndex($img, $i);
             ImageColorAllocate($newimg, $colors['red'], $colors['green'], $colors['blue']);
         }
         //copy original image into new image at new size.
         imagecopyresized($newimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
         imagejpeg($newimg, $thumbPix);
         //$output file is the path/filename where you wish to save the file.
     }
     $base = 'https://newhollandpress.com/pix/view/';
     $base .= urlencode($id);
     return $view->partial("/items/pix.phtml");
     /*
         	$output = "<div id='" . $this->itemId . "' class='itemHelper_Wide'>";
     		$output .= "<ul>";
     		$output .= "<li>";
     		$output .= "<span>Pix</span>";
     		$output .= "</li>";
     		$output .= "<li>";
     		$output .= "<a href='" . $base . "'>" . $id . "</a>";
     		$output .= "</li>";
     		$output .= "<li>";
     		$output .= $pixObject->getPicture();
     		$output .= "</li>";
     		$output .= "<li>";
     		$output .= "<img src='https://www.newhollandpress.com/uploads/";
     		$output .= $this->username;
     		$output .= "/pix/";
     		$output .= $thumbPixName;
     		$output .= "'>";
     		$output .= "</li>";
     		$output .= "</ul>";
     		$output .= "</div>";
     		
     		return $output;
     * 
     */
 }
开发者ID:newhollandpress,项目名称:nhp,代码行数:72,代码来源:PixHelper.php

示例13: GDtoICOstr

 function GDtoICOstr(&$gd_ico_array)
 {
     foreach ($gd_ico_array as $key => $gd_image) {
         $IcoWidths[$key] = ImageSX($gd_image);
         $IcoHeights[$key] = ImageSY($gd_image);
         $bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
         $totalcolors[$key] = ImageColorsTotal($gd_image);
         $icXOR[$key] = '';
         for ($y = $IcoHeights[$key] - 1; $y >= 0; $y--) {
             for ($x = 0; $x < $IcoWidths[$key]; $x++) {
                 $argb = $this->gpc($gd_image, $x, $y);
                 $a = round(255 * ((127 - $argb['alpha']) / 127));
                 $r = $argb['red'];
                 $g = $argb['green'];
                 $b = $argb['blue'];
                 if ($bpp[$key] == 32) {
                     $icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
                 } elseif ($bpp[$key] == 24) {
                     $icXOR[$key] .= chr($b) . chr($g) . chr($r);
                 }
                 if ($a < 128) {
                     @($icANDmask[$key][$y] .= '1');
                 } else {
                     @($icANDmask[$key][$y] .= '0');
                 }
             }
             while (strlen($icANDmask[$key][$y]) % 32) {
                 $icANDmask[$key][$y] .= '0';
             }
         }
         $icAND[$key] = '';
         foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
             for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
                 $icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
             }
         }
     }
     foreach ($gd_ico_array as $key => $gd_image) {
         $biSizeImage = $IcoWidths[$key] * $IcoHeights[$key] * ($bpp[$key] / 8);
         $bfh[$key] = '';
         $bfh[$key] .= "(";
         $bfh[$key] .= $this->le2s($IcoWidths[$key], 4);
         $bfh[$key] .= $this->le2s($IcoHeights[$key] * 2, 4);
         $bfh[$key] .= "";
         $bfh[$key] .= chr($bpp[$key]) . "";
         $bfh[$key] .= "";
         $bfh[$key] .= $this->le2s($biSizeImage, 4);
         $bfh[$key] .= "";
         $bfh[$key] .= "";
         $bfh[$key] .= "";
         $bfh[$key] .= "";
     }
     $icondata = "";
     $icondata .= "";
     $icondata .= $this->le2s(count($gd_ico_array), 2);
     $dwImageOffset = 6 + count($gd_ico_array) * 16;
     foreach ($gd_ico_array as $key => $gd_image) {
         $icondata .= chr($IcoWidths[$key]);
         $icondata .= chr($IcoHeights[$key]);
         $icondata .= chr($totalcolors[$key]);
         $icondata .= "";
         $icondata .= "";
         $icondata .= chr($bpp[$key]) . "";
         $dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
         $icondata .= $this->le2s($dwBytesInRes, 4);
         $icondata .= $this->le2s($dwImageOffset, 4);
         $dwImageOffset += strlen($bfh[$key]);
         $dwImageOffset += strlen($icXOR[$key]);
         $dwImageOffset += strlen($icAND[$key]);
     }
     foreach ($gd_ico_array as $key => $gd_image) {
         $icondata .= $bfh[$key];
         $icondata .= $icXOR[$key];
         $icondata .= $icAND[$key];
     }
     return $icondata;
 }
开发者ID:diandianxiyu,项目名称:ApiTesting,代码行数:77,代码来源:Iconv.php

示例14: nfo2pic

 function nfo2pic($pic_format)
 {
     // 打开指定位置的 NFO 文件
     $nfoa = @file($this->config['nfo-dir'] . $this->config['nfo_name']);
     // 如果 NFO 文件不存在,或者打开失败
     if (!$nfoa) {
         echo "打开打开NFO文件失败!";
         exit;
     }
     // 计算图片的高度
     $this->setvar("height", count($nfoa) * $this->config["line-space"]);
     // 建立图片流
     $im = imagecreate($this->config["width"], $this->config["height"]);
     // 获取背景色
     $bgR = hexdec(substr($this->config['bgcolor'], 1, 2));
     $bgG = hexdec(substr($this->config['bgcolor'], 3, 2));
     $bgB = hexdec(substr($this->config['bgcolor'], 5));
     //list ($bgR,  $bgG,  $bgB)  =  $this->config['bgcolor'];
     // 设置背景色
     $background_color = imagecolorallocate($im, $bgR, $bgG, $bgB);
     // 获取文字颜色
     $fgR = hexdec(substr($this->config['fontcolor'], 1, 2));
     $fgG = hexdec(substr($this->config['fontcolor'], 3, 2));
     $fgB = hexdec(substr($this->config['fontcolor'], 5));
     //list ($fgR,  $fgG,  $fgB)  =  $this->config['fontcolor'];
     // 设置字体颜色
     $font_color = imagecolorallocate($im, $fgR, $fgG, $fgB);
     // 检查是否需要将背景色透明
     if ($this->config["tbg"]) {
         ImageColorTransparent($im, $background_color);
     }
     // 每一行的行距变量
     $pheight = 0;
     // 输出 NFO 的内容
     for ($i = 0; $i < count($nfoa); $i++) {
         $pheight = $pheight + $this->config["line-space"];
         imagettftext($im, $this->config["font-size"], 0, $this->config["left"], $pheight, $font_color, $this->config['font-dir'] . $this->config["font-name"], $this->format_text($nfoa[$i]));
     }
     // 检查输出格式
     if ($pic_format == "png") {
         @imagepng($im, $this->config["server_save_dir"] . $this->config["pic_name"]);
     }
     if ($pic_format == "gif") {
         @imagegif($im, $this->config["server_save_dir"] . $this->config["pic_name"]);
     }
     if ($pic_format == "jpg") {
         //$this->config["pic_name"] = $this->config["prefix"]."_".md5(mktime()).".jpg";
         @imagejpeg($im, $this->config["server_save_dir"] . $this->config["pic_name"], $this->config["jepg_quality"]);
     }
     $this->color_total = ImageColorsTotal($im);
     // 释放图片流
     imagedestroy($im);
 }
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:53,代码来源:class.NFOPiC.php

示例15: makeIcon

 /**
  * Creates the icon file for the function getIcon()
  *
  * @param string $iconfile Original unprocessed Icon file, relative path to PATH_typo3
  * @param string $mode Mode string, eg. "deleted" or "futuretiming" determining how the icon will look
  * @param integer $user The number of the fe_group record uid if applicable
  * @param boolean $protectSection Flag determines if the protected-section icon should be applied.
  * @param string $absFile Absolute path to file from which to create the icon.
  * @param string $iconFileName_stateTagged The filename that this icon should have had, basically [icon base name]_[flags].[extension] - used for part of temporary filename
  * @return string Filename relative to PATH_typo3
  * @access private
  */
 public static function makeIcon($iconfile, $mode, $user, $protectSection, $absFile, $iconFileName_stateTagged)
 {
     $iconFileName = 'icon_' . GeneralUtility::shortMD5($iconfile . '|' . $mode . '|-' . $user . '|' . $protectSection) . '_' . $iconFileName_stateTagged . '.' . ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'] ? 'png' : 'gif');
     $mainpath = '../typo3temp/' . $iconFileName;
     $path = PATH_site . 'typo3temp/' . $iconFileName;
     if (file_exists(PATH_typo3 . 'icons/' . $iconFileName)) {
         // Returns if found in typo3/icons/
         return 'icons/' . $iconFileName;
     } elseif (file_exists($path)) {
         // Returns if found in ../typo3temp/icons/
         return $mainpath;
     } else {
         // Makes icon:
         if (file_exists($absFile)) {
             if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
                 // Create image pointer, if possible
                 $im = self::imagecreatefrom($absFile);
                 if ($im < 0) {
                     return $iconfile;
                 }
                 // Converting to gray scale, dimming the icon:
                 if ($mode == 'disabled' or $mode != 'futuretiming' && $mode != 'no_icon_found' && !(!$mode && $user)) {
                     $totalImageColors = ImageColorsTotal($im);
                     for ($c = 0; $c < $totalImageColors; $c++) {
                         $cols = ImageColorsForIndex($im, $c);
                         $newcol = round(($cols['red'] + $cols['green'] + $cols['blue']) / 3);
                         $lighten = $mode == 'disabled' ? 2.5 : 2;
                         $newcol = round(255 - (255 - $newcol) / $lighten);
                         ImageColorSet($im, $c, $newcol, $newcol, $newcol);
                     }
                 }
                 // Applying user icon, if there are access control on the item:
                 if ($user) {
                     if ($user < 100) {
                         // Apply user number only if lower than 100
                         $black = ImageColorAllocate($im, 0, 0, 0);
                         imagefilledrectangle($im, 0, 0, $user > 10 ? 9 : 5, 8, $black);
                         $white = ImageColorAllocate($im, 255, 255, 255);
                         imagestring($im, 1, 1, 1, $user, $white);
                     }
                     $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_group.gif');
                     if ($ol_im < 0) {
                         return $iconfile;
                     }
                     self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                 }
                 // Applying overlay based on mode:
                 if ($mode) {
                     unset($ol_im);
                     switch ($mode) {
                         case 'deleted':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_deleted.gif');
                             break;
                         case 'futuretiming':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_timing.gif');
                             break;
                         case 'timing':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_timing.gif');
                             break;
                         case 'hiddentiming':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_hidden_timing.gif');
                             break;
                         case 'no_icon_found':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_no_icon_found.gif');
                             break;
                         case 'disabled':
                             // is already greyed - nothing more
                             $ol_im = 0;
                             break;
                         case 'hidden':
                         default:
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_hidden.gif');
                     }
                     if ($ol_im < 0) {
                         return $iconfile;
                     }
                     if ($ol_im) {
                         self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                     }
                 }
                 // Protect-section icon:
                 if ($protectSection) {
                     $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_sub5.gif');
                     if ($ol_im < 0) {
                         return $iconfile;
                     }
                     self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                 }
//.........这里部分代码省略.........
开发者ID:khanhdeux,项目名称:typo3test,代码行数:101,代码来源:IconUtility.php


注:本文中的ImageColorsTotal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。