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


PHP WideImage::createTrueColorImage方法代码示例

本文整理汇总了PHP中WideImage::createTrueColorImage方法的典型用法代码示例。如果您正苦于以下问题:PHP WideImage::createTrueColorImage方法的具体用法?PHP WideImage::createTrueColorImage怎么用?PHP WideImage::createTrueColorImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WideImage的用法示例。


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

示例1: testMagicCallDrawRectangle

 function testMagicCallDrawRectangle()
 {
     $img = WideImage::createTrueColorImage(10, 10);
     $canvas = $img->getCanvas();
     $canvas->filledRectangle(1, 1, 5, 5, $img->allocateColorAlpha(255, 0, 0, 64));
     $this->assertRGBAt($img, 3, 3, array('red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 64));
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:7,代码来源:CanvasTest.php

示例2: execute

 /**
  * Returns an image with a resized canvas
  * 
  * The image is filled with $color. Use $scale to determine, when to resize.
  *
  * @param WideImage_Image $img
  * @param smart_coordinate $width
  * @param smart_coordinate $height
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param int $color
  * @param string $scale 'up', 'down', 'any'
  * @return WideImage_Image
  */
 function execute($img, $width, $height, $left, $top, $color, $scale)
 {
     $new_width = WideImage_Coordinate::fix($width, $img->getWidth());
     $new_height = WideImage_Coordinate::fix($width, $img->getHeight());
     if ($scale == 'down') {
         $new_width = min($new_width, $img->getWidth());
         $new_height = min($new_height, $img->getHeight());
     } elseif ($scale == 'up') {
         $new_width = max($new_width, $img->getWidth());
         $new_height = max($new_height, $img->getHeight());
     }
     $new = WideImage::createTrueColorImage($new_width, $new_height);
     if ($img->isTrueColor()) {
         if ($color === null) {
             $color = $new->allocateColorAlpha(0, 0, 0, 127);
         }
     } else {
         imagepalettecopy($new->getHandle(), $img->getHandle());
         if ($color === null) {
             if ($img->isTransparent()) {
                 $new->copyTransparencyFrom($img);
                 $tc_rgb = $img->getTransparentColorRGB();
                 $color = $new->allocateColorAlpha($tc_rgb);
             } else {
                 $color = $new->allocateColorAlpha(255, 0, 127, 127);
             }
             imagecolortransparent($new->getHandle(), $color);
         }
     }
     $new->fill(0, 0, $color);
     $x = WideImage_Coordinate::fix($left, $new->getWidth(), $img->getWidth());
     $y = WideImage_Coordinate::fix($top, $new->getHeight(), $img->getHeight());
     $img->copyTo($new, $x, $y);
     return $new;
 }
开发者ID:victorborg3s,项目名称:kimera,代码行数:49,代码来源:ResizeCanvas.php

示例3: testResizeCanvasPositionsCorner

 function testResizeCanvasPositionsCorner()
 {
     $img = WideImage::createTrueColorImage(20, 20);
     $black = $img->allocateColor(0, 0, 0);
     $white = $img->allocateColor(255, 255, 255);
     $img->fill(0, 0, $black);
     $res = $img->resizeCanvas(40, 40, 'bottom', 'right', $white);
     $this->assertRGBAt($res, 5, 5, $white);
     $this->assertRGBAt($res, 35, 35, $black);
     $this->assertRGBAt($res, 5, 35, $white);
     $this->assertRGBAt($res, 35, 5, $white);
 }
开发者ID:AmandaNatallie,项目名称:RequisitosPA,代码行数:12,代码来源:ResizeCanvasTest.php

示例4: asTrueColor

 /**
  * (non-PHPdoc).
  *
  * @see WideImage_Image#asTrueColor()
  */
 public function asTrueColor()
 {
     $width = $this->getWidth();
     $height = $this->getHeight();
     $new = WideImage::createTrueColorImage($width, $height);
     if ($this->isTransparent()) {
         $new->copyTransparencyFrom($this);
     }
     if (!imagecopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height)) {
         throw new WideImage_GDFunctionResultException('imagecopy() returned false');
     }
     return $new;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:18,代码来源:PaletteImage.php

示例5: execute

 /**
  * Returns an image with a resized canvas
  * 
  * The image is filled with $color. Use $scale to determine, when to resize.
  *
  * @param WideImage_Image $img
  * @param smart_coordinate $width
  * @param smart_coordinate $height
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param int $color
  * @param string $scale 'up', 'down', 'any'
  * @param boolean $merge
  * @return WideImage_Image
  */
 function execute($img, $width, $height, $left, $top, $color, $scale, $merge)
 {
     $new_width = WideImage_Coordinate::fix($width, $img->getWidth());
     $new_height = WideImage_Coordinate::fix($height, $img->getHeight());
     if ($scale == 'down') {
         $new_width = min($new_width, $img->getWidth());
         $new_height = min($new_height, $img->getHeight());
     } elseif ($scale == 'up') {
         $new_width = max($new_width, $img->getWidth());
         $new_height = max($new_height, $img->getHeight());
     }
     $new = WideImage::createTrueColorImage($new_width, $new_height);
     if ($img->isTrueColor()) {
         if ($color === null) {
             $color = $new->allocateColorAlpha(0, 0, 0, 127);
         }
     } else {
         imagepalettecopy($new->getHandle(), $img->getHandle());
         if ($img->isTransparent()) {
             $new->copyTransparencyFrom($img);
             $tc_rgb = $img->getTransparentColorRGB();
             $t_color = $new->allocateColorAlpha($tc_rgb);
         }
         if ($color === null) {
             if ($img->isTransparent()) {
                 $color = $t_color;
             } else {
                 $color = $new->allocateColorAlpha(255, 0, 127, 127);
             }
             imagecolortransparent($new->getHandle(), $color);
         }
     }
     $new->fill(0, 0, $color);
     $x = WideImage_Coordinate::fix($left, $new->getWidth(), $img->getWidth());
     $y = WideImage_Coordinate::fix($top, $new->getHeight(), $img->getHeight());
     // blending for truecolor images
     if ($img->isTrueColor()) {
         $new->alphaBlending($merge);
     }
     // not-blending for palette images
     if (!$merge && !$img->isTrueColor() && isset($t_color)) {
         $new->getCanvas()->filledRectangle($x, $y, $x + $img->getWidth(), $y + $img->getHeight(), $t_color);
     }
     $img->copyTo($new, $x, $y);
     return $new;
 }
开发者ID:mjrouser,项目名称:cityapi,代码行数:61,代码来源:WideImage_Operation_ResizeCanvas.php

示例6: execute

 /**
  * @param WideImage_Image $image
  * @param int $radius
  * @param int $color
  * @param int $smoothness
  * @return WideImage_Image
  */
 function execute($image, $radius, $color, $smoothness, $corners)
 {
     if ($smoothness < 1) {
         $sample_ratio = 1;
     } elseif ($smoothness > 16) {
         $sample_ratio = 16;
     } else {
         $sample_ratio = $smoothness;
     }
     $corner = WideImage::createTrueColorImage($radius * $sample_ratio, $radius * $sample_ratio);
     if ($color === null) {
         imagepalettecopy($corner->getHandle(), $image->getHandle());
         $bg_color = $corner->allocateColor(0, 0, 0);
         $corner->fill(0, 0, $bg_color);
         $fg_color = $corner->allocateColor(255, 255, 255);
         $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color);
         $corner = $corner->resize($radius, $radius);
         $result = $image->asTrueColor();
         $tc = $result->getTransparentColor();
         if ($tc == -1) {
             $tc = $result->allocateColorAlpha(255, 255, 255, 127);
             imagecolortransparent($result->getHandle(), $tc);
             $result->setTransparentColor($tc);
         }
         if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) {
             $result = $result->applyMask($corner, -1, -1);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) {
             $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) {
             $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) {
             $result = $result->applyMask($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100);
         }
         return $result;
     } else {
         $bg_color = $color;
         $corner->fill(0, 0, $bg_color);
         $fg_color = $corner->allocateColorAlpha(127, 127, 127, 127);
         $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color);
         $corner = $corner->resize($radius, $radius);
         $result = $image->copy();
         if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) {
             $result = $result->merge($corner, -1, -1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) {
             $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) {
             $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) {
             $result = $result->merge($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100);
         }
         return $result;
     }
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:72,代码来源:RoundCorners.php

示例7: rgb2hex

    //echo "Hex color: " .$color.'<br />';
} else {
    $hex = rgb2hex($color);
    //echo "RGB color: " . $color .'<br />Hex conversion: ' . $hex . '<br />';
}
//exit;
$rgb = hex2rgb($hex);
$im_handle = imagecreatefrompng('../img/icons/icon-arrow.png');
// 1. Load Image
$original = WideImage::load($im_handle);
// 2. Get Transparency Mask
$mask = $original->getMask();
// 3. Dispose Original
$original->destroy();
// 4. Create New Image
$colorized = WideImage::createTrueColorImage($mask->getWidth(), $mask->getHeight());
// 5. Colorize Image
$bg = $colorized->allocateColor($rgb[0], $rgb[1], $rgb[2]);
$colorized->fill(0, 0, $bg);
// 6. Apply Transparency Mask
$colorized = $colorized->applyMask($mask);
// 7. Dispose mask
$mask->destroy();
// 8a. Save colorized (Possible to incorporate caching here.)
//$colorized->save($new_image_name);
// 8b. Serve colorized
$colorized->output('png');
//echo rgb2hex($hex) . '<br />';
// 9. Dispose colorized
$colorized->destroy();
function hex2rgb($hex)
开发者ID:ehazell,项目名称:AWPF,代码行数:31,代码来源:linkarrow.php

示例8: normalize_bbox

<?php

include '../lib/WideImage.php';
$img = WideImage::createTrueColorImage(400, 200);
$canvas = $img->getCanvas();
$canvas->useFont('fonts/Vera.ttf', 36, $img->allocateColor(255, 0, 0));
$canvas->writeText('left', 'top', 'abc', 0);
$canvas->writeText('right', 'top', 'def', 15);
$canvas->writeText('right', 'bottom', 'ghi', 30);
$canvas->writeText('left', 'bottom', 'jkl', 45);
$canvas->writeText('center', 'center', 'mno', 60);
$img->output('png');
exit;
// Create a 300x150 image
$im = imagecreatetruecolor(600, 350);
$black = imagecolorallocate($im, 0, 0, 0);
$bgcolor = imagecolorallocate($im, 255, 255, 0);
// Set the background to be white
imagefilledrectangle($im, 0, 0, imagesx($im), imagesy($im), $bgcolor);
// Path to our font file
$font = './fonts/Vera.ttf';
$angle = 340;
$font_size = 20;
$text = 'jW| asdkasdlk alk,.,wedwer|w[r=?';
$text = '#j';
// First we create our bounding box
$bbox = imageftbbox($font_size, $angle, $font, $text);
function normalize_bbox($bbox)
{
    return array('up-left' => array('x' => $bbox[6], 'y' => $bbox[7]), 'up-right' => array('x' => $bbox[4], 'y' => $bbox[5]), 'down-left' => array('x' => $bbox[0], 'y' => $bbox[1]), 'down-right' => array('x' => $bbox[2], 'y' => $bbox[3]));
}
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:31,代码来源:font.php

示例9: testResizeWithoutParametersDoesNothing

 function testResizeWithoutParametersDoesNothing()
 {
     $img = WideImage::createTrueColorImage(70, 20);
     $res = $img->resize();
     $this->assertDimensions($res, $img->getWidth(), $img->getHeight());
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:6,代码来源:ResizeTest.php

示例10: asTrueColor

 /**
  * (non-PHPdoc)
  * @see WideImage_Image#asTrueColor()
  */
 function asTrueColor()
 {
     $width = $this->getWidth();
     $height = $this->getHeight();
     $new = WideImage::createTrueColorImage($width, $height);
     if ($this->isTransparent()) {
         $new->copyTransparencyFrom($this);
     }
     imageCopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height);
     return $new;
 }
开发者ID:victorborg3s,项目名称:kimera,代码行数:15,代码来源:PaletteImage.php

示例11: testFactories

 function testFactories()
 {
     $this->assertTrue(WideImage::createTrueColorImage(100, 100) instanceof WideImage_TrueColorImage);
     $this->assertTrue(WideImage::createPaletteImage(100, 100) instanceof WideImage_PaletteImage);
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:5,代码来源:ImageTest.php


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