| Instead of reflecting each x-row, could you instead
| arrange to process them "backwards" elsewhere? That is,
[quoted text clipped - 3 lines]
| to-right" order, maybe you could just leave the array as
| it is and iterate over x=N-1,N-2,N-3,... instead.
the reason I do this is that the clone is an image to be displayed on
screen , but it has to be the mirror of the original one
| By the way, the end tests of both your loops look
| suspicious and may be wrong. A useful way to check for
| possible off-by-one errors is to consider what happens in
| extreme or degenerate cases: does the code you've shown
| do what you intend when clone.height==1? How about when
| clone.width==2 or ==3?
The code works nice . height has to be at least 768 (checked before in
code) .
Thanks

Signature
Erik
Eric Sosman - 20 Sep 2005 16:05 GMT
Flatman wrote On 09/20/05 05:46,:
> | By the way, the end tests of both your loops look
> | suspicious and may be wrong. A useful way to check for
[quoted text clipped - 5 lines]
> The code works nice . height has to be at least 768 (checked before in
> code) .
That wasn't the point I was trying to make. For
reference, here's your original loop:
> for(int y=0; y<clone.height-1; y++){
> for(int x=0; x<clone.width/2-1; x++){
[quoted text clipped - 3 lines]
> }
> }
Now: If clone.height is the total number of rows in
your image, observe that the bottommost row never gets
processed; the loop stops after processing the next-to-
last row. The point of imagining a one-row image is to
make this fact stand out: If clone.height is 1 the loop
begins by testing whether 0 < 1-1, and since this test
yields false, the loop never executes. Is it really your
intention to leave the last row un-reflected, or have you
fallen victim to an off-by-one error?
Similarly with the inner loop. If clone.width is the
number of pixels in each row, then imagine what happens with
a two-column row: the loop tests whether 0 < 2/2-1, the test
fails, and the loop doesn't execute. The point is not that
you really intend to process images of just two columns, but
that the misbehavior on a two-column image shows that the loop
is set up incorrectly and will also misbehave on images of
realistic width.
All this is, of course, based on the supposition that
clone.width and clone.height are the dimensions of the
image you're trying to reflect. The arithmetic in the two
clone.set() calls suggests that's the case, but it isn't
absolutely certain: maybe you've got an extra "guard" row
or column that resides in clone but isn't considered part
of the image, or is to be left alone for some reason. It
doesn't seem likely, but it's possible -- which is why I
said that your loops "may be" wrong, not that they "are"
wrong. You decide.

Signature
Eric.Sosman@sun.com
Flatman - 21 Sep 2005 07:08 GMT
| yields false, the loop never executes. Is it really your
| intention to leave the last row un-reflected, or have you
| fallen victim to an off-by-one error?
You're right, I'm missing a row . Since the Jpeg is black on that row I
didn't notice it . Thanks, bug corrected

Signature
Erik