Howdy guys,
I’m trying to set up a basic script that will download an image, and then save the image as a transparent PNG to a specific folder. Here’s what I have so far (I’ve replaced the url, for privacy sake. The actual URL can be accessed and the program will display the image, if I remove the entire if statement):
boolean saved = false;
PImage spr1;
PGraphics sprOut;
void setup()
{
spr1 = loadImage("URL HERE");
surface.setSize(spr1.width, spr1.height);
sprOut = createGraphics(width, height);
}
void draw()
{
image(spr1, 0, 0);
if (saved == false)
{
sprOut.save("C:/PetStuff/Pet0/test.png");
saved = true;
}
}
This throws a null pointer exception, and I cannot for the life of my figure out why. Any help would be greatly appreciated.
Fixed the issue by going about things a different way.
It was incredibly simple, and it saves as a transparent PNG.
PImage spr1;
void setup()
{
spr1 = loadImage("MY URL");
image(spr1, 0, 0);
spr1.save("C:/PetStuff/Pet0/test.png");
}