I have an image stored in a cuda unsigned char array, but I am not sure how to print it. Please help.
cudaChannelFormatDesc desc;
desc = cudaCreateChannelDesc<unsigned char>();
cutilSafeCall(cudaMallocArray(&array, &desc, imWidth, imHeight));
cutilSafeCall(cudaMemcpyToArray(array, 0, 0, pixels, imWidth * imHeight, cudaMemcpyHostToDevice));
memset(pixels, 0x0, imWidth * imHeight);
printf("Reading image: bicol.pgm\n");
const char* image_filename = "bicol.pgm";
char* image_path = cutFindFilePath(image_filename, loc_exec);
if (image_path == 0)
{
printf( "Reading image failed.\n");
exit(EXIT_FAILURE);
}
if (cutLoadPGMub(image_filename, &pixels, &imWidth, &imHeight) != CUTTrue)
{
printf("Failed to load image file: %s\n", image_filename);
}
for(int i=0; i<imWidth * imHeight;i++)
printf("%c", array[i]);