c ++ – How can I create a Texture2D from a color data matrix?

I'm trying to make a simple engine with DirectX where you can draw on the screen with a draw function (x, y, r, g, b). The function sets the pixel to x, and to the color r, g, b. The engine has a parameter for the size of a pixel, which makes the engine look retro or low resolution.
My question is in the title. I would like to take a series of color data and paste it into a Texture2D that will then be processed on the screen, and I would appreciate someone telling me the correct direction of how I could do it in DirectX.