Create an image from a pointer on the pixels with storage management.
The operator create_dimagecreates an image of the size Width * Height. The pixels in PixelPointer are stored line-sequentially. The type of the given pixels (PixelPointer) must correspond to (Type). Since the type of the parameter PixelPointer is generic (long) a cast must be used for the call.
The memory for the new image is not newly allocated by HORUS contrary to create_image, and thus is not copied either. This means that the memory space that PixelPointer points to must be released when deleting the object Image. This is done by the procedure ClearProc provided by the caller. This procedure must have the following signature:
void ClearProc(void* ptr);
It is called when deleting Image. If the memory shall not be released (in the case of frame grabbers or static memory) a procedure "without trunk" or the NULL-Pointer can be passed. Analogous to the parameter PixelPointer the pointer has to be passed to the procedure by casting it to long.
Image (output_object) |
image -> object |
Created HORUS image. |
Type (input_control) |
string -> string |
Pixel type | |
Default value: 'byte' | |
List of values: 'int1', 'int2', 'int4', 'byte', 'real', 'direction', 'cyclic' |
Width (input_control) |
extent.x -> integer |
Width of image | |
Default value: 512 | |
Suggested values: 128, 256, 512, 1024 | |
Range of values: 1 <= Width <= 512 (lin) | |
Minimum increment: 1 | |
Recommended increment: 10 | |
Restriction: Width >= 1 |
Height (input_control) |
extent.y -> integer |
Height of image | |
Default value: 512 | |
Suggested values: 128, 256, 512, 1024 | |
Range of values: 1 <= Height <= 512 (lin) | |
Minimum increment: 1 | |
Recommended increment: 10 | |
Restriction: Height >= 1 |
PixelPointer (input_control) |
integer -> integer |
Pointer to the first gray value |
ClearProc (input_control) |
integer -> integer |
Pointer to the procedure re-releasing the memory of the image when deleting the object. | |
Default value: 0 |
void NewImage(ObjType *new) { unsigned char *image; int r,c; image = malloc(768*525); for (r=0; r<525; r++) for (c=0; c<768; c++) image[r*768+c] = c % 255; create_dimage(new,"byte",768,525,(long)image,(long)free); }
The operator create_dimage returns the value TRUE if the parameter values are correct. Otherwise an exception is raised.
create_image, new_image__, get_image_pointer__
reduce_domain, paint_grey__, paint_region__, set_greyval__