Prev
MagickWand For PHP
Manual


Next

MagickSetImagePixels

MagickSetImagePixels -- accepts pixel data and stores it in the current active image, at the location you specify

Description

bool MagickSetImagePixels( MagickWand mgck_wnd, int x_offset, int y_offset, float columns, float rows, string map, int storage_type, array pixel_array )

Accepts pixel data and stores it in the current active image, at the location you specify. MagickSetImagePixels() is called as follows: MagickSetImagePixels( $mgck_wnd, 34, 77, 4, 8, 'BRG', MW_CharPixel, array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //pixels (34,77) (35,77) (36,77) (37,77) 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, //pixels (34,78) (35,78) (36,78) (37,78) 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, //pixels (34,79) (35,79) (36,79) (37,79) 128,128,128, 128,128,128, 128,128,128, 128,128,128, //pixels (34,80) (35,80) (36,80) (37,80) 160,160,160, 160,160,160, 160,160,160, 160,160,160, //pixels (34,81) (35,81) (36,81) (37,81) 192,192,192, 192,192,192, 192,192,192, 192,192,192, //pixels (34,82) (35,82) (36,82) (37,82) 224,224,224, 224,224,224, 224,224,224, 224,224,224, //pixels (34,83) (35,83) (36,83) (37,83) 255,255,255, 255,255,255, 255,255,255, 255,255,255 //pixels (34,84) (35,84) (36,84) (37,84) ) ); The above would insert a 4 pixel wide by 8 pixel high pixel area into the current active image at point (34, 77). The area would be made up of RGB pixel data, ('BRG' is just 'RGB' jumbled -- the order doesn't matter), with the first row of pixels all black, and the intervening rows increasing in color value to the last all white row. The x_offset and y_offset parameters indicate the (x, y) coordinates of the point where the pixel data is to be inserted. The columns and rows parameters specify the width and height (respectively) of the area to be inserted. 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 region being inserted, 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 area you wish to insert. 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
x_offset The x ordinate of the pixel at the top left corner of the area where you wish to insert the pixels
y_offset The y ordinate of the pixel at the top left corner of the area where you wish to insert the pixels
columns The width of the pixel region you wish to insert
rows The height of the pixel region you wish to insert
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 to be returned.
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
MagickSetImageOption
Up Next
MagickSetImageProfile