Prev
MagickWand For PHP
Manual


Next

MagickConstituteImage

MagickConstituteImage -- adds an image to the MagickWand comprised of the the pixel data you supply

Description

bool MagickConstituteImage( MagickWand mgck_wnd, float columns, float rows, string map, int storage_type, array pixel_array )

Adds an image to the MagickWand comprised of the the pixel data you supply. MagickConstituteImage() is called as follows: MagickConstituteImage( $mgck_wnd, 4, 8, 'GRB', MW_CharPixel, array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //pixels (0,0) (1,0) (2,0) (3,0) 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, //pixels (0,1) (1,1) (2,1) (3,1) 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, //pixels (0,2) (1,2) (2,2) (3,2) 128,128,128, 128,128,128, 128,128,128, 128,128,128, //pixels (0,3) (1,3) (2,3) (3,3) 160,160,160, 160,160,160, 160,160,160, 160,160,160, //pixels (0,4) (1,4) (2,4) (3,4) 192,192,192, 192,192,192, 192,192,192, 192,192,192, //pixels (0,5) (1,5) (2,5) (3,5) 224,224,224, 224,224,224, 224,224,224, 224,224,224, //pixels (0,6) (1,6) (2,6) (3,6) 255,255,255, 255,255,255, 255,255,255, 255,255,255 //pixels (0,7) (1,7) (2,7) (3,7) ) ); The above would create a RGB image, ('GRB' is just 'RGB' jumbled -- the order doesn't matter), that is 4 pixels wide, by 8 pixels high, with the first row of pixels all black, and the intervening rows increasing in color value to the last all white row. The columns and rows parameters specify the width and height (respectively) of the image to be constituted. The map string parameter specifies the type and ordering of the pixel color component data in the pixel_array. It 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 For each letter in map, there must be a corresponding color component value, for each pixel in the image, in pixel_array. So, the size of pixel_array must be EXACTLY: columns * rows * strlen(map) In the above example, this would be 96 (i.e., 4 * 8 * 3). storage_type must be a StorageType constant, one of the following: MW_CharPixel MW_ShortPixel MW_IntegerPixel MW_LongPixel MW_FloatPixel MW_DoublePixel MW_FloatPixel and MW_DoublePixel StorageType constants require the pixel color component values to be normalized [0..1]. For the other StorageType constants, (MW_CharPixel, MW_ShortPixel, MW_IntegerPixel, MW_LongPixel), the pixel color component values in pixel_array must be in the range [0..Max], where Max is the maximum value of the (unsigned) C datatype referenced by the constant's name. So, according to the ANSI C standard, StorageType C Type Ansi C minimum maximum value ------------------------------------------------------ MW_CharPixel char 255 MW_ShortPixel short 65535 MW_IntegerPixel integer 65535 MW_LongPixel long 4294967295 Please note, it is probably your best bet to just use MW_CharPixel or MW_ShortPixel in most cases, unless you need very high granularity in your color selections, (as in print work). The pixel_array is an array of numbers representing the pixel color component data for each pixel in the image you wish to create. The pixel data must be in scanline (left-to-right) order, top-to-bottom. The pixel data can be long, (MW_CharPixel, MW_ShortPixel, MW_IntegerPixel, MW_LongPixel), or double, (MW_FloatPixel, MW_DoublePixel).


A description of each parameter follows:

mgck_wnd A MagickWand resource
columns Width in pixels of the image to be created.
rows Height in pixels of the image to be created.
map This string reflects the expected types and ordering of the pixel color component data array. See above.
storage_type A StorageType constant; defines the numerical C datatype of the pixel color component data in pixel_array.
pixel_array This array contains the values of the pixel color components, (for each pixel in the image), as defined by map and storage_type.
The length of this array varies depending on the values of columns, rows, and map, and MUST always equal:
columns * rows * strlen(map)


Prev
MagickCompositeImage
Up Next
MagickContrastImage