Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6644705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:11:53+00:00 2026-05-26T00:11:53+00:00

If I create an NSImage via something like: NSImage *icon = [NSImage imageNamed:NSImageNameUser]; it

  • 0

If I create an NSImage via something like:

NSImage *icon = [NSImage imageNamed:NSImageNameUser];

it only has one representation, a NSCoreUIImageRep which seems to be a private class.

I’d like to archive this image as an NSData but if I ask for the TIFFRepresentation I get a
small icon when the real NSImage I originally created seemed to be vector and would scale up to fill my image views nicely.

I was kinda hoping images made this way would have a NSPDFImageRep I could use.

Any ideas how can I get an NSData (pref the vector version or at worse a large scale bitmap version) of this NSImage?

UPDATE

Spoke with some people on Twitter and they suggested that the real source of these images are multi resolution icns files (probably not vector at all). I couldn’t find the location of these on disk but interesting to hear none-the-less.

Additionally they suggested I create the system NSImage and manually render it into a high res NSImage of my own. I’m doing this now and it’s working for my needs. My code:

+ (NSImage *)pt_businessDefaultIcon
{
    // Draws NSImageNameUser into a rendered bitmap. 
    // We do this because trying to create an NSData from 
    // [NSImage imageNamed:NSImageNameUser] directly results in a 32x32 image.
    NSImage *icon = [NSImage imageNamed:NSImageNameUser];
    NSImage *renderedIcon = [[NSImage alloc] initWithSize:CGSizeMake(PTAdditionsBusinessDefaultIconSize, PTAdditionsBusinessDefaultIconSize)];
    [renderedIcon lockFocus]; 
    NSRect inRect = NSMakeRect(0, 0, PTAdditionsBusinessDefaultIconSize, PTAdditionsBusinessDefaultIconSize);
    NSRect fromRect = NSMakeRect(0, 0, icon.size.width, icon.size.width);;
    [icon drawInRect:inRect fromRect:fromRect operation:NSCompositeCopy fraction:1.0];
    [renderedIcon unlockFocus];

    return renderedIcon;
}

(Tried to post this as my answer but I don’t have enough reputation?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:11:54+00:00Added an answer on May 26, 2026 at 12:11 am

    Both of your major questions are answered in the Cocoa Drawing Guide (companion guide linked from the NSImage API reference) has an Images section you really need to read thoroughly and refer to any time you have rep/caching/sizing/quality issues.

    …if I ask for the TIFFRepresentation I get a small icon when the
    real NSImage I originally created seemed to be vector and would scale
    up to fill my image views nicely.

    Relevant subsections of the Images section for this question are: How an Image Representation is Chosen, Images and Caching, and Image Size and Resolution. By default, the -cacheMode for a TIFF image "Behaves as if the NSImageCacheBySize setting were in effect." Also, for in-memory scaling/sizing operations, -imageInterpolation is important: "Table 6-4 lists the available interpolation settings." and "NSImageInterpolationHigh – Slower, higher-quality interpolation."

    I’m fairly certain this applies to a named system image as well as any other.

    I was kinda hoping images made [ by loading an image from disk ] would
    have a NSPDFImageRep I could use.

    Relevant subsection: Image Representations. "…with file-based images, most of the images you create need only a single image representation." and "You might create multiple representations in the following situations, however: For printing, you might want to create a PDF representation or high-resolution bitmap of your image."

    You get the representation that suits the loaded image. You must create a PDF representation for a TIFF image, for example. To do so at high resolution, you’ll need to refer back to the caching mode so you can get higher-res items.

    There are a lot of fine details too numerous to list because of the high number of permutations of images/creation mechanisms/settings/ and what you want to do with it all. My post is meant to be a general guide toward finding the specific information you need for your situation.

    For more detail, add specific details: the code you attempted to use, the type of image you’re loading or creating — you seemed to mention two different possibilities in your fourth paragraph — and what went wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an NSImage which comes from a PDF. When I initially create
I got a image with only one representation, and that was a NSCGImageSnapshotRep .
I am trying to create an application that will have a tray icon only,
I need to create a base64 string representation of an NSImage cocoa object. What's
I need to create an NSImage from a url and then set it to
I am trying to make a simple that needs to create an NSImage and
I'm trying to flip an NSImage created with a NSImageBitmapRep representation. After some digging
Currently I'm drawing an NSImage in a custom NSCell like so: - (void)drawInteriorWithFrame:(NSRect)theCellFrame inView:(NSView
I am trying to create a NSImage or NSImageCell with rounded corners inside a
I am working in NSImage i want to create watermark in NSImage how can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.