on Mac OS X, an NSImage object is a high-level class for manipulating image data
Questions tagged [nsimage]
681 questions
5
votes
2 answers
NSImage and retina display confusion
I want to add crosses on a NSImage, here's my code:
-(NSSize)convertPixelSizeToPointSize:(NSSize)px
{
CGFloat displayScale = [[NSScreen mainScreen] backingScaleFactor];
NSSize res;
res.width = px.width / displayScale;
res.height =…

Irwan
- 783
- 1
- 13
- 28
4
votes
1 answer
How to convert 256 colors palettized RGBA image data to NSImage
I'm a newbie developer and I need your help with something that is probably trivial for you.
I have an image data in this pixel format: 256 colors palettized RGBA. It comes from FFmpeg (PIX_FMT_PAL8) and it's explained this way:
PIX_FMT_RGB32 is…

Andrea3000
- 1,018
- 1
- 11
- 26
4
votes
3 answers
How to stop NSImage lockfocus from Leaking Memory in an NSOperation?
I have a problem with NSImages leaking memory when I draw to them with lock/unlockfocus. The leak goes away when I comment out the LEAKS HERE code below. So I know that is where the leak is happening.
for(int i= 0; i < nNumberImages; ++i)
{
…

Mark
- 408
- 3
- 12
4
votes
1 answer
setColor on NSBitmapImageRep not working in Swift
I'm trying to figure out how setColor works. I have the following code:
lazy var imageView:NSImageView = {
let imageView = NSImageView(frame: view.frame)
return imageView
}()
override func viewDidLoad() {
…

Ben A.
- 874
- 7
- 23
4
votes
1 answer
Cropping is not working perfectly as per the frame drawn
I am trying to crop a selected portion of NSImage which is fitted as per ProportionallyUpOrDown(AspectFill) Mode.
I am drawing a frame using mouse dragged event like this:
class CropImageView: NSImageView {
var startPoint: NSPoint!
var…

Shivam Tripathi
- 1,405
- 3
- 19
- 37
4
votes
1 answer
How to scale axes independently at runtime on an NSButton
In Interface Builder, you can select how you want a button's image to be scaled, choosing either Axes Independent, Proportionally Down, etc. for the "Scaling" drop-down. How can I access or change this attribute of the NSButton at runtime?

Regan
- 1,487
- 2
- 28
- 43
4
votes
1 answer
Display NSImage from NSData
My target is to display an image in a view.
Considering I've an:
IBOutlet NSImageView *image for display my image
NSData *imageData for readig the image file
NSImage *imageView
In imageData is stored the image (I've used initWithContentsOfFile…

Matteo
- 41
- 1
- 3
4
votes
1 answer
Resizing NSImage Shifts its Origin and Producing Wrong Results
I'm using the following code to Resize an Image(Keeping Aspect Ratio).When I try to resize an Image whose size is 2432X3648 Pixels to 1800X2700 Pixels
The output image origin gets shifted.
extension NSImage {
func resizeTo(width: CGFloat,…

techno
- 6,100
- 16
- 86
- 192
4
votes
3 answers
NSImage DPI Question
Can anyone tell me how I can get the true width and height of an NSImage? I have noticed that images that are a higher DPI than 72 come through with inaccurate width and height with the NSImage.size parameters.
I saw this example on…

mootymoots
- 4,545
- 9
- 46
- 74
4
votes
2 answers
NSImages to PDFs and merge them in Swift
I have an array with some NSImages in it.
I mainly want to convert NSImage to PDF. So, can anyone show me how to do it in Swift.
If possible, could you guys show me how to merge PDFs into one and output it as well?
Thank you so much.

user2367447
- 37
- 1
- 7
4
votes
1 answer
Convert CGImage to NSImage Swift
I am trying to display a CGImage in a NSImageView box and I am having trouble converting the CGImage to a NSImage. How should I approach this situation ? Thank you!

ch_studend
- 91
- 2
- 10
4
votes
3 answers
Creating an NSImage from bitmap data
Ok, it appears that the I'm creating a PDFDocument where pixelWidth is incorrect in the images that I created. So the question becomes: How do I get the correct resolution into the image?
I start with bitmap data from a scanner. I'm doing…

Brian Postow
- 11,709
- 17
- 81
- 125
4
votes
6 answers
Rotate NSImage in Swift, Cocoa, Mac OSX
Is there an easy way to rotate a NSImage in a Mac OSX app? Or just set the orientation from portrait to landscape using Swift?
I am playing around with CATransform3DMakeAffineTransform but I can't get it to work.…

stefOCDP
- 803
- 2
- 12
- 20
4
votes
3 answers
NSImage different size in code different shown by Finder/Preview
I have a couple of images that i use in my application(one of them is attached). The strange thing is that the real image size(shown by finder and preview) is 1200x701 px.
When I access image from the code and as for its size, I get 360x210px. What…

krasnyk
- 3,458
- 3
- 24
- 20
4
votes
3 answers
NSImageView ClipsToBounds
I have an iOS app that uses the code below. I am now creating the app for Mac OS X and would like the same effect however I do not seem to be able to use clipsToBounds. What should I be using?
I have the rest of the code working on the Mac, just not…

Tom Coomer
- 6,227
- 12
- 45
- 82