gen_image1_rect ( : Image : PixelPointer, Width, Height, VerticalPitch, HorizontalBitPitch, BitsPerPixel, DoCopy, ClearProc : )

Create an image with a rectangular domain from a pointer on the pixels (with storage management).

The operator gen_image1_rect creates an image of size (VerticalPitch/(HorizontalBitPitch / 8)) * Height. The pixels pointed to by PixelPointer are stored line by line. Since the type of the parameter PixelPointer is generic (long) a cast must be used for the call. VerticalPitch determines the distance (in bytes) between pixel m in row n and pixel m in row n+1 inside of memory. All rows of the 'input image' have the same vertical pitch. The width of the output image equals VerticalPitch / (HorizontalBitPitch / 8). The height of input and output image are equal. The domain of the output image Image is a rectangle of the size Width * Height. The parameter HorizontalBitPitch is the horizontal distance (in bits) between two neighbouring pixels. BitsPerPixel is the number of used bits per pixel.

If DoCopy is set 'true', the image data pointed to by PixelPointer is copied and memory for the new image is newly allocated by HALCON . Else the image data is not duplicated and 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. Analogously to the parameter PixelPointer the pointer has to be passed to the procedure by casting it to long. If DoCopy is 'true' then ClearProc is irrelevant. The operator gen_image1_rect is symmetrical to get_image_pointer1_rect.


Parameters

Image (output_object)
image -> object : byte / uint2 / int4
Created HALCON image.

PixelPointer (input_control)
integer -> integer
Pointer to the first pixel.

Width (input_control)
extent.x -> integer
Width of the image.
Default value: 512
Suggested values: 128, 256, 512, 1024
Typical range of values: 1 <= Width <= 512 (lin)
Minimum increment: 1
Recommended increment: 10
Restriction: Width >= 1

Height (input_control)
extent.y -> integer
Height of the image.
Default value: 512
Suggested values: 128, 256, 512, 1024
Typical range of values: 1 <= Height <= 512 (lin)
Minimum increment: 1
Recommended increment: 10
Restriction: Height >= 1

VerticalPitch (input_control)
integer -> integer
Distance (in bytes) between pixel m in row n and pixel m in row n+1 of the 'input image'.
Restriction: VerticalPitch >= (Width * (HorizontalBitPitch / 8))

HorizontalBitPitch (input_control)
integer -> integer
Distance between two neighbouring pixels in bits .
Default value: 8
List of values: 8, 16, 32

BitsPerPixel (input_control)
integer -> integer
Number of used bits per pixel.
Default value: 8
List of values: 8, 9, 10, 11, 12, 13, 14, 15, 16, 32
Restriction: BitsPerPixel <= HorizontalBitPitch

DoCopy (input_control)
string -> string
Copy image data.
Default value: 'false'
Suggested values: 'true', 'false'

ClearProc (input_control)
integer -> integer
Pointer to the procedure releasing the memory of the image when deleting the object.
Default value: 0


Example
void NewImage(Hobject *new)
{
  unsigned char       *image;
  int                 r,c;

  image = malloc(640*480);
  for (r=0; r<480; r++)
    for (c=0; c<640; c++)
      image[r*640+c] = c % 255;
  gen_image1_rect(new,(long)image,400,480,640,8,8,'false',(long)free);
}

Result

The operator gen_image1_rect returns the value 2 (H_MSG_TRUE) if the parameter values are correct. Otherwise an exception handling is raised.


Parallelization Information

gen_image1_rect is reentrant and processed without parallelization.


Possible Successors

get_image_pointer1_rect


Alternatives

gen_image1, gen_image1_extern


See also

get_image_pointer1_rect


Module

Image / region / XLD management



Copyright © 1996-2005 MVTec Software GmbH