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 › Optimized Performance Using Bitmaps
Page Index Toggle Pages: 1
Optimized Performance Using Bitmaps (Read 785 times)
Optimized Performance Using Bitmaps
Jun 3rd, 2009, 5:29pm
 
I'm really enjoying using Processing. I'm having so much fun, I'm honestly waiting for the other shoe to drop... that I'll eventually start to tax the processor and memory of an average machine.

For example I've been playing with pseudo-cell shaded sprites and I'm really digging the result:

http://npoly.com/cellShade/

But in order to do something like that I have to have twice as many sprites drawn as there are gears on screen (6 images 3 foreground and 3 background).

So my question is... are there any things to bear in mind, performance wise, when building bitmaps for use in Processing?

I imagine keeping graphics as powers of 2?

Anything as it pertains to png vs jpg (assuming both are similar filesize)?

I like to use alpha transparancy, is it a significant resource hog compared to binary transparency in Java/Processing?

Any other tips?
Re: Optimized Performance Using Bitmaps
Reply #1 - Jun 11th, 2009, 7:34pm
 
svg?
Re: Optimized Performance Using Bitmaps
Reply #2 - Jun 12th, 2009, 5:15am
 
Once loaded it doesn't really matter what format bitmap file is in because they are all stored as PImage objects in Processing. PImage stores the graphic as an array where each element represents a pixel and each element is a 32 bit integer representing ARGB values.

If the image is png of gif then it will recognise any transparency used in the image and apply it, obviously jpg files does not support transparency.

You can manipulate the actual values in the array to get a number of nice effects but depending on the image size this canbe quite CPU intensive.

Not sure about the powers of 2 although this is normal when used as textures in 3D stuff.

You could look at
http://processing.org/reference/pixels.html
and
http://processing.org/reference/PImage.html
for more info.

Page Index Toggle Pages: 1