Skip to content

gen_image1_rectGenImage1RectGenImage1Rectgen_image1_rectgen_image1_rectπŸ”—

Short descriptionπŸ”—

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

SignatureπŸ”—

gen_image1_rect( out image Image, pointer PixelPointer, extent.x Width, extent.y Height, integer VerticalPitch, integer HorizontalBitPitch, integer BitsPerPixel, string DoCopy, pointer ClearProc )void GenImage1Rect( HObject* Image, const HTuple& PixelPointer, const HTuple& Width, const HTuple& Height, const HTuple& VerticalPitch, const HTuple& HorizontalBitPitch, const HTuple& BitsPerPixel, const HTuple& DoCopy, const HTuple& ClearProc )static void HOperatorSet.GenImage1Rect( out HObject image, HTuple pixelPointer, HTuple width, HTuple height, HTuple verticalPitch, HTuple horizontalBitPitch, HTuple bitsPerPixel, HTuple doCopy, HTuple clearProc )def gen_image1_rect( pixel_pointer: int, width: int, height: int, vertical_pitch: int, horizontal_bit_pitch: int, bits_per_pixel: int, do_copy: str, clear_proc: int ) -> HObject

Herror gen_image1_rect( Hobject* Image, const Hlong PixelPointer, const Hlong Width, const Hlong Height, const Hlong VerticalPitch, const Hlong HorizontalBitPitch, const Hlong BitsPerPixel, const char* DoCopy, const Hlong ClearProc )

Herror T_gen_image1_rect( Hobject* Image, const Htuple PixelPointer, const Htuple Width, const Htuple Height, const Htuple VerticalPitch, const Htuple HorizontalBitPitch, const Htuple BitsPerPixel, const Htuple DoCopy, const Htuple ClearProc )

void HImage::GenImage1Rect( void* PixelPointer, Hlong Width, Hlong Height, Hlong VerticalPitch, Hlong HorizontalBitPitch, Hlong BitsPerPixel, const HString& DoCopy, void* ClearProc )

void HImage::GenImage1Rect( void* PixelPointer, Hlong Width, Hlong Height, Hlong VerticalPitch, Hlong HorizontalBitPitch, Hlong BitsPerPixel, const char* DoCopy, void* ClearProc )

void HImage::GenImage1Rect( void* PixelPointer, Hlong Width, Hlong Height, Hlong VerticalPitch, Hlong HorizontalBitPitch, Hlong BitsPerPixel, const wchar_t* DoCopy, void* ClearProc ) (Windows only)

void HImage.GenImage1Rect( IntPtr pixelPointer, int width, int height, int verticalPitch, int horizontalBitPitch, int bitsPerPixel, string doCopy, IntPtr clearProc )

DescriptionπŸ”—

The operator gen_image1_rectGenImage1Rect creates an image of size (VerticalPitchverticalPitchvertical_pitch / (HorizontalBitPitchhorizontalBitPitchhorizontal_bit_pitch/8)) * Heightheightheight. The pixels pointed to by PixelPointerpixelPointerpixel_pointer are stored line by line. Note that how to pass a pointer value depends on the used operator signature and programming environment. Make sure to pass the actual memory address where the image data is stored, not the address of a pointer variable. Care must be taken not to truncate 64-bit pointers on 64-bit architectures.

VerticalPitchverticalPitchvertical_pitch 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 is VerticalPitchverticalPitchvertical_pitch / (HorizontalBitPitchhorizontalBitPitchhorizontal_bit_pitch / 8), its height is Heightheightheight. The domain of the output image Imageimageimage is a rectangle of the size Widthwidthwidth * Heightheightheight. The parameter HorizontalBitPitchhorizontalBitPitchhorizontal_bit_pitch is the horizontal distance (in bits) between two neighboring pixels. BitsPerPixelbitsPerPixelbits_per_pixel is the number of used bits per pixel.

If DoCopydoCopydo_copy is set 'true'"true", the image data pointed to by PixelPointerpixelPointerpixel_pointer 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 PixelPointerpixelPointerpixel_pointer points to must be released when deleting the object Imageimageimage. This is done by the procedure ClearProcclearProcclear_proc provided by the caller. This procedure must have the following signature

      void ClearProc(void* ptr);

and will be called using __cdecl calling convention when deleting Imageimageimage. 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 PixelPointerpixelPointerpixel_pointer the pointer has to be passed to the procedure depending on the used operator signature and programming environment. If DoCopydoCopydo_copy is 'true'"true" then ClearProcclearProcclear_proc is irrelevant. The operator gen_image1_rectGenImage1Rect is symmetrical to get_image_pointer1_rectGetImagePointer1Rect.

AttentionπŸ”—

gen_image1_rectGenImage1Rect does not check whether the PixelPointerpixelPointerpixel_pointer is valid or not. Thus, it must be ensured by the user that it is valid. Otherwise, the program may crash!

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

ParametersπŸ”—

Imageimageimage (output_object) image β†’ object (byte / uint2 / int4)HObject (byte / uint2 / int4)HImage (byte / uint2 / int4)HObject (byte / uint2 / int4)Hobject * (byte / uint2 / int4)

Created HALCON image.

PixelPointerpixelPointerpixel_pointer (input_control) pointer β†’ (integer)HTuple (Hlong)HTuple (IntPtr)intHtuple (Hlong)

Pointer to the first pixel.

Widthwidthwidth (input_control) extent.x β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Width of the image.

Default: 512512
Suggested values: 128, 256, 512, 1024128, 256, 512, 1024
Value range: 1 ≀ Width (lin)
Minimum increment: 1
Recommended increment: 10

Heightheightheight (input_control) extent.y β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of the image.

Default: 512512
Suggested values: 128, 256, 512, 1024128, 256, 512, 1024
Value range: 1 ≀ Height (lin)
Minimum increment: 1
Recommended increment: 10

VerticalPitchverticalPitchvertical_pitch (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

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)

HorizontalBitPitchhorizontalBitPitchhorizontal_bit_pitch (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Distance between two neighboring pixels in bits .

Default: 88
List of values: 8, 16, 328, 16, 32

BitsPerPixelbitsPerPixelbits_per_pixel (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Number of used bits per pixel.

Default: 88
List of values: 8, 9, 10, 11, 12, 13, 14, 15, 16, 328, 9, 10, 11, 12, 13, 14, 15, 16, 32
Restriction: BitsPerPixel <= HorizontalBitPitch

DoCopydoCopydo_copy (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Copy image data.

Default: 'false'"false"
Suggested values: 'true', 'false'"true", "false"

ClearProcclearProcclear_proc (input_control) pointer β†’ (integer)HTuple (Hlong)HTuple (IntPtr)intHtuple (Hlong)

Pointer to the procedure releasing the memory of the image when deleting the object.

Default: 00

ExampleπŸ”—

(C)

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,(Hlong)image,400,480,640,8,8,'false',(long)free)\;
}

ResultπŸ”—

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

Combinations with other operatorsπŸ”—

Combinations

Possible successors

get_image_pointer1_rectGetImagePointer1Rect

Alternatives

gen_image1GenImage1, gen_image1_externGenImage1Extern, gen_image_constGenImageConst

See also

get_image_pointer1_rectGetImagePointer1Rect

ModuleπŸ”—

Foundation