Questions tagged [nsimage]

on Mac OS X, an NSImage object is a high-level class for manipulating image data

681 questions
15
votes
4 answers

NSImage to NSData, then to UIImage

I am creating a plist from my OSX app that contains some images. I am writing the image by : [NSKeyedArchiver archivedDataWithRootObject:self.someImage] Then I am using this plist file as a template for iOS app, but here I can't convert the file to…
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
14
votes
3 answers

how to code NSButton to look just like image

Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means: 1. No…
OZG
  • 509
  • 7
  • 19
14
votes
3 answers

How can I load an NSImage representation of the icon for my application?

I have a custom icon file (MyApp.icns) set up for my Cocoa App. How can I access an NSImage representation of the icon from within my application? Something like the following would be perfect: NSImage * iconImage = [MyApplication…
e.James
  • 116,942
  • 41
  • 177
  • 214
13
votes
1 answer

NSTextView insert image in between text

Is it possible to insert an image (not a background image) into an NSTextView? Something like: Hi :) How are you? and it should display a "smiley" image. I have an NSTextView and an NSImage.
Amitg2k12
  • 3,765
  • 10
  • 48
  • 97
13
votes
1 answer

How to get NSImage of generic folder icon on OS X 10.5 and 10.6

I'm writing a Cocoa application that displays the contents of an archive file in an NSOutlineView. I provide a custom icon for an NSBrowserCell in the outline column, and it works great, but I ran into a little snag — using [NSImage…
Quinn Taylor
  • 44,553
  • 16
  • 113
  • 131
12
votes
3 answers

UIImage vs NSImage: Drawing to an off screen image in iOS

In mac osx (cocoa), It is very easy to make a blank image of a specific size and draw to it off screen: NSImage* image = [[NSImage alloc] initWithSize:NSMakeSize(64,64)]; [image lockFocus]; /* drawing code here */ [image unlockFocus]; However, in…
mtmurdock
  • 12,756
  • 21
  • 65
  • 108
12
votes
3 answers

Loading image from Assets to NSImage keep getting error, expecting NSImage.Name

I am trying to load a file from xcassets to an NSImage, where the asset name is logo. I tried this: let logoIcon = NSImage(named: "logo") But I keep getting this error: Cannot convert value of type 'String' to expected argument type…
Lars Nielsen
  • 2,005
  • 2
  • 25
  • 48
12
votes
3 answers

How do I get the icon of the user's Mac?

Using Objective-C and Cocoa, does anyone know how to get the icon for a user's computer (the one that shows under "Devices" and "Network" in Finder)? Not the harddisk icon, the actual one for a user's device. It ranges from a MacBook icon to the Mac…
Alex B
  • 1,438
  • 13
  • 17
10
votes
2 answers

NSImage to cv::Mat and vice versa

while working with OpenCV I need to convert a NSImage to an OpenCV multi-channel 2D matrix (cvMat) and vice versa. What's the best way to do it? Greets, Dom
dom
  • 11,894
  • 10
  • 51
  • 74
10
votes
1 answer

What's the best way to load an image from a framework in OS X Yosemite (10.10)?

I'm working on a Yosemite app that includes a Notification Center widget (or Today extension). I have a framework where I'm storing all of my shared code and resources, which includes some images. Whether I just use PNGs or an asset catalog, they…
robotspacer
  • 2,732
  • 2
  • 28
  • 50
10
votes
6 answers

Get pixels and colours from NSImage

I have created an NSImage object, and ideally would like to determine how many of each pixels colour it contains. Is this possible?
Nippysaurus
  • 20,110
  • 21
  • 77
  • 129
10
votes
3 answers

How to create 8-, 4-, and 1-bit representations of NSImage

I had created 32 bit NSImage with following code. NSBitmapImageRep *sourceRep = [[NSBitmapImageRep alloc] initWithData: imageData]; // create a new bitmap representation scaled down NSBitmapImageRep *newRep = …
NewStack
  • 990
  • 8
  • 19
9
votes
1 answer

Loading NSImage with imageNamed from xcassets crash in older osx versions

So, I have an xcassets that is shared amongst quite a few apps. I'm developing with Xcode8 in a Mac Mini with MacOs Sierra installed in it. If I compile and run in the development machine, there's no issue at all. However, when I try to run it in a…
leandrodemarco
  • 1,552
  • 1
  • 15
  • 22
9
votes
2 answers

Rendering the same image with different sizes

I have bunch of images in my assets. What I am trying to do is render the image in status bar of OSX as following: let icon = NSImage(named: "statusIcon") icon?.size = NSSize.init(width: 18, height: 18) icon?.template = true statusItem.image =…
Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
9
votes
4 answers

How to make a perfect crop (without changing the quality) in Objective-c/Cocoa (OSX)

Is there any way in Objective-c/cocoa (OSX) to crop an image without changing the quality of the image? I am very near to a solution, but there are still some differences that I can detect in the color. I can notice it when zooming into the text.…
lindon fox
  • 3,298
  • 3
  • 33
  • 59
1
2
3
45 46