NOW it works! It was the missing img from img.updatePixels();
I had been trying with and without.
Thank you!
(What do you think of my proposed workflow (see reply to kll).)
Something I was trying the other day:
PImage img;
String filename = str(month()) + str(day());
void setup()
{
size(500, 500); //I want a white margin. This is currently same size as image.
background(255);
noLoop();
make();
}
void draw()
{
background(0);
image(img, (width-275)/2, (height-275)/2);
println(frameCount);
}
void make()
{
img = loadImage("blank.png");
//img.width = 275;
//img.height = 275;
println(img.width);
println(img.height);
colorMode(RGB, 255, 255, 255);
int offset = (img.width-255)/2; //to center it
for (int y = offset; y < img.width-offset; y++ )
{
for (int x = offset; x < img.height-offset; x++ )
{
int loc = x + y*img.width;
img.pixels[loc] = color(loc%img.width, (loc - (loc%img.width))/img.width, 0); //
}
}
img.updatePixels();
img.save(filename + ".jpg");
println("done");
}
This is the “blank.png” image (275x275):
And output:
1 Like
Please save this under a new file name so that you have a working version
Then work on with a new version
The proposal is homework and I wish you good luck Sir.
Yes, all saved as a new version with setup() and draw() as they should be.
Shall I continue with loading an image or move over to createImage() ?
The rest, as you say, is homework.
Thank you. That works as well. Now I need to study it!
img.width = 255;
img.height = 255;
Please tell me more.