Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Rotating Images....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rotating Images....



Florent,

Your code is much nicer than than what I cobbled together.
I am rotating inside of a larger rectangle and then shrinking
to the appropriate size by copying only a segment of the
larger rectangle to the appropriately sized rectangle, ugh.

Thanks for the pointer to the code.

Jerry

On Jun 30, 2004, at 4:22 AM, Florent Pillet wrote:

I have open source code to manipulate images. Here is a pointer to a NSImage category that provides everything you need:

http://cvs.sourceforge.net/viewcvs.py/osx-palm-tools/PalmConstructor/ CocoaExtensions/

Download "NSImage-Constructor.{h,m}" and you should be all set. Or at least it provides working examples of what you want to achieve.

I also have a couple other extensions on the image manipulation front:

http://cvs.sourceforge.net/viewcvs.py/osx-palm-tools/PalmServices/

There, get "NSImage-PalmExtensions.{h,m}" there are a bunch more goodies in this one.

Regards,
Florent

On 27 juin 04, at 23:56, Jerry LeVan wrote:

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.


--
Florent Pillet, Code Segment email@hidden
Developer tools and end-user products for Palm OS & Mac OS X
ICQ: 117292463 http://perso.wanadoo.fr/fpillet
_______________________________________________
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.


References: 
 >Rotating Images.... (From: Jerry LeVan <email@hidden>)
 >Re: Rotating Images.... (From: Allan Odgaard <email@hidden>)
 >Re: Rotating Images.... (From: Jerry LeVan <email@hidden>)
 >Re: Rotating Images.... (From: Allan Odgaard <email@hidden>)
 >Re: Rotating Images.... (From: Jerry LeVan <email@hidden>)
 >Re: Rotating Images.... (From: Florent Pillet <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.