Getting the network Machine Icon

  • Greetings

    I'm looking for a way to programatically get the machine icon from my
    servers, just like finder does in the finder.
    for every type of mac it has a different icon, and for windows
    computers, it;s the nice crash screen icon.

    I would like my application to represent the network hosts as finder
    does.

    I looked over the internet but could not find how finder does it.
    I did however find the icons in /System/Library/CoreServices/
    CoreTypes.bundle/Contents/Resources/

    Any suggestions on where to look??

    Thank you in advance.
    Sandro Noel.
  • On 1/11/09 2:31 PM, Sandro Noel said:

    > I'm looking for a way to programatically get the machine icon from my
    > servers, just like finder does in the finder.
    >
    > *SNIP*.
    >
    > Any suggestions on where to look??

    NSImage.  I think it's NSImageNameComputer.

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
  • On Mon, Jan 12, 2009 at 11:56 AM, Sean McBride <sean...> wrote:

    > NSImage.  I think it's NSImageNameComputer.

      Yep:

      http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIG
    uidelines/XHIGIcons/chapter_15_section_10.html#


    --
    I.S.
  • Le 12 janv. 09 à 17:56, Sean McBride a écrit :

    > On 1/11/09 2:31 PM, Sandro Noel said:
    >
    >> I'm looking for a way to programatically get the machine icon from my
    >> servers, just like finder does in the finder.
    >>
    >> *SNIP*.
    >>
    >> Any suggestions on where to look??
    >
    > NSImage.  I think it's NSImageNameComputer.

    Fine to get the current machine icon, but not to get a remote machine
    icon, just like the Finder does when it display the list of machine on
    the local network.
  • On 12 Jan 2009, at 18:19, Jean-Daniel Dupas wrote:
    >
    >>
    >> NSImage.  I think it's NSImageNameComputer.
    >
    > Fine to get the current machine icon, but not to get a remote
    > machine icon, just like the Finder does when it display the list of
    > machine on the local network.
    >

    I don't know, but you could ask the same question on Carbon-Dev. At
    least one Finder engineer hangs out there.

    Matt Gough
  • Thanks guy's i'll ask in the Carbon-dev list.

    Sandro Noel.

    On 11-Jan-09, at 2:31 PM, Sandro Noel wrote:

    > Greetings
    >
    > I'm looking for a way to programatically get the machine icon from
    > my servers, just like finder does in the finder.
    > for every type of mac it has a different icon, and for windows
    > computers, it;s the nice crash screen icon.
    >
    > I would like my application to represent the network hosts as finder
    > does.
    >
    > I looked over the internet but could not find how finder does it.
    > I did however find the icons in /System/Library/CoreServices/
    > CoreTypes.bundle/Contents/Resources/
    >
    > Any suggestions on where to look??
    >
    > Thank you in advance.
    > Sandro Noel.
  • On Mon, Jan 12, 2009 at 1:52 PM, Sandro Noel <sandro.noel...> wrote:

    > Thanks guy's i'll ask in the Carbon-dev list.

      Sorry - I didn't see the "remote" part of the requirement at first.
    After spending some time searching the docs, tech notes, and even some
    headers for this myself (because it's an intriguing question), I
    couldn't find any good leads either. I'll second the suspicion that
    Carbon will likely be needed, but there doesn't appear to be a
    well-documented way to do so.

      If you wouldn't mind following up on this thread with any references
    you might get on carbon-dev (for those who aren't subscribed), it
    would be greatly appreciated.

    --
    I.S.
  • Follow UP.

    Here is what i got from the Carbon-dev list

    I'd guess it just uses AFP to ask the server:

    From <http://developer.apple.com/documentation/Networking/Conceptual/AFP/UsingLog
    inCommands/chapter_3_section_1.html#//apple_ref/doc/uid/TP40000854-CH4-SW1
    >:

    The AFP client sends the FPGetSrvrInfo command to obtain server
    information. The FPGetSrvrInfo command returns server information
    including the following server parameters: server name, machine type,
    AFP version strings, UAM strings, volume icon and mask, a bitmap of
    flags, and optionally, a list of available Open Directory names. For
    descriptions of server parameters, see FPGetSrvrInfo in the Reference
    section.

    I will post my code here as soon as i'm done, if this is the proper
    solution, it does makes sense.

    regards

    Sandro Noel.

    On 12-Jan-09, at 2:01 PM, I. Savant wrote:

    > On Mon, Jan 12, 2009 at 1:52 PM, Sandro Noel <sandro.noel...>
    > wrote:
    >
    >> Thanks guy's i'll ask in the Carbon-dev list.
    >
    > Sorry - I didn't see the "remote" part of the requirement at first.
    > After spending some time searching the docs, tech notes, and even some
    > headers for this myself (because it's an intriguing question), I
    > couldn't find any good leads either. I'll second the suspicion that
    > Carbon will likely be needed, but there doesn't appear to be a
    > well-documented way to do so.
    >
    > If you wouldn't mind following up on this thread with any references
    > you might get on carbon-dev (for those who aren't subscribed), it
    > would be greatly appreciated.
    >
    > --
    > I.S.
  • On Tue, Jan 13, 2009 at 11:32 AM, Sandro Noel <sandro.noel...> wrote:

    > The AFP client sends the FPGetSrvrInfo command to obtain server information.
    > The FPGetSrvrInfo command returns server information including the following
    > server parameters: server name, machine type, AFP version strings, UAM
    > strings, volume icon and mask, a bitmap of flags, and optionally, a list of
    > available Open Directory names. For descriptions of server parameters, see
    > FPGetSrvrInfo in the Reference section.

      Neat! That seems an odd place to put that functionality, but
    hopefully it'll be better-placed when all that stuff is eventually
    cocoa-ized. Thanks for the follow-up. Very informative.

    --
    I.S.
  • Well it's not that bad of a place to put it...
    there is not way to know beforehand if the servers are going to be
    present
    So it makes sense to ask the server what it is. when Bonjour declares
    it's presence.
    or when the SMB server broadcasts.

    The icons for every possible mac model are local to the computer, if
    you have a Mac.
    /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/

    I suspect that the icon in the reply from the FPGetSrvrInfo is useful
    for other platforms.
    because with the model number, there is pretty much no more
    information needed to
    associate an icon from the local resource.

    The only problem I find it VERY complicated for such a simple feature.
    to have to implement sockets UDP or TCP "have not gotten a reply yet".
    Just to get an image to show up on screen :) is quite an overhead :)

    Perhaps it would of been nice to add the model number of the machine
    to a NSNetService(Bonjour) TXT record.
    Instead of having to uery the host directly. IMHO

    I might be wrong, what do I know :)

    Sandro Noel.

    On 13-Jan-09, at 12:09 PM, I. Savant wrote:

    > On Tue, Jan 13, 2009 at 11:32 AM, Sandro Noel <sandro.noel...>
    > wrote:
    >
    >> The AFP client sends the FPGetSrvrInfo command to obtain server
    >> information.
    >> The FPGetSrvrInfo command returns server information including the
    >> following
    >> server parameters: server name, machine type, AFP version strings,
    >> UAM
    >> strings, volume icon and mask, a bitmap of flags, and optionally, a
    >> list of
    >> available Open Directory names. For descriptions of server
    >> parameters, see
    >> FPGetSrvrInfo in the Reference section.
    >
    >
    > Neat! That seems an odd place to put that functionality, but
    > hopefully it'll be better-placed when all that stuff is eventually
    > cocoa-ized. Thanks for the follow-up. Very informative.
    >
    > --
    > I.S.
  • Guy's I think I found it.

    Using a packet analyzer on my laptop, and using my iphone with
    DataCase (AFP server for iphone)
    when the service is resolved, finder sends a special bonjour query.
    called device-info.
    Packet: 5, Packetlength: 252 bytes, Packet follows:

    00030  00 05 00 00 00 00 16 53  61 6e 64 72 6f 20 4e
    6f    .......Sandro No
    00040  65 6c e2 80 99 73 20 69  50 68 6f 6e 65 0b 5f 61    el...s
    iPhone._a
    00050  66 70 6f 76 65 72 74 63  70 04 5f 74 63 70 05 6c
    fpovertcp._tcp.l
    00060  6f 63 61 6c 00 00 21 80  01 00 00 00 78 00 11 00
    ocal..!.....x...
    00070  00 00 00 15 38 08 69 50  68 6f 6e 65 2d 37 c0 34    ....
    8.iPhone-7.4
    00080  c0 0c 00 10 80 01 00 00  11 94 00 01 00 09 5f
    73    .............._s
    00090  65 72 76 69 63 65 73 07  5f 64 6e 73 2d 73 64 04
    ervices._dns-sd.
    000a0  5f 75 64 70 c0 34 00 0c  00 01 00 00 11 94 00 02    _udp.
    4..........
    000b0  c0 23 c0 23 00 0c 00 01  00 00 11 94 00 02 c0
    0c    .#.#............
    000c0  16 53 61 6e 64 72 6f 20  4e 6f 65 6c e2 80 99 73    .Sandro
    Noel...s
    000d0  20 69 50 68 6f 6e 65 0c  5f 64 65 76 69 63 65 2d
    iPhone._device-
    000e0  69 6e 66 6f c0 2f 00 10  00 01 00 00 11 94 00 0c
    info./..........
    000f0  0b 6d 6f 64 65 6c 3d 4d  36 38 41 50                .model=M68AP

    can you see the model=M68AP ?

    the service reference here :http://www.dns-sd.org/ServiceTypes.html says
    device-info
    Device Info Stuart Cheshire , Marc Krochmal  Not a service type.
    Special name reserved for DNS-SD device info.

    So the query would be .

    [computer bonjour name].[service-info.tcp].[domain]
    resolve that, and you get your model info.

    This is just speculation for now but i'll try it tomorrow and let you
    guy's know ! :)

    I. Savant thank you for being curious as I am :)

    Sandro Noel.

    On 13-Jan-09, at 2:51 PM, Sandro Noel wrote:

    > Well it's not that bad of a place to put it...
    > there is not way to know beforehand if the servers are going to be
    > present
    > So it makes sense to ask the server what it is. when Bonjour
    > declares it's presence.
    > or when the SMB server broadcasts.
    >
    > The icons for every possible mac model are local to the computer, if
    > you have a Mac.
    > /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
    >
    > I suspect that the icon in the reply from the FPGetSrvrInfo is
    > useful for other platforms.
    > because with the model number, there is pretty much no more
    > information needed to
    > associate an icon from the local resource.
    >
    > The only problem I find it VERY complicated for such a simple feature.
    > to have to implement sockets UDP or TCP "have not gotten a reply yet".
    > Just to get an image to show up on screen :) is quite an overhead :)
    >
    > Perhaps it would of been nice to add the model number of the machine
    > to a NSNetService(Bonjour) TXT record.
    > Instead of having to uery the host directly. IMHO
    >
    > I might be wrong, what do I know :)
    >
    > Sandro Noel.
    >
    > On 13-Jan-09, at 12:09 PM, I. Savant wrote:
    >
    >> On Tue, Jan 13, 2009 at 11:32 AM, Sandro Noel <sandro.noel...>
    >> wrote:
    >>
    >>> The AFP client sends the FPGetSrvrInfo command to obtain server
    >>> information.
    >>> The FPGetSrvrInfo command returns server information including the
    >>> following
    >>> server parameters: server name, machine type, AFP version strings,
    >>> UAM
    >>> strings, volume icon and mask, a bitmap of flags, and optionally,
    >>> a list of
    >>> available Open Directory names. For descriptions of server
    >>> parameters, see
    >>> FPGetSrvrInfo in the Reference section.
    >>
    >>
    >> Neat! That seems an odd place to put that functionality, but
    >> hopefully it'll be better-placed when all that stuff is eventually
    >> cocoa-ized. Thanks for the follow-up. Very informative.
    >>
    >> --
    >> I.S.

  • sorry I typed it to quickly.
    > [computer bonjour name].[_device-info._tcp].[domain]

    but I get error -72004 when i try it. :(
    witch is an invalid parameter.

    I've searched the internet for _device-info.
    and apparently i'm not the only one asking about this feature, but no
    one seems to be getting an answer :|

    Oh well... Discovery time :)

    Sandro Noel.

    On 16-Jan-09, at 2:21 AM, Sandro Noel wrote:

    > Guy's I think I found it.
    >
    > Using a packet analyzer on my laptop, and using my iphone with
    > DataCase (AFP server for iphone)
    > when the service is resolved, finder sends a special bonjour query.
    > called device-info.
    > Packet: 5, Packetlength: 252 bytes, Packet follows:
    >
    > 00030  00 05 00 00 00 00 16 53  61 6e 64 72 6f 20 4e
    > 6f    .......Sandro No
    > 00040  65 6c e2 80 99 73 20 69  50 68 6f 6e 65 0b 5f 61    el...s
    > iPhone._a
    > 00050  66 70 6f 76 65 72 74 63  70 04 5f 74 63 70 05 6c
    > fpovertcp._tcp.l
    > 00060  6f 63 61 6c 00 00 21 80  01 00 00 00 78 00 11 00
    > ocal..!.....x...
    > 00070  00 00 00 15 38 08 69 50  68 6f 6e 65 2d 37 c0 34    ....
    > 8.iPhone-7.4
    > 00080  c0 0c 00 10 80 01 00 00  11 94 00 01 00 09 5f
    > 73    .............._s
    > 00090  65 72 76 69 63 65 73 07  5f 64 6e 73 2d 73 64 04
    > ervices._dns-sd.
    > 000a0  5f 75 64 70 c0 34 00 0c  00 01 00 00 11 94 00 02    _udp.
    > 4..........
    > 000b0  c0 23 c0 23 00 0c 00 01  00 00 11 94 00 02 c0
    > 0c    .#.#............
    > 000c0  16 53 61 6e 64 72 6f 20  4e 6f 65 6c e2 80 99 73    .Sandro
    > Noel...s
    > 000d0  20 69 50 68 6f 6e 65 0c  5f 64 65 76 69 63 65 2d
    > iPhone._device-
    > 000e0  69 6e 66 6f c0 2f 00 10  00 01 00 00 11 94 00 0c
    > info./..........
    > 000f0  0b 6d 6f 64 65 6c 3d 4d  36 38 41
    > 50                .model=M68AP
    >
    > can you see the model=M68AP ?
    >
    > the service reference here :http://www.dns-sd.org/ServiceTypes.html
    > says
    > device-info
    > Device Info Stuart Cheshire , Marc Krochmal  Not a service type.
    > Special name reserved for DNS-SD device info.
    >
    > So the query would be .
    >
    > [computer bonjour name].[service-info.tcp].[domain]
    > resolve that, and you get your model info.
    >
    > This is just speculation for now but i'll try it tomorrow and let
    > you guy's know ! :)
    >
    > I. Savant thank you for being curious as I am :)
    >
    >
    > Sandro Noel.
    >
    > On 13-Jan-09, at 2:51 PM, Sandro Noel wrote:
    >
    >> Well it's not that bad of a place to put it...
    >> there is not way to know beforehand if the servers are going to be
    >> present
    >> So it makes sense to ask the server what it is. when Bonjour
    >> declares it's presence.
    >> or when the SMB server broadcasts.
    >>
    >> The icons for every possible mac model are local to the computer,
    >> if you have a Mac.
    >> /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
    >>
    >> I suspect that the icon in the reply from the FPGetSrvrInfo is
    >> useful for other platforms.
    >> because with the model number, there is pretty much no more
    >> information needed to
    >> associate an icon from the local resource.
    >>
    >> The only problem I find it VERY complicated for such a simple
    >> feature.
    >> to have to implement sockets UDP or TCP "have not gotten a reply
    >> yet".
    >> Just to get an image to show up on screen :) is quite an overhead :)
    >>
    >> Perhaps it would of been nice to add the model number of the
    >> machine to a NSNetService(Bonjour) TXT record.
    >> Instead of having to uery the host directly. IMHO
    >>
    >> I might be wrong, what do I know :)
    >>
    >> Sandro Noel.
    >>
    >> On 13-Jan-09, at 12:09 PM, I. Savant wrote:
    >>
    >>> On Tue, Jan 13, 2009 at 11:32 AM, Sandro Noel
    >>> <sandro.noel...> wrote:
    >>>
    >>>> The AFP client sends the FPGetSrvrInfo command to obtain server
    >>>> information.
    >>>> The FPGetSrvrInfo command returns server information including
    >>>> the following
    >>>> server parameters: server name, machine type, AFP version
    >>>> strings, UAM
    >>>> strings, volume icon and mask, a bitmap of flags, and optionally,
    >>>> a list of
    >>>> available Open Directory names. For descriptions of server
    >>>> parameters, see
    >>>> FPGetSrvrInfo in the Reference section.
    >>>
    >>>
    >>> Neat! That seems an odd place to put that functionality, but
    >>> hopefully it'll be better-placed when all that stuff is eventually
    >>> cocoa-ized. Thanks for the follow-up. Very informative.
    >>>
    >>> --
    >>> I.S.

    >
  • Hi All,

    I would like to something similar which is to display the Icons of
    iPods. I can get the .icns files for the iPhone and iPod Touch from:

    /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/

    But where to locate the icons for iPods?

    Thanks a lot
    All the Best
    Dave

    On 11 Jan 2009, at 19:31, Sandro Noel wrote:

    > Greetings
    >
    > I'm looking for a way to programatically get the machine icon from
    > my servers, just like finder does in the finder.
    > for every type of mac it has a different icon, and for windows
    > computers, it;s the nice crash screen icon.
    >
    > I would like my application to represent the network hosts as
    > finder does.
    >
    > I looked over the internet but could not find how finder does it.
    > I did however find the icons in /System/Library/CoreServices/
    > CoreTypes.bundle/Contents/Resources/
    >
    > Any suggestions on where to look??
    >
    > Thank you in advance.
    > Sandro Noel.
  • dave

    The only one i found was the one for he ipod touch,

    enjoy.

    //-----------------------------------------------------------------------------
    // returns the default iPod Touch icon.
    + (NSImage *) getDefaultiPodTouchIcon{

    IconRef iconRef;
    OSErr err = GetIconRef (kOnSystemDisk, kSystemIconsCreator, 'ipdt',
    &iconRef);
    if (!err){
      NSImage *image =[[[NSImage alloc] initWithIconRef:iconRef]
    autorelease];
      ReleaseIconRef(iconRef);
      return image;
    }
    else
      return nil;
    }

    Sandro Noel.

    On 20-Jan-09, at 9:38 AM, Dave wrote:

    > Hi All,
    >
    > I would like to something similar which is to display the Icons of
    > iPods. I can get the .icns files for the iPhone and iPod Touch from:
    >
    > /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
    >
    > But where to locate the icons for iPods?
    >
    > Thanks a lot
    > All the Best
    > Dave
    >
    > On 11 Jan 2009, at 19:31, Sandro Noel wrote:
    >
    >> Greetings
    >>
    >> I'm looking for a way to programatically get the machine icon from
    >> my servers, just like finder does in the finder.
    >> for every type of mac it has a different icon, and for windows
    >> computers, it;s the nice crash screen icon.
    >>
    >> I would like my application to represent the network hosts as
    >> finder does.
    >>
    >> I looked over the internet but could not find how finder does it.
    >> I did however find the icons in /System/Library/CoreServices/
    >> CoreTypes.bundle/Contents/Resources/
    >>
    >> Any suggestions on where to look??
    >>
    >> Thank you in advance.
    >> Sandro Noel.

  • Dave,

    Due to there being an icon stored on the root of each iPod, I don't
    *think* there is an icon stored on the system for each one.

    Russell

    On 20 Jan 2009, at 02:38 pm,  wrote:

    > Hi All,
    >
    > I would like to something similar which is to display the Icons of
    > iPods. I can get the .icns files for the iPhone and iPod Touch from:
    >
    > /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
    >
    > But where to locate the icons for iPods?
    >
    > Thanks a lot
    > All the Best
    > Dave
    >
    > On 11 Jan 2009, at 19:31, Sandro Noel wrote:
    >
    >> Greetings
    >>
    >> I'm looking for a way to programatically get the machine icon from
    >> my servers, just like finder does in the finder.
    >> for every type of mac it has a different icon, and for windows
    >> computers, it;s the nice crash screen icon.
    >>
    >> I would like my application to represent the network hosts as
    >> finder does.
    >>
    >> I looked over the internet but could not find how finder does it.
    >> I did however find the icons in /System/Library/CoreServices/
    >> CoreTypes.bundle/Contents/Resources/
    >>
    >> Any suggestions on where to look??
    >>
    >> Thank you in advance.
    >> Sandro Noel.

  • Hi,

    Yes, that's true. Can I get the Icon with the volume associated with
    an iPod? I can form the volume file path no problem.

    All the Best
    Dave

    On 20 Jan 2009, at 18:40, Russell Hancox wrote:

    > Dave,
    >
    > Due to there being an icon stored on the root of each iPod, I don't
    > *think* there is an icon stored on the system for each one.
    >
    > Russell
    >
    > On 20 Jan 2009, at 02:38 pm,  wrote:
    >
    >> Hi All,
    >>
    >> I would like to something similar which is to display the Icons of
    >> iPods. I can get the .icns files for the iPhone and iPod Touch from:
    >>
    >> /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
    >>
    >> But where to locate the icons for iPods?
    >>
    >> Thanks a lot
    >> All the Best
    >> Dave
    >>
    >> On 11 Jan 2009, at 19:31, Sandro Noel wrote:
    >>
    >>> Greetings
    >>>
    >>> I'm looking for a way to programatically get the machine icon
    >>> from my servers, just like finder does in the finder.
    >>> for every type of mac it has a different icon, and for windows
    >>> computers, it;s the nice crash screen icon.
    >>>
    >>> I would like my application to represent the network hosts as
    >>> finder does.
    >>>
    >>> I looked over the internet but could not find how finder does it.
    >>> I did however find the icons in /System/Library/CoreServices/
    >>> CoreTypes.bundle/Contents/Resources/
    >>>
    >>> Any suggestions on where to look??
    >>>
    >>> Thank you in advance.
    >>> Sandro Noel.

    >
  • Did you try -[NSWorkspace iconForFile:] ?

    Le 20 janv. 09 à 19:49, Dave a écrit :

    > Hi,
    >
    > Yes, that's true. Can I get the Icon with the volume associated with
    > an iPod? I can form the volume file path no problem.
    >
    > All the Best
    > Dave
    >
    > On 20 Jan 2009, at 18:40, Russell Hancox wrote:
    >
    >> Dave,
    >>
    >> Due to there being an icon stored on the root of each iPod, I don't
    >> *think* there is an icon stored on the system for each one.
    >>
    >> Russell
    >>
    >> On 20 Jan 2009, at 02:38 pm,  wrote:
    >>
    >>> Hi All,
    >>>
    >>> I would like to something similar which is to display the Icons of
    >>> iPods. I can get the .icns files for the iPhone and iPod Touch from:
    >>>
    >>> /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
    >>>
    >>> But where to locate the icons for iPods?
    >>>
    >>> Thanks a lot
    >>> All the Best
    >>> Dave
    >>>
    >>> On 11 Jan 2009, at 19:31, Sandro Noel wrote:
    >>>
    >>>> Greetings
    >>>>
    >>>> I'm looking for a way to programatically get the machine icon
    >>>> from my servers, just like finder does in the finder.
    >>>> for every type of mac it has a different icon, and for windows
    >>>> computers, it;s the nice crash screen icon.
    >>>>
    >>>> I would like my application to represent the network hosts as
    >>>> finder does.
    >>>>
    >>>> I looked over the internet but could not find how finder does it.
    >>>> I did however find the icons in /System/Library/CoreServices/
    >>>> CoreTypes.bundle/Contents/Resources/
    >>>>
    >>>> Any suggestions on where to look??
    >>>>
    >>>> Thank you in advance.
    >>>> Sandro Noel.

    >>

    >
  • iTunes contains a full list of iPod icon (in iTunes.rsrc). Could it be
    responsible to set the iPod icon ?

    Le 20 janv. 09 à 19:40, Russell Hancox a écrit :

    > Dave,
    >
    > Due to there being an icon stored on the root of each iPod, I don't
    > *think* there is an icon stored on the system for each one.
    >
    > Russell
    >
    > On 20 Jan 2009, at 02:38 pm,  wrote:
    >
    >> Hi All,
    >>
    >> I would like to something similar which is to display the Icons of
    >> iPods. I can get the .icns files for the iPhone and iPod Touch from:
    >>
    >> /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
    >>
    >> But where to locate the icons for iPods?
    >>
    >> Thanks a lot
    >> All the Best
    >> Dave
    >>
    >> On 11 Jan 2009, at 19:31, Sandro Noel wrote:
    >>
    >>> Greetings
    >>>
    >>> I'm looking for a way to programatically get the machine icon from
    >>> my servers, just like finder does in the finder.
    >>> for every type of mac it has a different icon, and for windows
    >>> computers, it;s the nice crash screen icon.
    >>>
    >>> I would like my application to represent the network hosts as
    >>> finder does.
    >>>
    >>> I looked over the internet but could not find how finder does it.
    >>> I did however find the icons in /System/Library/CoreServices/
    >>> CoreTypes.bundle/Contents/Resources/
    >>>
    >>> Any suggestions on where to look??
    >>>
    >>> Thank you in advance.
    >>> Sandro Noel.


  • On 21 Jan 2009, at 08:50, Jean-Daniel Dupas wrote:

    > iTunes contains a full list of iPod icon (in iTunes.rsrc). Could it
    > be responsible to set the iPod icon ?
    >
    >
    A convenient way to browse this resource is with ThemePark. Goto menu
    File - Open Special - iTunes.rsrc
    http://www.geekspiff.com/software/themepark/

    > Le 20 janv. 09 à 19:40, Russell Hancox a écrit :
    >
    >> Dave,
    >>
    >> Due to there being an icon stored on the root of each iPod, I don't
    >> *think* there is an icon stored on the system for each one.
    >>
    >> Russell
    >>
    >> On 20 Jan 2009, at 02:38 pm,  wrote:
    >>
    >>> Hi All,
    >>>
    >>> I would like to something similar which is to display the Icons of
    >>> iPods. I can get the .icns files for the iPhone and iPod Touch from:
    >>>
    >>> /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
    >>>
    >>> But where to locate the icons for iPods?
    >>>
    >>> Thanks a lot
    >>> All the Best
    >>> Dave
    >>>
    >>> On 11 Jan 2009, at 19:31, Sandro Noel wrote:
    >>>
    >>>> Greetings
    >>>>
    >>>> I'm looking for a way to programatically get the machine icon
    >>>> from my servers, just like finder does in the finder.
    >>>> for every type of mac it has a different icon, and for windows
    >>>> computers, it;s the nice crash screen icon.
    >>>>
    >>>> I would like my application to represent the network hosts as
    >>>> finder does.
    >>>>
    >>>> I looked over the internet but could not find how finder does it.
    >>>> I did however find the icons in /System/Library/CoreServices/
    >>>> CoreTypes.bundle/Contents/Resources/
    >>>>
    >>>> Any suggestions on where to look??
    >>>>
    >>>> Thank you in advance.
    >>>> Sandro Noel.




    Jonathan Mitchell

    Central Conscious Unit
    http://www.mugginsoft.com
  • Hi,

    Is there some sample code anywhere that renders (e.g. applies the
    mask etc.) an Icon from a .icns file at a given resolution? I'd then
    like to be able to save the rendered image as a JPEG file.

    If anyone knows of some sample code to get me going or can point me
    to the best starting place for this, I'd be really Grateful.

    Thanks a lot

    All the Best
    Dave
  • Le 23 janv. 09 à 14:29, Dave a écrit :

    > Hi,
    >
    > Is there some sample code anywhere that renders (e.g. applies the
    > mask etc.) an Icon from a .icns file at a given resolution? I'd then
    > like to be able to save the rendered image as a JPEG file.
    >
    > If anyone knows of some sample code to get me going or can point me
    > to the best starting place for this, I'd be really Grateful.
    >
    > Thanks a lot
    >
    > All the Best
    > Dave
    >

    An icns file can be opened using NSImage methods.
    Then choose the representation you need and convert it to JPEG as you
    would do with any image.

    If you want to go the "hard" way (that is not that hard):
    Use ReadIconFromFSRef() to load the icns file.
    Convert it into an FSRef using GetIconRefFromIconFamilyPtr().
    And then draw it using PlotIconRefInContext().
  • Hi Jean,

    On 23 Jan 2009, at 13:56, Jean-Daniel Dupas wrote:
    > An icns file can be opened using NSImage methods.
    > Then choose the representation you need and convert it to JPEG as
    > you would do with any image.
    >
    > If you want to go the "hard" way (that is not that hard):
    > Use ReadIconFromFSRef() to load the icns file.
    > Convert it into an FSRef using GetIconRefFromIconFamilyPtr().
    > And then draw it using PlotIconRefInContext().
    >

    Thanks for this. After looking around, I decided to do it the 'hard"
    way, since I already have most of the wrapper code I can steal from
    another module.

    I have a question on this through. How do I fill in the parameters to
    the GetIconRefFromIconFamilyPtr() call? This is my code so far:

    (There may be a few typeo's in this, but it compiles ok)

    CGContextRef        myBitMapContextRef;
    CGBitMapInfo        myBitMapInfo;
    CGColorSpaceRef    myColorSpaceRef;
    CGRect                myImageRect;
    size_t                myImageWidth;
    size_t                myImageHeight;
    size_t                myBitsPerComponent;
    size_t                myNumberOfComponents;
    size_t                myRowBytes;
    char*                myImageBufferPtr;
    RGBColor            myLabelRGBColor:

    IconFamilyHandle     myIconFamilyHandle;
    IconRef                myIconRef;

    // myFSRef is setup ok at this point

    myIconFamilyHandle = NULL;
    myOSErr = ReadIconFromFSRef(&myFSRef,&myIconFamilyHandle);
    if (myOSErr != noErr)
    goto Error;

    myOSErr = GetIconRefFromIconFamilyPtr
    (*myIconFamilyHandle,GetHandleSize(myIconFamilyHandle),&myIconRef);
    if (myOSErr != noErr)
    goto Error;

    myBitMapInfo = kCGImageAlphaPremultipliedLast;
    myImageWidth = 64;
    myImageHeight = 64;
    myBitsPerComponent = 8;
    myNumberOfComponents = 4;
    myRowBytes = COMPUTE_BEST_BYTES_PER_ROW(myImageWidth *
    (myBitsPerComponent / 8) * myNumberOfComponents);
    myImageBufferPtr = malloc(myImageHeight, myRowBytes);
    myColorSpaceRef = GCColorSpaceCreateWithName(kCGColorSpaceGenericRGB);

    myBitMapContextRef = CGBitmapContextCreate
    (myImageBufferPtr,myImageWidth,myImageHeight,myBitsPerComponent,myRowByt
    es, myColorSpaceRef, myBitMapInfo);

    CGContextClearRect(myBitMapContextRef,0,0,myWidth, myImageHeight)

    myImageRect.origin.x = 0;
    myImageRect.origin.y = 0;
    myImageRect.size.width = myImageWidth;
    myImageRect.size.height = myImageHeight;

    myLabelRGBColor.red = 0;
    myLabelRGBColor.green = 0;
    myLabelRGBColor.blue = 0;
    myOSErr = PlotIconRefInContext
    (myBitMapContextRef,&myImageRect,kAlignNone,kTransformNone,
    myLabelRGBColor,kPlotIconRefNormalFlags,myIconRef);

    What should "myLabelRGBColor" be set to?

    Also at this point, I'd like to get a pointer to the Pixel buffer in
    the CGContext and return this. The code I already have will write the
    JPEG file, all I need is a copy of the Pixel Data? Is there a way to
    do this?

    Thanks a lot
    All the Best
    Dave
  • Le 23 janv. 09 à 17:34, Dave a écrit :

    > Hi Jean,
    >
    > On 23 Jan 2009, at 13:56, Jean-Daniel Dupas wrote:
    >> An icns file can be opened using NSImage methods.
    >> Then choose the representation you need and convert it to JPEG as
    >> you would do with any image.
    >>
    >> If you want to go the "hard" way (that is not that hard):
    >> Use ReadIconFromFSRef() to load the icns file.
    >> Convert it into an FSRef using GetIconRefFromIconFamilyPtr().
    >> And then draw it using PlotIconRefInContext().
    >>
    >
    > Thanks for this. After looking around, I decided to do it the 'hard"
    > way, since I already have most of the wrapper code I can steal from
    > another module.
    >
    > I have a question on this through. How do I fill in the parameters
    > to the GetIconRefFromIconFamilyPtr() call? This is my code so far:
    >
    > (There may be a few typeo's in this, but it compiles ok)

    >
    >
    > myIconFamilyHandle = NULL;
    > myOSErr = ReadIconFromFSRef(&myFSRef,&myIconFamilyHandle);
    > if (myOSErr != noErr)
    > goto Error;
    >
    > myOSErr =
    > GetIconRefFromIconFamilyPtr
    > (*myIconFamilyHandle,GetHandleSize(myIconFamilyHandle),&myIconRef);
    > if (myOSErr != noErr)
    > goto Error;

    look fine to me.

    > myBitMapInfo = kCGImageAlphaPremultipliedLast;
    > myImageWidth = 64;
    > myImageHeight = 64;
    > myBitsPerComponent = 8;
    > myNumberOfComponents = 4;
    > myRowBytes = COMPUTE_BEST_BYTES_PER_ROW(myImageWidth *
    > (myBitsPerComponent / 8) * myNumberOfComponents);
    > myImageBufferPtr = malloc(myImageHeight, myRowBytes);
    > myColorSpaceRef = GCColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    >
    > myBitMapContextRef =
    > CGBitmapContextCreate
    > (myImageBufferPtr
    > ,myImageWidth,myImageHeight,myBitsPerComponent,myRowBytes,
    > myColorSpaceRef, myBitMapInfo);
    >
    > CGContextClearRect(myBitMapContextRef,0,0,myWidth, myImageHeight)
    >
    > myImageRect.origin.x = 0;
    > myImageRect.origin.y = 0;
    > myImageRect.size.width = myImageWidth;
    > myImageRect.size.height = myImageHeight;
    >
    > myLabelRGBColor.red = 0;
    > myLabelRGBColor.green = 0;
    > myLabelRGBColor.blue = 0;
    > myOSErr =
    > PlotIconRefInContext
    > (myBitMapContextRef,&myImageRect,kAlignNone,kTransformNone,
    > myLabelRGBColor,kPlotIconRefNormalFlags,myIconRef);
    >
    > What should "myLabelRGBColor" be set to?

    I think you can pass NULL for the label color.

    >
    >
    > Also at this point, I'd like to get a pointer to the Pixel buffer in
    > the CGContext and return this. The code I already have will write
    > the JPEG file, all I need is a copy of the Pixel Data? Is there a
    > way to do this?

    myImageBufferPtr is the pixel buffer.

    To create the image, you can also use an NSImage,

    NSImage *img = [[NSImage alloc] initWithSize:NSMakeSize(myImageWidth,
    myImageHeight)];
    [img lockFocus]
    CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicPort];

    // draw

    [img unlockFocus]

    And now, use NSImage function to save it as a JPEG. It's easier than
    dealing with all the bitmap stuff.

    An other way may be to use CGBitmapContextCreateImage() to create a
    CGImageRef from your context, and then use ImageIO
    (CGImageDestinationRef) to export your image.
  • Hi Jean,

    Thank you so much for your help. I've almost got the code in place
    now. But please see below.

    On 23 Jan 2009, at 17:33, Jean-Daniel Dupas wrote:

    >
    >>
    >>
    >> Also at this point, I'd like to get a pointer to the Pixel buffer
    >> in the CGContext and return this. The code I already have will
    >> write the JPEG file, all I need is a copy of the Pixel Data? Is
    >> there a way to do this?
    >
    > myImageBufferPtr is the pixel buffer.
    >
    > To create the image, you can also use an NSImage,
    >
    > NSImage *img = [[NSImage alloc] initWithSize:NSMakeSize
    > (myImageWidth, myImageHeight)];
    > [img lockFocus]
    > CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicPort];
    >
    > // draw
    >
    > [img unlockFocus]
    >
    > And now, use NSImage function to save it as a JPEG. It's easier
    > than dealing with all the bitmap stuff.
    >
    > An other way may be to use CGBitmapContextCreateImage() to create a
    > CGImageRef from your context, and then use ImageIO
    > (CGImageDestinationRef) to export your image.

    The requirement of the function I am writing has now changed because
    I found a different way of doing it that requires much less changes
    to the rest of the application. Basically there is a framework of
    sorts that calls my function (GetIconImage), all I have to do is to
    render the Icon into a BitMap/PixMap and then return a pointer to it
    from my function, e.g. the function that calls my function need to
    return a buffer that is width * height * 4 in size that contains the
    pixels and everything else will be taken care of!

    So, I if change the bit that computes the Row Bytes value so it is
    (width * 4) and change the malloc to malloc(width * height * 4) then
    just return myImageBufferPtr, this should be ok?

    Also, how to I free the memory allocated by myBitMapContextRef,
    myIconRef and myIconFamily Icon? I can't seem to find dispose/release
    functions for these objects.

    Thanks again, you have been a great help!

    All the Best
    Dave
  • Le 23 janv. 09 à 19:53, Dave a écrit :

    > Hi Jean,
    >
    > Thank you so much for your help. I've almost got the code in place
    > now. But please see below.
    >
    > On 23 Jan 2009, at 17:33, Jean-Daniel Dupas wrote:
    >
    >
    >>
    >>>
    >>>
    >>> Also at this point, I'd like to get a pointer to the Pixel buffer
    >>> in the CGContext and return this. The code I already have will
    >>> write the JPEG file, all I need is a copy of the Pixel Data? Is
    >>> there a way to do this?
    >>
    >> myImageBufferPtr is the pixel buffer.
    >>
    >> To create the image, you can also use an NSImage,
    >>
    >> NSImage *img = [[NSImage alloc]
    >> initWithSize:NSMakeSize(myImageWidth, myImageHeight)];
    >> [img lockFocus]
    >> CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicPort];
    >>
    >> // draw
    >>
    >> [img unlockFocus]
    >>
    >> And now, use NSImage function to save it as a JPEG. It's easier
    >> than dealing with all the bitmap stuff.
    >>
    >> An other way may be to use CGBitmapContextCreateImage() to create a
    >> CGImageRef from your context, and then use ImageIO
    >> (CGImageDestinationRef) to export your image.
    >
    > The requirement of the function I am writing has now changed because
    > I found a different way of doing it that requires much less changes
    > to the rest of the application. Basically there is a framework of
    > sorts that calls my function (GetIconImage), all I have to do is to
    > render the Icon into a BitMap/PixMap and then return a pointer to it
    > from my function, e.g. the function that calls my function need to
    > return a buffer that is width * height * 4 in size that contains the
    > pixels and everything else will be taken care of!
    >
    > So, I if change the bit that computes the Row Bytes value so it is
    > (width * 4) and change the malloc to malloc(width * height * 4) then
    > just return myImageBufferPtr, this should be ok?

    Yes. You should release the CGContext too. If you provide a buffer
    when you create it (this is what you do), your are responsible to free
    it, and so, releasing the bitmap context will not affect it.

    >
    >
    > Also, how to I free the memory allocated by myBitMapContextRef,
    > myIconRef and myIconFamily Icon? I can't seem to find dispose/
    > release functions for these objects.

    All CG type are CoreFoundation objects. So you can use CFRelease to
    free the bitmap context. There is also a CGContextRelease function but
    the doc says that this function is equivalent to CFRelease, except
    that it does not cause an error if the context parameter is NULL.

    For the IconRef, the function is ReleaseIconRef().

    And the icon family is an handle, and should be freed using
    DisposeHandle().

    >
    >
    > Thanks again, you have been a great help!
    >
    > All the Best
    > Dave
    >
  • Hi Jean,

    Thanks, I added the code you suggested and it basically works! I have
    one small problem left in that the colors are shifted, I think the
    routine I am returning the buffer to expects ARGB or BGRA and I am
    returning the opposite! Typical!

    Is there an easy way to get the pixels in the reverse order or do I
    need to swap the bytes myself?

    Thanks in Advance
    All the Best
    Dave

    On 23 Jan 2009, at 19:27, Jean-Daniel Dupas wrote:
    >>
    >> The requirement of the function I am writing has now changed
    >> because I found a different way of doing it that requires much
    >> less changes to the rest of the application. Basically there is a
    >> framework of sorts that calls my function (GetIconImage), all I
    >> have to do is to render the Icon into a BitMap/PixMap and then
    >> return a pointer to it from my function, e.g. the function that
    >> calls my function need to return a buffer that is width * height *
    >> 4 in size that contains the pixels and everything else will be
    >> taken care of!
    >>
    >> So, I if change the bit that computes the Row Bytes value so it is
    >> (width * 4) and change the malloc to malloc(width * height * 4)
    >> then just return myImageBufferPtr, this should be ok?
    >
    > Yes. You should release the CGContext too. If you provide a buffer
    > when you create it (this is what you do), your are responsible to
    > free it, and so, releasing the bitmap context will not affect it.
    >
    >>
    >>
    >> Also, how to I free the memory allocated by myBitMapContextRef,
    >> myIconRef and myIconFamily Icon? I can't seem to find dispose/
    >> release functions for these objects.
    >
    > All CG type are CoreFoundation objects. So you can use CFRelease to
    > free the bitmap context. There is also a CGContextRelease function
    > but the doc says that this function is equivalent to CFRelease,
    > except that it does not cause an error if the context parameter is
    > NULL.
    >
    > For the IconRef, the function is ReleaseIconRef().
    >
    > And the icon family is an handle, and should be freed using
    > DisposeHandl
  • Opps! I sent this by mistake, I already found the solution this
    weekend, I just changed the BitmapInfo to
    kCGImageAlphaPremulitipledFirst and all is well!

    Thanks a lot for your help, it's almost all working now.

    All the Best
    Dave

    Hi Jean,

    Thanks, I added the code you suggested and it basically works! I have
    one small problem left in that the colors are shifted, I think the
    routine I am returning the buffer to expects ARGB or BGRA and I am
    returning the opposite! Typical!

    Is there an easy way to get the pixels in the reverse order or do I
    need to swap the bytes myself?

    Thanks in Advance
    All the Best
    Dave

    On 23 Jan 2009, at 19:27, Jean-Daniel Dupas wrote:
    >>
    >> The requirement of the function I am writing has now changed
    >> because I found a different way of doing it that requires much
    >> less changes to the rest of the application. Basically there is a
    >> framework of sorts that calls my function (GetIconImage), all I
    >> have to do is to render the Icon into a BitMap/PixMap and then
    >> return a pointer to it from my function, e.g. the function that
    >> calls my function need to return a buffer that is width * height *
    >> 4 in size that contains the pixels and everything else will be
    >> taken care of!
    >>
    >> So, I if change the bit that computes the Row Bytes value so it is
    >> (width * 4) and change the malloc to malloc(width * height * 4)
    >> then just return myImageBufferPtr, this should be ok?
    >
    > Yes. You should release the CGContext too. If you provide a buffer
    > when you create it (this is what you do), your are responsible to
    > free it, and so, releasing the bitmap context will not affect it.
    >
    >>
    >>
    >> Also, how to I free the memory allocated by myBitMapContextRef,
    >> myIconRef and myIconFamily Icon? I can't seem to find dispose/
    >> release functions for these objects.
    >
    > All CG type are CoreFoundation objects. So you can use CFRelease to
    > free the bitmap context. There is also a CGContextRelease function
    > but the doc says that this function is equivalent to CFRelease,
    > except that it does not cause an error if the context parameter is
    > NULL.
    >
    > For the IconRef, the function is ReleaseIconRef().
    >
    > And the icon family is an handle, and should be freed using
    > DisposeHandl
previous month january 2009 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Go to today