Re: Rotating Images....
Re: Rotating Images....
- Subject: Re: Rotating Images....
- From: Jerry LeVan <email@hidden>
- Date: Sun, 27 Jun 2004 17:56:40 -0400
Hi,
I am starting to make progress on the image rotation problem, I can
rotate by
multiples of 90 sorta ok...
The 90 and 270 degree rotation are handled by building a (square) image
whose
sides are the length of the larger of the two sides of the scaled image
and
then drawing into this square after transforming the co-ordinates by
something
like:
if(rotationFactor==270)
//NSLog(@"in 270");
// This will leave the rotated object clinging to the right side of
big box
[imageRotation translateXBy:bigSide/2.0 yBy:bigSide/2.0];
[imageRotation rotateByDegrees:-rotateFactor]; // counter clockwise
[imageRotation translateXBy:-bigSide/2.0 yBy:-bigSide/2.0];
}
I have an image whose size is 4000 (width) by 200 (height)
When I apply my transformation the result is a 4000x4000 image with the
desired
bits clinging to the right hand side of the "big" box. I have to scroll
a bit
to see the rascal, but it is all there.
Similarly if I have an image that is higher than wider, then the 90
degree
transformation will leave the rotated gadget clinging to the top of the
big box.
All other cases leave the image nestled in the lower left corner of the
scroll window as it should be.
Is there a nice way to "trim" the window in the two "bad" cases? I
tried tacking
every conceivable translation in the code snippet above, but every try
made things worse....It is easy to see the location of the desired
object
in these two cases, I guess if worst comes to worst I can probably copy
the relevant hunk of the big image into a small image (somehow...). I
have
had a complaint that things are starting to slow down a bit in the app,
adding rotation looks like it might be a bit more expensive.
When I started the rotation study I initially had a slider that sent
a continuous action for rotation, It looked sorta cool watching the
stuff
pinwheel around. I was trying things out with a fair size jpeg zoomed by
a factor of about four. All of a sudden I experience a great slow down
in
the "force". Peeking at top showed my VM was over a gig (on my 1 gig
machine).
Since that experience I decided to restrict rotation to multiples of 90
:)
Thanks,
Jerry
On Jun 27, 2004, at 7:47 AM, Allan Odgaard wrote:
On 27. Jun 2004, at 13:40, Jerry LeVan wrote:
Anyway I can now rotate "square" images. Oblong images
are still a problem...Today I am going to try increasing
the size of the target image to see if that helps.
Well, yes -- if you rotate a non-square by 900, then the resulting
image will be as wide as the original was height and as height as the
original image was wide.
A
AAA -> A
A
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.