MImage_new2D (C Function)

is a library callback function that creates a new 2D image.


  • Used in C/C++ code in a library function called from the Wolfram Language.
  • A nonzero error code value will be returned if any of the specified arguments are invalid, or related arguments are not compatible, or if there is not sufficient memory.
  • Data type type can be one of the MImage_Type_Bit, MImage_Type_Byte, MImage_Type_Bit16, MImage_Type_Real32, or MImage_Type_Real.
  • Color space cs can be one of the MImage_CS_Gray, MImage_CS_RGB, MImage_CS_HSB, MImage_CS_CMYK, MImage_CS_XYZ, MImage_CS_LAB, MImage_CS_LCH, MImage_CS_LUV, or MImage_CS_Automatic.
  • Pixel values in the returned MImage are not initialized. Use MImage_setByte etc. to set the pixel values.


Basic Examples  (1)

This creates a 5×5 RGB MImage with interleaved pixels:

MImage I;
imagedata_t type = MImage_Type_Byte;
colorspace_t cs = MImage_CS_RGB;
mint width = 5, height = 5, channels = 3;
int err;
err = libData->MImage_new2D(width, height, channels, type, cs, TRUE, &I);