Re: Resolution-independent toolbar icons
Re: Resolution-independent toolbar icons
- Subject: Re: Resolution-independent toolbar icons
- From: Scott Andrew <email@hidden>
- Date: Sat, 16 Jun 2007 21:26:43 -0700
Ricky.. What format are you saving your resources in?
Scott
On Jun 16, 2007, at 8:35 AM, Ricky Sharp wrote:
On Jun 16, 2007, at 9:18 AM, Phill Kelley wrote:
I've been experimenting with resolution independence on toolbar
icons.
All my icon artwork starts life in Adobe Illustrator and, up until
now, has
moved through Photoshop and tiffutil on its way to my application.
The
icons were originally drawn within a 128x128 pixel bounding box
but I would
scale each to 25% in Illustrator so that I would get 32x32 icons
when the
artwork was pasted into Photoshop.
I assumed that "resolution independence" would mean that I could
forget
about the 25% scaling step. I just saved each to a PDF, changed
the toolbar
item building method to point to the PDFs instead of the tiffs,
and rebuilt
the app.
You really have two options for dealing with res-ind:
(1) use vector-based artwork. I do this myself for 99%+ of my
artwork. I also use Illustrator.
(2) use multi-resolution TIFFs. I believe the Tiger and later has
a tiffutil command-line tool that lets you merge TIFF images
together. Here, create at least two resolutions: One 72dpi and one
288dpi. Cocoa will choose the right dpi flavor to render depending
upon the current scale factor. I use this approach for large
cursors (images fed to NSCursor).
When I launched the app, each toolbar item icon had a white
background. I
double-checked that the PDFs had transparent backgrounds - they
did. I also
blew away the NSToolbar Configuration stuff in the app's
preferences file
in case that was interfering but it made no difference.
I cannot speak to this issue as my UI is completely custom.
However, when you say transparent backrounds, are you adding a
rectangle in your PDF and setting its transparency? You don't need
to do that, if that's the case.
This may though be a limitation of using PDFs with toolbars? For
example, when I render my PDF images, I always use:
drawInRect:fromRect:operation:fraction:
where operation is NSCompositeSourceOver and fraction is set as
needed (usually just 1.0).
This is a document-based app. The next thing I noticed was that
the white
backgrounds were only present on the first document opened (whether a
default untitled document or double-clicking a document to cause
the app to
launch). For the second and subsequent documents, the toolbar
icons get
transparent backgrounds.
I also noticed that anything that caused an icon to redraw would
fix the
problem for that icon. Something like customizing the toolbar of
the first
document (adding or removing an icon, or changing between small
and large
icon sizes), would immediately redraw all the toolbar icons with
transparent backgrounds.
Then I wondered whether the nominal 128x128 starting size was the
cause of
my problems so I created 32x32 PDFs. That did cause a change - all
toolbar
icons always get white backgrounds.
If using the multi-res TIFF approach, again, create two flavors.
If the default size is 32x32 pts, make that the size of the 72dpi
TIFF. The 128x128 TIFF would then be your 288dpi flavor.
I am setting the image via:
NSImage *image = [NSImage imageNamed:@"example.pdf"];
[image setBackgroundColor:[NSColor clearColor]]; // should be
default
anyway
[toolbarItem setImage:image];
This is all under 10.4.9 but to forestall the obvious questions as to
whether I have tried it with a "later" version of the OS, let's
just say
that I have no reason to believe that there are any differences.
Has anyone else been traveling down a similar path to
resolution-independent toolbar icons? Any suggestions?
Regards, PK
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40adelphia.net
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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