本文整理汇总了C#中ManagedCuda.NPP.NPPImage_8uC4.CopyToDevice方法的典型用法代码示例。如果您正苦于以下问题:C# NPPImage_8uC4.CopyToDevice方法的具体用法?C# NPPImage_8uC4.CopyToDevice怎么用?C# NPPImage_8uC4.CopyToDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManagedCuda.NPP.NPPImage_8uC4
的用法示例。
在下文中一共展示了NPPImage_8uC4.CopyToDevice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CudaHelper
private ManagedCuda.NPP.NPPImage_8uC4 CudaHelper(Bitmap map)
{
NppiSize size = new NppiSize(map.Width, map.Height);
ManagedCuda.NPP.NPPImage_8uC4 source = new NPPImage_8uC4(size);
source.CopyToDevice(map);
return source;
}
示例2: btn_open_Click
private void btn_open_Click(object sender, EventArgs e)
{
if (!_nppOK) return;
CleanUp();
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Images|*.jpg;*.bmp;*.png;*.tif";
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
Bitmap src = new Bitmap(ofd.FileName);
switch (src.PixelFormat)
{
case PixelFormat.Format24bppRgb:
_colorChannels = 3;
break;
case PixelFormat.Format32bppArgb:
_colorChannels = 4;
break;
case PixelFormat.Format32bppRgb:
_colorChannels = 4;
break;
case PixelFormat.Format8bppIndexed:
_colorChannels = 1;
break;
default:
_colorChannels = 0;
txt_info.AppendText(ofd.FileName + " has an unsupported pixel format.\n");
break;
}
try
{
switch (_colorChannels)
{
case 1:
//Allocate memory on device for one channel images...
src_c1 = new NPPImage_8uC1(src.Width, src.Height);
dest_c1 = new NPPImage_8uC1(src.Width, src.Height);
src_c1.CopyToDevice(src);
txt_info.AppendText("Info: Loaded image '" + ofd.FileName + "' succesfully (Size: " + src.Width.ToString() + " x " + src.Height.ToString() + ", color channels: " + _colorChannels.ToString() + ")\n");
break;
case 3:
//As of version 5, NPP has new histogram and LUT functions for three channel images, no more need to convert first to 4 channels.
//Allocate memory on device for four channel images...
src_c3 = new NPPImage_8uC3(src.Width, src.Height);
dest_c3 = new NPPImage_8uC3(src.Width, src.Height);
//Fill 3 channel image in device memory
src_c3.CopyToDevice(src);
txt_info.AppendText("Info: Loaded image '" + ofd.FileName + "' succesfully (Size: " + src.Width.ToString() + " x " + src.Height.ToString() + ", color channels: " + _colorChannels.ToString() + ")\n");
break;
case 4:
//Allocate memory on device for four channel images...
src_c4 = new NPPImage_8uC4(src.Width, src.Height);
dest_c4 = new NPPImage_8uC4(src.Width, src.Height);
src_c4.CopyToDevice(src);
txt_info.AppendText("Info: Loaded image '" + ofd.FileName + "' succesfully (Size: " + src.Width.ToString() + " x " + src.Height.ToString() + ", color channels: " + _colorChannels.ToString() + ")\n");
break;
}
}
catch (Exception ex)
{
if (ex is NPPException)
{
txt_info.AppendText("NPPException: " + ex.Message + "\n");
CleanUp();
}
else if (ex is CudaException)
{
txt_info.AppendText("CudaException: " + ex.Message + "\n");
CleanUp();
}
else throw;
}
//Show original image
pictureBox_src.Image = src;
}