// 2D image
unsigned short* pDeviceImageData;
cudaMalloc(&pDeviceImageData, nImgHeight*nImgWidth*sizeof(unsigned short));
cudaError_t cudaerror = cudaSuccess;
cudaerror = cudaMemcpy(pDeviceImageData, pImageDate, nImgHeight*nImgWidth*sizeof(unsigned short), cudaMemcpyHostToDevice);
if (cudaSuccess != cudaerror)
{
return -1;
}
// 3D image or amount of images
cudaPitchedPtr pDeviceImage;
cudaExtent extent = make_cudaExtent(nImgWidth * sizeof(unsigned short), nImgHeight, 1);
cudaError_t cudaerror = cudaSuccess;
cudaerror = cudaMalloc3D(&pDeviceImage, extent);
cudaerror = cudaMemcpy2D( pDeviceImage.ptr, pDeviceImage.pitch,
pImageDate, nImgWidth*sizeof(unsigned short), nImgWidth*sizeof(float), nImgHeight, cudaMemcpyHostToDevice );
if (cudaSuccess != cudaerror)
{
return -1;
}