contents   index   previous   next



GD copy()

syntax:

gd.copy(source, dstX, dstY, srcX, srcY, width,

        height)

gd.copy(source, dstPoint, srcPoint, width,

        height)

where:

source - A gd object to copy from

 

dstX - Horizontal destination pixel in current object

 

dstY - Vertical destination pixel in current object

 

dstPoint - Destination pixel in current object.

 

srcX - Horizontal source pixel in source object

 

srcY - Vertical source pixel in source object

 

srcPoint - Source pixel in source object.

 

width - Width of section to copy

 

height - Height of section to copy

 

return:

void.

 

description:

This method copies a section from one GD image to another. The portion of source, starting at the specified point (which is the upper-left corner of the region) and extending width and height in either direction. This region is then copied to the current GD object at the specified location (which is again the upper-left corner of the region). In copying the region, this method attempts to preserve the colors of the original source as best as possible. The method first tries calling colorExact() on the current image, and if that doesn't work then colorAllocate(), and finally if that fails, then colorClosest(). If you specify the same source image as the current image, then the method will work appropriately as long as the regions to not overlap. If they do, then the result is undefined.

 

see:

#link <gd>, GD copyResized()

 

example:

// Copy top-left 16x16 from "test.gif"

// while attempting to preserve

// necessary colors.

var source = GD.fromGif("test.gif");

var dest = new GD( 16, 16 );

dest.copy( source, [0,0], [0,0], 16, 16 );

 


GD copyResized()