We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm working on a paint program that will be able to handle larger images ( 4800 x 6000) pixels. In order to mix pixels properly, I've found I need to either use a floating point array or an array with the integer r,g,b, values of the pixels shifted 16. Using just integers, there is a little clipping each time that is lost and they start adding up into weird hue shifts. Though tests, I've found no difference in performance between using the floating point array and the integer shifted array-at least on the java machine. So I use the float because its clearer.
But I have found a major difference in performance between using a multidimensional array and 3 one dimension arrays.
I had been allocating the array as such:
float floatArray = new float[4800 * 6000];
That little line of code took about 5-10 seconds to allocate on my Windows 7, i7 processor with 16gb ram.
But writing it as this takes only milliseconds to allocate:
float floatArrayR = new float[4800 * 6000]; float floatArrayG = new float[4800 * 6000]; float floatArrayB = new float[4800 * 6000];
I remember reading many years ago that different os's handle multidimensional arrays differently and one should not assume how the members are ordered. I can't imagine how the java virtual machine handles multidimensional arrays to make them so much slower than one dimension arrays. Allocation time from 5-10 seconds to milliseconds? Whats going on there? The multidimensional array also slowed garbage collection so much it was performance issue. Not so with the one dimension array.