<blockquote>
  <p>Digital painting and raster graphics software like Krita and Photoshop have a canvas where you can paint with brushes. From a programming perspective, how is this canvas rendered?</p>
</blockquote>

<p>I don't have access to the code of the programs you mentioned, so I can't tell how exactly they did this since there are usually multiple ways to solve a programming problem. However, I guess everybody with some graphics programming experience will immediately think of the solution @lightxbulb already mentioned in his comment because it is the simplest one.</p>

<p>Textures are just an array of color values and a graphics API like OpenGL expects you to upload them as such. So a possible solution would be to represent your modifiable canvas in memory in this form too. Every time a modification is made, you find the affected pixels in your array, adjust their color values, and upload the updated canvas as texture (or update the already existing one). Then you just draw a fullscreen (or any other size you like) quad and attach the texture to it. Simple as that.</p>

<blockquote>
  <p>Can it be included on a graphics pipeline like OpenGL?</p>
</blockquote>

<p>As you might already guess: Yes, you can do that. If you use the texture approach, you can do anything you can do with an ordinary texture in the graphics pipeline. If your intention is to include a canvas in a 3d game, then keep in mind that finding the pixel that should be modified gets a little bit more complicated due to the perspective projection. However, the rendering process stays the same.</p>

CC BY-SA 4.0
2020-06-09T12:34:56.660Z
I have little experience in graphics programming but seems a little hacky. It also seems easy so i guess its worth a try. I wonder what performance will it have. One critical component must be only updating the changed pixels instead of the whole canvas for each frame.
Burst
CC BY-SA 4.0
2020-06-09T12:49:02.970Z
The main performance problem in OpenGL is the texture update on the GPU side. But there exist some fast routes (search for "OpenGL buffer streaming" or "OpenGL Approaching zero driver overhead"). However, if you are just doing a regular paint program, this is not worth optimizing since you have "plenty" of time.  Also, I wouldn't call it hacky since it is a perfectly valid usage of the render pipeline. - Updating single pixels is also not that much of a problem because there are special OpenGL functions for that.
wychmaster
CC BY-SA 4.0
2020-06-09T07:45:10.237Z
2020-06-09T07:45:10.237Z
wychmaster
<p>Digital painting and raster graphics software like <a href="https://krita.org/en/" rel="nofollow noreferrer">Krita</a> and <a href="https://www.adobe.com/products/photoshop.html" rel="nofollow noreferrer">Photoshop</a> have a canvas where you can paint with brushes.</p>
<p>From a programming perspective, how is this canvas rendered?<br />
Can it be included on a graphics pipeline like <a href="https://www.opengl.org" rel="nofollow noreferrer">OpenGL</a>?</p>
<p>One proposed solution is to represent the canvas as a texture.<br />
Are there any other solutions?</p>

CC BY-SA 4.0
2020-06-09T05:41:50.990Z
It is a 2D array containing the color values: an image. You can present it on screen through various methods, a special case being drawing it as an OpenGL texture.
lightxbulb
<rendering><2d>
How are digital painting canvas rendered?
Burst
# How are digital painting canvas rendered?

(Asked by: username_0 on 2020-06-08)

Digital painting and raster graphics software like [Krita](https://krita.org/en/) and [Photoshop](https://www.adobe.com/products/photoshop.html) have a canvas where you can paint with brushes.

From a programming perspective, how is this canvas rendered?  
Can it be included on a graphics pipeline like [OpenGL](https://www.opengl.org)?

One proposed solution is to represent the canvas as a texture.  
Are there any other solutions?

**Tags:** rendering, 2d

> **Comments:**
> **username_1**: It is a 2D array containing the color values: an image. You can present it on screen through various methods, a special case being drawing it as an OpenGL texture.  

---

## 1 answers

### Answer by username_2 on 2020-06-09. Score: 0 | Accepted answer

> Digital painting and raster graphics software like Krita and Photoshop have a canvas where you can paint with brushes. From a programming perspective, how is this canvas rendered?

I don't have access to the code of the programs you mentioned, so I can't tell how exactly they did this since there are usually multiple ways to solve a programming problem. However, I guess everybody with some graphics programming experience will immediately think of the solution @username_1 already mentioned in his comment because it is the simplest one.

Textures are just an array of color values and a graphics API like OpenGL expects you to upload them as such. So a possible solution would be to represent your modifiable canvas in memory in this form too. Every time a modification is made, you find the affected pixels in your array, adjust their color values, and upload the updated canvas as texture (or update the already existing one). Then you just draw a fullscreen (or any other size you like) quad and attach the texture to it. Simple as that.

> Can it be included on a graphics pipeline like OpenGL?

As you might already guess: Yes, you can do that. If you use the texture approach, you can do anything you can do with an ordinary texture in the graphics pipeline. If your intention is to include a canvas in a 3d game, then keep in mind that finding the pixel that should be modified gets a little bit more complicated due to the perspective projection. However, the rendering process stays the same.

> **Comments:**
> **username_0**: I have little experience in graphics programming but seems a little hacky. It also seems easy so i guess its worth a try. I wonder what performance will it have. One critical component must be only updating the changed pixels instead of the whole canvas for each frame.  
> **username_2**: The main performance problem in OpenGL is the texture update on the GPU side. But there exist some fast routes (search for "OpenGL buffer streaming" or "OpenGL Approaching zero driver overhead"). However, if you are just doing a regular paint program, this is not worth optimizing since you have "plenty" of time.  Also, I wouldn't call it hacky since it is a perfectly valid usage of the render pipeline. - Updating single pixels is also not that much of a problem because there are special OpenGL functions for that.  

---

