public ray_gui(eRayVersion rayVersion) { InitializeComponent(); Text = rayVersion.ToString(); int side = DIM; Bitmap bmp = new Bitmap(side, side, PixelFormat.Format32bppArgb); Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, bmp.PixelFormat); // Declare an array to hold the bytes of the bitmap. int bytes = bmpData.Stride * bmp.Height; byte[] rgbValues = new byte[bytes]; //ray.Execute(rgbValues); if (rayVersion == eRayVersion.CUDA_const) { ray.Execute(rgbValues); } else if (rayVersion == eRayVersion.CUDA) { ray_noconst.Execute(rgbValues); } else if (rayVersion == eRayVersion.OpenCL_const) { ray_opencl_const.Execute(rgbValues); } else { ray_opencl.Execute(rgbValues); } // Get the address of the first line. IntPtr ptr = bmpData.Scan0; // Copy the RGB values back to the bitmap System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes); // Unlock the bits. bmp.UnlockBits(bmpData); pictureBox.Image = bmp; bDONE = true; if (CudafyModes.Target == eGPUType.Emulator) { timer1.Interval = 120000; } timer1.Start(); }
public ray_gui(eRayVersion rayVersion) { InitializeComponent(); Text = rayVersion.ToString(); int side = DIM; Bitmap bmp = new Bitmap(side, side, PixelFormat.Format32bppArgb); Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, bmp.PixelFormat); // Declare an array to hold the bytes of the bitmap. int bytes = bmpData.Stride * bmp.Height; byte[] rgbValues = new byte[bytes]; //ray.Execute(rgbValues); if (rayVersion == eRayVersion.CUDA_const) ray.Execute(rgbValues); else if (rayVersion == eRayVersion.CUDA) ray_noconst.Execute(rgbValues); else if (rayVersion == eRayVersion.OpenCL_const) ray_opencl_const.Execute(rgbValues); else ray_opencl.Execute(rgbValues); // Get the address of the first line. IntPtr ptr = bmpData.Scan0; // Copy the RGB values back to the bitmap System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes); // Unlock the bits. bmp.UnlockBits(bmpData); pictureBox.Image = bmp; bDONE = true; if (CudafyModes.Target == eGPUType.Emulator) timer1.Interval = 120000; timer1.Start(); }