1
$\begingroup$

After creating a new image,i know that D.images['my_image'].generated_color = (1,1,1,1) It makes the image all white, in short, it fills it (R,G,B,A)

The problem arises, when I go into texture paint mode, I paint over my image, and then I save the project, exit, and am asked to save the changes made to the image (And I confirm)

When I return to Blender, I realize that D.images['my_image'].generated_color = (1,1,1,1)

it won't work anymore. For example, if I go on to paint and try again to use generated_color, it will always revert to the previous paint I had at the time of the previous save. Therefore it will no longer be possible to do the "Fill" in solid colors

Anyone have any idea why?

$\endgroup$

1 Answer 1

4
+50
$\begingroup$

Images have a source, D.images['my_image'].source, that specifies where the image comes from.

A "Generated" image (source == 'GENERATED') is generated based on some parameters, generated_type and generated_color. For example, when Generated Type is "Blank", it will generate a solid color image with the generated_color, like you observed.

When you paint over an image and save it, the source is changed to "Single Image" (source == 'FILE'). Now the image comes from a single file (possibly packed into the .blend).

The generated_color is only used for "Generated" images (and even then, only "Blank" type), it won't affect other source types. But if you switch back to "Generated" you'll see the color you set.

D.images['my_image'].source = 'GENERATED'

If you open the Image Editor and open the sidebar (shorcut: N), you can see all this under the Image tab. It might help to play around with it.

Image tab

$\endgroup$
1
  • $\begingroup$ D.images['my_image'].source = 'GENERATED' It really does what I was looking for. I hadn't really noticed that API. Really useful, you solved a big problem for me. $\endgroup$
    – Noob Cat
    Commented Jun 4, 2021 at 22:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .