bool GrayDataToHalcon(HObject *ho_Image, int width, int height)
{ unsigned char *GrayData = new unsigned char [width * height]; for(int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { GrayData[width * (height - i - 1) + j] = ImageBuffer[width * i + j]; } } GenImage1(ho_Image, "byte", width, height, (Hlong)(GrayData)); return true; } BOOL CaiSeDataToHalcon(HObject *ho_Image, int width, int height) { unsigned char *red = new unsigned char[width * height]; unsigned char *green = new unsigned char[width * height]; unsigned char *blue = new unsigned char[width * height]; if (red == NULL || green == NULL || blue == NULL) { return false; } for (int r = 0; r < height; r++) { for (int c = 0 ; c < width; c++) { blue[(height - r - 1) * width + c] = ImageBuffer[r * width * 3 + 3 * c]; green[(height - r - 1) * width + c] = ImageBuffer[r * width * 3 + 3 * c + 1]; red[(height - r - 1) * width + c] = ImageBuffer[r * width*3 + 3 * c + 2]; } } GenImage3(ho_Image, "byte", width, height, (Hlong)red, (Hlong)green, (Hlong)blue); delete [] red; delete [] green; delete [] blue; return true; }
