
-----------------------------------
Justin_
Thu Jun 08, 2006 11:41 pm

help with image program
-----------------------------------
okay so "sourcePixels" is an array of values between 0-255 which are pixels.  this is a black and white image scaler with just one problem, some of the image is chopped off and the image that appears is enlarged and slightly compressed rather than scaled down.  It should just scale down 50% but I cannot see what I'm doing wrong.  



                int height = sourcePixels.length, width = sourcePixels

-----------------------------------
rizzix
Fri Jun 09, 2006 9:41 am


-----------------------------------
What are you trying to achieve here? Why don't you try and use Java's built-in methods to scale the image? It would probably be faster (more optimized) and it works.

-----------------------------------
Justin_
Fri Jun 09, 2006 9:55 am


-----------------------------------
Sorry I forgot to mention that this is for a school summative and I'm supposed to make my own functions.   It is supposed to scale the image stored in the pixel array by 50% or in other words div both height and width by 2.  

Does anyone know an algorithm to accomplish it?  To explain my algorithm I essentially took the 2d pixel array and put it into a 1d array because that way I can choose 4 pixels in a box like: o o
                                                                             o o
by simply using the algorithm: num, num++, num+(width-2), num+(width-1) to choose pixels in this order.  

Anyway, if someone has done this kind of thing before please shed some light.

-----------------------------------
[Gandalf]
Sat Jun 10, 2006 5:53 pm


-----------------------------------
Why don't you just store every second pixel of that image in an array and redraw the pixels in that array?  I've just tried that in Turing, and it doesn't look too bad, even with Turing's crappy colour preservation.
