文字

Imagick::importImagePixels

(No version information available, might only be in Git)

Imagick::importImagePixelsImports image pixels

说明

public bool Imagick::importImagePixels ( int $x , int $y , int $width , int $height , string $map , int $storage , array $pixels )

Imports pixels from an array into an image. The map is usually 'RGB'. This method imposes the following constraints for the parameters: amount of pixels in the array must match width x height x length of the map. 此方法在Imagick基于ImageMagick 6.4.5以上版本编译时可用。

参数

x

The image x position

y

The image y position

width

The image width

height

The image height

map

Map of pixel ordering as a string. This can be for example RGB. The value can be any combination or order of R = red, G = green, B = blue, A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan, Y = yellow, M = magenta, K = black, I = intensity (for grayscale), P = pad.

storage

The pixel storage method. Refer to this list of pixel constants.

pixels

The array of pixels

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

范例

Example #1 Imagick::importImagePixels() example

<?php


$count  2000  3 ;

$pixels 
   
array_merge ( array_pad (array(),  $count 0 ),
               
array_pad (array(),  $count 255 ), 
               
array_pad (array(),  $count 0 ),
               
array_pad (array(),  $count 255 ),
               
array_pad (array(),  $count 0 ));


$width  $height  pow (( count ( $pixels ) /  3 ),  0.5 );


$im  = new  Imagick ();
$im -> newImage ( $width $height 'gray' );


$im -> importImagePixels ( 0 0 $width $height "RGB" Imagick :: PIXEL_CHAR $pixels );


$im -> setImageFormat ( 'jpg' );
header ( "Content-Type: image/jpg" );
echo 
$im ;

?>

以上例程的输出类似于:

Output of example : Imagick::importImagePixels()
上一篇: 下一篇: