|
Author |
Topic: BImage issue (Read 446 times) |
|
Dara Kilicoglu Guest
|
BImage issue
« on: Apr 25th, 2003, 3:30pm » |
|
hi, http://www.darakilicoglu.com/wod/p5/luminance/ small software at the link above reads bitmaps and sort pixels by their luminance value using "merge sort". original image on the left and then sorted pixels are displayed on the right. my question here is how come b.pixels are manupulated as well as i only send sortArray array which is a copy of b.pixels array. temporarily i solved the problem by loading image to both b and c variables. and then displaying only c. void loop() { if (!imageLoaded) { b = loadImage("shirts.gif"); c = loadImage("shirts.gif"); imageLoaded = true; sortArray = b.pixels; msort(sortArray, 0, sortArray.length); } image(c , 20, 20); for (int j=0; j < bmpH; j++) { for (int i=0; i < bmpW; i++) { setPixel(140 + i, j + 20, sortArray[(j*bmpW)+i]); } } } also code can be found here: http://www.darakilicoglu.com/wod/p5/luminance/luminance.java Have a wonderful one! Dara
|
|
|
|
toxi
|
Re: BImage issue
« Reply #1 on: Apr 25th, 2003, 7:33pm » |
|
Quote:my question here is how come b.pixels are manupulated as well as i only send sortArray array which is a copy of b.pixels array. |
| that would be because sortArray will only store a reference to b.pixels and hence the array which is being sorted IS b.pixels... if you want a copy, you have to do a: System.arraycopy(b.pixels,0,sortArray,0,b.pixels.length);
|
http://toxi.co.uk/
|
|
|
REAS
|
Re: BImage issue
« Reply #2 on: Apr 28th, 2003, 12:35pm » |
|
toxi, thank you for your assistance with this and other questions. + casey
|
|
|
|
toxi
|
Re: BImage issue
« Reply #3 on: Apr 28th, 2003, 3:17pm » |
|
yer welcome casey! glad if i can help
|
http://toxi.co.uk/
|
|
|
Dara
|
Re: BImage issue
« Reply #4 on: Apr 28th, 2003, 4:06pm » |
|
got it thanks
|
« Last Edit: Apr 28th, 2003, 4:07pm by Dara » |
|
|
|
|
|