How do I get a Rhino image buffer data in C++?

I am building an output buffer via CUDA and I am trying to get a Rhino image buffer data to “see” this data. As I understand the most straight-away but perhaps slow method is to copy pixel by pixel from the one buffer (CUDA device) to the Rhino buffer.

			for (int i = 0; i < num_pixels; ++i) {
				const uchar4 pixel = cuda_buffer_data[i];
				const int x = i % width;
				const int y = (num_pixels - i - 1) / width; // Reverse the vertical coordinate due to top-down pixel ordering

				float fColor[4];
				fColor[0] = pixel.x;
				fColor[1] = pixel.y;
				fColor[2] = pixel.z;
				fColor[3] = pixel.w;
				// Assuming pChannel is a color channel
				pChannel->SetValue(x, y, ComponentOrder::RGBA, fColor); // Set the pixel value in the Rhino SDK image buffer

Are there any other options?

@jeff - is this something you can help with?

Rhino 7 SR29 2023-4-17 (Rhino 7, 7.29.23107.03001)
win10 64bit
Rhino’s SystemInfo:

Rhino 7 SR29 2023-4-17 (Rhino 7, 7.29.23107.03001, Git hash:master @ 5f05ef3a2eea3d910c4c2fb79ccc75b413d33ca7)
License type: Commercial, build 2023-04-17
License details: QWERTY

Windows 10 (10.0.19045 SR0.0) or greater (Physical RAM: 16Gb)
Rhino’s SystemInfo:
Computer platform: DESKTOP 

Standard graphics configuration.
  Primary display and OpenGL: NVIDIA GeForce RTX 3050 (NVidia) Memory: 8GB, Driver date: 4-25-2023 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 531.79
    > Accelerated graphics device with 4 adapter port(s)
        - Windows Main Display attached to adapter port #0
        - Secondary monitor attached to adapter port #1

OpenGL Settings
  Safe mode: Off
  Use accelerated hardware modes: On
  Redraw scene when viewports are exposed: On
  Graphics level being used: OpenGL 4.6 (primary GPU's maximum)
  Anti-alias mode: 4x
  Mip Map Filtering: Linear
  Anisotropic Filtering Mode: High
  Vendor Name: NVIDIA Corporation
  Render version: 4.6
  Shading Language: 4.60 NVIDIA
  Driver Date: 4-25-2023
  Driver Version:
  Maximum Texture size: 32768 x 32768
  Z-Buffer depth: 24 bits
  Maximum Viewport size: 32768 x 32768
  Total Video Memory: 8 GB

Rhino plugins that do not ship with Rhino
  C:\Users\QWERTY\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\ColorPicker\6.0.0\ColorPicker.rhp	"ColorPicker"	

Rhino plugins that ship with Rhino
  C:\Program Files\Rhino 7\Plug-ins\Commands.rhp	"Commands"	7.29.23107.3001
  C:\Program Files\Rhino 7\Plug-ins\rdk.rhp	"Renderer Development Kit"	
  C:\Program Files\Rhino 7\Plug-ins\rdk_etoui.rhp	"RDK_EtoUI"	7.29.23107.3001
  C:\Program Files\Rhino 7\Plug-ins\rdk_ui.rhp	"Renderer Development Kit UI"	
  C:\Program Files\Rhino 7\Plug-ins\NamedSnapshots.rhp	"Snapshots"	
  C:\Program Files\Rhino 7\Plug-ins\Toolbars\Toolbars.rhp	"Toolbars"	7.29.23107.3001
  C:\Program Files\Rhino 7\Plug-ins\3dxrhino.rhp	"3Dconnexion 3D Mouse"	
  C:\Program Files\Rhino 7\Plug-ins\Displacement.rhp	"Displacement"

What is that data format for cuda_buffer_data? If it’s not 8 bits per channel, then there is no way to do this any differently than what you show here…because the conversion is going to obviously have to take place in order to pack things into a 32bit, 4 channel format.

If cuda_buffer_data is already in a packed 32bit, 4 channel format, then you could just move it all into a CRhinoDib, making sure size and alignments are all correct (based on Width and Height), and then use the display pipeline’s method CopyToBackBuffer(dib) …again assuming cuda_buffer_data size and format all matches the current back buffer’s size and format.

Just know that on Windows this will require that you store things into cuda_buffer_data in BGRA byte order.

If this isn’t what you’re requesting, then I’ll need more information and specifics.