on Mac OS X, an NSImage object is a high-level class for manipulating image data
Questions tagged [nsimage]
681 questions
4
votes
1 answer
Thin white lines being added when cropping an image (Objective-C OSX)
I am cutting up a large image and saving it into many different images. I first implemented this in iOS and it is working fine, but when I try and port the code to OSX, a thin white line (1 pixel) appears on the top and right of the image. The line…

lindon fox
- 3,298
- 3
- 33
- 59
4
votes
1 answer
Create a padded, centered, scaled NSImage
I'm putting a fixed size icon based on an arbitrarily sized image into an NSOutlineView using an NSImageCell.
NSImageCell will scale the image down nicely, but I can't find a way to add padding around the scaled image. The rows look ugly to my eye…

Jeffrey Harris
- 3,480
- 25
- 30
3
votes
1 answer
Human-readable strings for [NSImage imageTypes] identifiers?
Put simply, how does one retrieve a human-readable string (for instance, "Portable Network Graphics") for the type of identifier found in the array returned by [NSImage imageTypes] (for instance, "public.png" or "com.microsoft.bitmap")? I've read…

John Wells
- 1,139
- 1
- 10
- 27
3
votes
0 answers
How can I save the image from IKImageView?
Okay... I want to save the visible rectangle of the IKImageView image only.
My problem is that, somehow, if I had an image in portrait mode it will be not saved in the right orientation. I drawing the image with this code:
[sourceImg…

xnz
- 63
- 1
- 5
3
votes
1 answer
Is it possible to check if an image stored in an NSimage object is grayscale?
Is there a simple method for checking if an NSImage Object contains a grayscale image?
What I am trying to do is count the number of colour and black and white pages within a pdf. As far as I can tell the only real solution to this is to render the…

Chris Hattrell
- 33
- 2
3
votes
1 answer
Is there a counterpart to NSImageNameFolder for files?
NSImage comes with a number of system images. One of them being NSImageNameFolder for a generic folder icon.
What about a generic image for a single file or document? There does not seem to be such a thing as NSImageNameDocument...

Mark
- 6,647
- 1
- 45
- 88
3
votes
1 answer
Swift read writing images take a lot of memory
I'm writing an app in Swift for macOS that superposes images.
It works fine but when I do it a lot of time, memory goes through the roof.
I tried to create a small project to read one image, and write it 1000 times.
The image is 15K.
It takes the…

n savoini
- 422
- 1
- 3
- 13
3
votes
1 answer
Setting an image on NSImageView
I'm having a problem with my program. Basically what i want is, i have 2 nssecuretextfield and i have a button. if both are equal, it shows one image on the nsimageview, if not it displays other image. This could be very easy, but i'm new to mac…

Pedro Vieira
- 3,330
- 3
- 41
- 76
3
votes
1 answer
Fasted way to detect and remove transparent space around NSImage
What is the fastest way to trim an image (NSImage or CGImageRef) so that all transparent areas around the image are removed?
I'd imagine I could look at each pixel starting from the top and determine its alpha value, but maybe there's another…

Mark
- 1,447
- 2
- 14
- 26
3
votes
1 answer
SwiftUI - onDrag Argument type 'NSImage' does not conform to expected type 'NSItemProviderWriting'
I'm trying several ways to implement image dragging (from my app to other apps) in macOS but none of them is working.
The image is a Data() object, which was taken from the clipboard, not an URL.
My code:
.onDrag {
return NSItemProvider(object:…

Simon Pham
- 1,603
- 1
- 10
- 15
3
votes
1 answer
Drawing text on an NSImage
I am struggling to find any good tutorials or posts about how to draw some text onto an NSImage. I have a feeling this is a pretty simple process but I just can't work it out!
I already have an NSImage and i need to end up with a manipulated NSImage…

tarnfeld
- 25,992
- 41
- 111
- 146
3
votes
1 answer
How does NSImage's data retaining behaviour work?
I have a method that constantly loads new image data from the web. Whenever all data for an image has arrived, it is forwarded to a delegate like this:
NSImage *img = [[NSImage alloc] initWithData:dataDownloadedFromWeb];
if([[self delegate]…

carsten
- 31
- 2
3
votes
2 answers
Embedding PNG image and other resources into OS X executable
Modern applications are centered around graphics. Graphics that display information to the user or provide a creative, artsy touch to that otherwise grey application. Most of the time, it makes sense to load graphics at runtime: in image editing…

Hackstaar
- 233
- 2
- 13
3
votes
1 answer
NSImage Overlay/Mask Gradient like iOS
I'm looking to replicate with Cocoa/Core Graphics the process which seems to occur on iOS when setting an image for a UITabBarItem. When the tab bar item is selected, the image is overlayed with a gradient.
For example,
becomes...
I'm unsure…

JoeR
- 1,901
- 3
- 25
- 39
3
votes
1 answer
Maximum bitmap image size for NSImage or CGImage?
I generate bitmap images with Cocoa using NSImage or CGImage (UIImage would work similar probably)
How do I determine what would be the maximum image size I can generate?
I guess it should be in some relation to the memory available?

MartinW
- 4,966
- 2
- 24
- 60