on Mac OS X, an NSImage object is a high-level class for manipulating image data
Questions tagged [nsimage]
644 questions
77
votes
9 answers
How to save a NSImage as a new file
How can I save a NSImage as a new file (png, jpg, ...) in a certain directory?
![](../../users/profiles/264529.webp)
burki
- 2,666
- 4
- 33
- 49
30
votes
6 answers
How to save PNG file from NSImage (retina issues)
I'm doing some operations on images and after I'm done, I want to save the image as PNG on disk. I'm doing the following:
+ (void)saveImage:(NSImage *)image atPath:(NSString *)path {
[image lockFocus] ;
NSBitmapImageRep *imageRepresentation…
![](../../users/profiles/596857.webp)
Ludovic Landry
- 10,946
- 9
- 45
- 79
29
votes
4 answers
NSImage size not real size with some pictures?
I see that sometimes NSImage size is not real size (with some pictures) and CIImage size is always real. I was testing with this image.
This is source code which I wrote for testing:
NSImage *_imageNSImage = [[NSImage…
![](../../users/profiles/1028709.webp)
Justin Boo
- 9,954
- 7
- 48
- 71
25
votes
1 answer
Getting NSImage from CGImageRef
I am trying process an image in CoreGraphics and then return the processed image back to an NSImage for saving and displaying. I have ample resources on how to perform these functions in iOS but the helper methods seem to be missing in NSImage. In…
![](../../users/profiles/498994.webp)
MobileOverlord
- 4,520
- 3
- 20
- 29
25
votes
10 answers
How to resize NSImage?
I have an NSBitmapImageRep which is WxH size.
I create NSImage and call addRepresentation:. Then I need to resize the NSImage.
I tried setSize method but it doesn't work. What should I do?
![](../../users/profiles/1428622.webp)
hockeyman
- 955
- 6
- 27
- 55
21
votes
5 answers
Get the correct image width and height of an NSImage
I use the code below to get the width and height of a NSImage:
NSImage *image = [[[NSImage alloc] initWithContentsOfFile:[NSString stringWithFormat:s]] autorelease];
imageWidth=[image size].width;
imageHeight=[image…
![](../../users/profiles/262325.webp)
arachide
- 7,640
- 17
- 66
- 128
18
votes
4 answers
How to draw a NSImage like images in NSButtons (with a deepness)?
Is there any way to draw an NSImage like images in NSButtons or other cocoa interface elements?
Here are examples:
Apple uses pdf's with black icons:
![](../../users/profiles/239936.webp)
Flocked
- 1,888
- 2
- 36
- 56
17
votes
1 answer
NSImage to NSData as PNG Swift
I am writing a Mac app based on an iOS app. The code below converts a UIImage to NSData to upload to Parse.com.
I would like to do the same for Mac but I do not seem to be able to convert it to NSData. What should I be doing?
Thanks
var image =…
![](../../users/profiles/3976008.webp)
Tom Coomer
- 5,449
- 12
- 38
- 76
17
votes
5 answers
Swift NSImage to CGImage
How can I convert a NSImage to CGImage in Swift? In Objective-C I did it like this:
- (CGImageRef)CGImage {
NSData *imageData = self.TIFFRepresentation;
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)imageData,…
![](../../users/profiles/2062613.webp)
Lupurus
- 2,819
- 2
- 24
- 48
17
votes
3 answers
Converting CIImage Into NSImage
I'm playing with the Core Image framework. As I understand, if I have an image (NSImage), it needs to be converted into CIImage, first. I can do that.
NSImage *im1 = [[NSImage alloc] initWithContentsOfFile:imagepath];
NSRect rect1;rect1.size.width…
![](../../users/profiles/1824524.webp)
El Tomato
- 5,656
- 5
- 41
- 66
15
votes
5 answers
Turning an NSImage* into a CGImageRef?
Is there an easy way to do this that works in 10.5?
In 10.6 I can use nsImage CGImageForProposedRect: NULL context: NULL hints: NULL
If I'm not using 1b black and white images (Like Group 4 TIFF), I can use bitmaps, but cgbitmaps seem to not like…
![](../../users/profiles/53491.webp)
Brian Postow
- 10,227
- 14
- 69
- 113
15
votes
2 answers
How to composite several NSImages into one big image?
I have a collection of objects which describe an image-name, its size and it's X/Y location. The collection is sorted by "layers", so I can composite the images in a sort of painter's algorithm.
From this, I can determine the rectangle necessary to…
![](../../users/profiles/34820.webp)
Olie
- 23,933
- 18
- 92
- 129
15
votes
3 answers
NSImage to NSBitmapImageRep
How to convert NSImage to NSBitmapImageRep? I have code:
- (NSBitmapImageRep *)bitmapImageRepresentation
{
NSBitmapImageRep *ret = (NSBitmapImageRep *)[self representations];
if(![ret isKindOfClass:[NSBitmapImageRep class]])
{
…
![](../../users/profiles/1428622.webp)
hockeyman
- 955
- 6
- 27
- 55
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…
![](../../users/profiles/460366.webp)
OZG
- 499
- 6
- 16
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.
![](../../users/profiles/1565490.webp)
Amitg2k12
- 3,723
- 9
- 45
- 92