We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Saving a background image after it has loaded
Page Index Toggle Pages: 1
Saving a background image after it has loaded (Read 1050 times)
Saving a background image after it has loaded
Apr 2nd, 2010, 3:24am
 
I'm loading a map from Bing Maps using modestmaps. I'm trying to cache it on my computer so I won't be loading it over and over again. Doing:

Code:
if (drawMap) {
  map.draw();
  save("map.png");
  drawMap = false;
  mapBackground = loadImage("map.png");
} else {
image(mapBackground, 0, 0);
}


Saves a white picture, since the map doesn't have time to load. Using delay also doesn't work :/
Re: Saving a background image after it has loaded
Reply #1 - Apr 2nd, 2010, 3:49pm
 
I'm pretty new to this stuff but it looks like the save command comes before the map is drawn?
Re: Saving a background image after it has loaded
Reply #2 - Apr 3rd, 2010, 4:26am
 
Ned wrote on Apr 2nd, 2010, 3:49pm:
I'm pretty new to this stuff but it looks like the save command comes before the map is drawn


But I want to save the drawn map, then use the cached image without drawing the map again.
Re: Saving a background image after it has loaded
Reply #3 - Apr 6th, 2010, 8:16am
 
Since it seems that there's no specific code for what I wanted, I went around it. Here's the code if someone's interested:

Code:
// Draws the map
if (drawMap) {
imageMode(CORNER);
map.draw();
timerMap++;
} // Caches the map
if (timerMap > 20 && !drawCache) {
drawMap = false;
save("data/cache/map.png");
backgroundMap = loadImage("data/cache/map.png");
drawCache = true;
} // Loads the background from the cache
if (drawCache) {
imageMode(CORNER);
image(backgroundMap, 0, 0);
}
Re: Saving a background image after it has loaded
Reply #4 - Apr 6th, 2010, 8:30am
 
Interesting...I'm also playing around with this and would be interested in figuring out how you would put the map directly into a PImage without drawing it to screen first...any ideas?
Re: Saving a background image after it has loaded
Reply #5 - Apr 7th, 2010, 2:30am
 
Giles wrote on Apr 6th, 2010, 8:30am:
Interesting...I'm also playing around with this and would be interested in figuring out how you would put the map directly into a PImage without drawing it to screen first...any ideas


Problem is, there's no documentation on modestmaps for processing. Maybe looking at what the code looks like for Python.
Re: Saving a background image after it has loaded
Reply #6 - Apr 7th, 2010, 1:45pm
 
Or maybe Tom could release some Processing documentation....please???...... Cheesy
Page Index Toggle Pages: 1