• 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: Re: Pictures as characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Re: Pictures as characters


  • Subject: RE: Re: Pictures as characters
  • From: Ricky Sharp <email@hidden>
  • Date: Fri, 21 Jan 2005 10:34:27 -0600

>> On Friday, January 21, 2005, at 08:20AM, Peter Karlsson
><email@hidden> wrote:
>>
>> >I have 32 NSImageView's in my app, located as a row. I take a 32
>character
>> >NSString and convert the first char to a ascii filename (for example A =
>> >65.tif) and load a picture in the first NSImageView. The 32 NSImageView's
>> >is called view1Outlet, view2Outlet and so on. This is a lot of work. Is
>> >there another and better way to use pictures as characters?
>>
>> What in the world are you trying to do here?  What are the contents of
>65.tif?  Is it just a bitmapped version of the character 'A'?

On Friday, January 21, 2005, at 09:43AM, Peter Karlsson <email@hidden> wrote:

>Yes, made in Photoshop.

Ok...I used to do this in the Carbon version of my app.  I rendered all the glyphs I needed into a single 'tiled' image.

Rather than having 32 separate views, I'd suggest just making a single custom NSView.  Or, if you need things a bit more general purpose, subclass NSCell, then create a matrix of 32 of those cells.

In terms of the tiled image, first choose a layout for your tiles.  For example, you may want to have a very wide image (1 row of 32 tiles) or a very narrow image (1 column of 32 tiles).   Or even n x m rows/columns.  It's really up to you.

Let's say that you're doing the custom NSCell solution.  Your cell could use its intValue to describe the index of the tile it should render (or perhaps you can add a separate attribute).

You'd then use NSImage's drawInRect:fromRect:operation:fraction to copy the appropriate rectangle of image data from your titled image.

For example, say your tiled image is 1 row and 32 columns.  The indecies of the tiles would then be in the range [0..31]  And,  say that each tile is 64x64 pixels.

Given an index i, the rectangle to use for the 'fromRect' parameter would simply be:

NSRect  theTileRect = NSMakeRect (i * 64, 0, 64, 64);

HTH,

Rick Sharp
Instant Interactive(tm)

 _______________________________________________
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

  • Follow-Ups:
    • Capturing 'pageup' and 'pagedown' keys in NSTextField
      • From: Ole Voß <email@hidden>
    • Re: Pictures as characters
      • From: Ryan Stevens <email@hidden>
References: 
 >RE: Re: Pictures as characters (From: "Peter Karlsson" <email@hidden>)

  • Prev by Date: Re: QTJava in Cocoa Java hangs
  • Next by Date: CFSocket event handler accessing GUI variables
  • Previous by thread: RE: Re: Pictures as characters
  • Next by thread: Re: Pictures as characters
  • Index(es):
    • Date
    • Thread