• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
cutting an image into multiple images
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cutting an image into multiple images


  • Subject: cutting an image into multiple images
  • From: Dharmendra <email@hidden>
  • Date: Sat, 21 Jun 2008 19:11:29 +0530

Hi,
I am trying to get a user-defined image in specific format (m x nm) and want
to generate an array with count n containing m x m sized images. I have
written the following code, but would like to know if there is better way to
do the same:

m=...;

NSImage *userImage=[[NSImage alloc] initWithContentsOfFile:@"xxx.gif"];

unsigned int n=[userImage size].width/m;

NSMutableArray *images = [NSMutableArray arrayWithCapacity:n];

for(i=0;i<n;i++) {

NSImage *testImage=[[NSImage alloc] initWithSize:NSMakeSize(m,m)];

[testImage lockFocus];

[userImage drawInRect:NSMakeRect(0,0,m,m) fromRect:NSMakeRect(m*i,0,m,m)
operation:NSCompositeSourceOver fraction:1.0];

[testImage unlockFocus];

[images addObject:testImage];

}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: cutting an image into multiple images
      • From: Ken Thomases <email@hidden>
    • Re: cutting an image into multiple images
      • From: "douglas a. welton" <email@hidden>
  • Prev by Date: NSPanel should not close on command-W
  • Next by Date: Why does this https post request always return "404 Not Found"
  • Previous by thread: Re: NSPanel should not close on command-W
  • Next by thread: Re: cutting an image into multiple images
  • Index(es):
    • Date
    • Thread