• 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
Re: Composing a single whole NSImage from pieces (tiles)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Composing a single whole NSImage from pieces (tiles)


  • Subject: Re: Composing a single whole NSImage from pieces (tiles)
  • From: Larry Gerndt <email@hidden>
  • Date: Thu, 2 Jun 2005 16:11:55 -0700

Indeed, this was exactly what I was looking for.   Thanks Andrew, it works like a charm.

P.S. It's clear to me now that this is a very fundamental thing, but I'm a newbie so I needed this.  Hopefully other newbies will benefit from the post as it moves to the archives.

On May 31, 2005, at 4:26 PM, Andrew Merenbach wrote:

Hi, Larry.  I believe that you'll want to create a new NSImage that's the precise size of all of the assembled pieces.  Then you'll lock focus on it, use drawing operations for the other images, and then unlock focus.


This was composed in Mail.app, and assumes the existence of some constants like tileHeight and tileWidth.  Someone else is likely to notice an error or two--you might need to specify a rectangle (there are a few variations of compositeToPoint:) and drawAtPoint: might also be an option in your case, depending on the situation.

---start code ---

NSSize combinedTileSize = ....; // Figure out your big image size
NSImage *theBigPicture = [[NSImage alloc] initWithSize:combinedTileSize];
[theBigPicture lockFocus];

int x, y;


/* come up with an algorithm to place the tiles here; for example: */

/*for (x = 0; x < theBigPictureTotalColumns; ++x) {
    for (y = 0; y < theBigPictureTotalRows; ++y) {
        [theTileForThisPosition compositeToPoint:NSMakePoint(x * tileWidth, y * tileHeight)
            operation:NSCompositeCopy];
    }
}*/

[theBigPicture unlockFocus];


/* do stuff with your picture */

[theBigPicture release];    // don't forget that!

----end code-----


Best wishes,
    Andrew Merenbach

On May 31, 2005, at 3:58 PM, Larry Gerndt wrote:

My application receives an image from a server which sends the image as a series of tiles-- that is, it grids the image and sends each section of the grid as a separate message.   I know how to convert each received tile into an NSImage, but I don't know how to assemble these individual NSImages into one whole NSImage.  Can anyone give me some advice?  Thanks in advance.

--

Larry Gerndt

AIM Handle: SonOfTheSonOfMan

Let the truth be told though the heavens fall -- James Garrison




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Core Data Relationship Binding
  • Next by Date: kerning broken on Tiger
  • Previous by thread: WebServices -- Re: (no subject)
  • Next by thread: kerning broken on Tiger
  • Index(es):
    • Date
    • Thread