Re: 90 Rotation in one buffer only
- From: Thomas Richter <thor@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 25 Nov 2005 09:13:42 GMT
Hi,
> you are right, sorry for this mistake.
> here is code which works (tested):
> public void rotate() {
> int w = width - 1;
> int h = height - 1;
> int w2 = width / 2;
> int h2 = height / 2;
> int tmp;
> for (int y = 0; y < h2; y++) {
> for (int x = 0; x < w2; x++) {
> tmp = getPixel(x, y);
> setPixel(x, y, getPixel(w - y, x));
> setPixel(w - y, x, getPixel(w - x, h - y));
> setPixel(w - x, h - y, getPixel(y, h - x));
> setPixel(y, h - x, tmp);
> }
> }
> }
That looks of course better. (-; However, there's still a problem
here: You need at least a buffer of width and height =
max(width,height) of the original image data, i.e. it will perform
"out of bounds" accesses unless the image is square. Solving that
problem is actually the harder part of it. Of course a memory chunk of
width * height pixels should be enough to perform a rotation "in
place", but it is very hard to do unless width = height.
So long,
Thomas
.
- Follow-Ups:
- Re: 90 Rotation in one buffer only
- From: Naresh
- Re: 90 Rotation in one buffer only
- From: ibai
- Re: 90 Rotation in one buffer only
- From: Andrey Kuznetsov
- Re: 90 Rotation in one buffer only
- References:
- 90 Rotation in one buffer only
- From: Naresh
- Re: 90 Rotation in one buffer only
- From: Andrey Kuznetsov
- Re: 90 Rotation in one buffer only
- From: Thomas Richter
- Re: 90 Rotation in one buffer only
- From: Andrey Kuznetsov
- 90 Rotation in one buffer only
- Prev by Date: Re: 90 Rotation in one buffer only
- Next by Date: Re: 90 Rotation in one buffer only
- Previous by thread: Re: 90 Rotation in one buffer only
- Next by thread: Re: 90 Rotation in one buffer only
- Index(es):
Loading