Please help explain how Pimage works in draw() getting out of memory errors
in
Programming Questions
•
7 months ago
I am trying to create a splash screen that comes up, displays a logo at the center of the screen,
then after a pause fades to white...
This code below works when I create an application file but within processing I get out of memory errors.
This is part of a larger program that uses G4P so I used that library to handle the fading. it aso goes on to change the size of the window when the splash screen routine is done. That's the reason for the frames
I know I am missing the concept of how images are displayed and loaded and am probably loading them many times...
Any help fixing this or pointers will help me a lot... Having a hard time jumping from arduino to processing environment... Arduino seems to do what I tell it to but processing is drawing at its own pace and that might be where I am completely lost....
- import g4p_controls.*;
- int opacity=255;
int splashFlag=0;
int startFlag=1; - PImage img;
void setup() {
size(1800, 760);
img = loadImage("coversm.jpg");
} - void draw()
{
// SPLASH screen Display IMAGE and then fade to white
if (startFlag==1) {
G4P.setGlobalAlpha(0);
frame.setSize(1800, 760);
frame.setLocation(85, 1);
PImage img;
img = loadImage("coversm.jpg");
background(255);
tint(255, opacity);
image(img, 650, 300);
splashFlag++;
if (splashFlag==5) {
delay(2500);
splashFlag=6;
}
if (splashFlag>=6) opacity=opacity-2; - if (opacity<=0) {
startFlag=2;
opacity=255;
delay(1000);
}
}
}
1