版本:IMAQ vision6.0
函数:
int = imaqGetImageInfo(const Image* image, ImageInfo* info)
参数:
image:输入图像,类型可以是:IMAQ_IMAGE_U8, IMAQ_IMAGE_I16, IMAQ_IMAGE_SGL, IMAQ_IMAGE_COMPLEX, IMAQ_IMAGE_RGB, IMAQ_IMAGE_HSL info:返回信息 ImageInfo 结构体: typedef struct ImageInfo_struct { CalibrationUnit imageUnit; // If you set calibration information with imaqSetSimpleCalibrationInfo(), imageUnit is the calibration unit. float stepX; // If you set calibration information with imaqSetSimpleCalibrationInfo(), stepX is the distance in the calibration unit between two pixels in the x direction. float stepY; // If you set calibration information with imaqSetSimpleCalibrationInfo(), stepY is the distance in the calibration unit between two pixels in the y direction. ImageType imageType; // The type of the image. int xRes; // The number of columns in the image. int yRes; // The number of rows in the image. int xOffset; // If you set mask offset information with imaqSetMaskOffset(), xOffset is the offset of the mask origin in the x direction. int yOffset; // If you set mask offset information with imaqSetMaskOffset(), yOffset is the offset of the mask origin in the y direction. int border; // The number of border pixels around the image. int pixelsPerLine; // The number of pixels stored for each line of the image. void* reserved0; // This element is reserved. void* reserved1; // This element is reserved. void* imageStart; // A pointer to pixel (0,0). } ImageInfo;
作用:
返回图像的大小、边框、类型、校准和内存布局等信息。
示例:
返回图像 srcImage 的长宽信息:
static Image *srcImage; srcImage = imaqCreateImage (IMAQ_IMAGE_U8, 2); ImageInfo imageInfo; imaqGetImageInfo(srcImage, &imageInfo); width = imageInfo.yRes; // 宽 height = imageInfo.xRes; // 长
或者用另一个获取图像尺寸大小的函数 imaqGetImageSize ,一行代码搞定:
imaqGetImageSize(srcImage, &width, &height);