###############
Creating Images
###############


Images operations generally occur from the application's rendering thread, because most image operations are synchronous, and are not allowed while a rendering is being processed. This behavior can be bypassed, but in the case of GPU application, it requires a fine management of OpenGL contexts on the various threads involved in image operations. So as a general guideline, all image operations should occur from the rendering thread.

Let's start by creating (or destroying) images. As other resources managed by the ``RED::IResourceManager`` class, images are shared resources. An image is used by shaders, themselves used inside materials to define how a shape is going to be rendered.

.. include:: /tasks/ta_ca/ta_ca_image/tk_creating_and_destroying_images.rst

Then, images may be duplicated whenever needed (keeping in mind that an image may take a lot of space in memory!) using the following code:

.. include:: /tasks/ta_ca/ta_ca_image/tk_duplicating_an_image.rst

An image can be sourced by the application from a local pixel array, from the disk through commonly supported image formats (JPEG, PNG, HDR) or from .red files. See the details here on :doc:`/book/subjects/bk_im/bk_im_loading_and_saving_images`.
