Herror ::gen_image1_extern (
    Hobject *Image,
    const HTuple &Type,
    const HTuple &Width,
    const HTuple &Height,
    const HTuple &PixelPointer,
    const HTuple &ClearProc
)
HImage HImage::GenImage1Extern (
    const HTuple &Type,
    const HTuple &Width,
    const HTuple &Height,
    const HTuple &PixelPointer,
    const HTuple &ClearProc
)

Create an image from a pointer on the pixels with storage management.

The operator ::gen_image1_extern creates 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 HALCON , contrary to ::gen_image1, and thus is not copied either. This means that the memory space that PixelPointer points to must be released by 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.


Parameters

Image (output_object)
image -> Hobject * : HImage
Created HALCON image.

Type (input_control)
string -> HTuple.char *
Pixel type.
Default value: 'byte'
List of values: 'int1', 'int2', 'int4', 'byte', 'real', 'direction', 'cyclic'

Width (input_control)
extent.x -> HTuple.long
Width of 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 -> HTuple.long
Height of 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

PixelPointer (input_control)
integer -> HTuple.long
Pointer to the first gray value.

ClearProc (input_control)
integer -> HTuple.long
Pointer to the procedure re-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_extern(new,"byte",640,480,(long)image,(long)free);
}

Result

The operator ::gen_image1_extern returns the value H_MSG_TRUE if the parameter values are correct. Otherwise an exception handling is raised.


Alternatives

::gen_image1, ::gen_image_const, ::get_image_pointer1


See also

::reduce_domain, ::paint_gray, ::paint_region, ::set_grayval


Module

Image / region / XLD management



Copyright © 1996-2002 MVTec Software GmbH