683 questions
2
votes
0
answers
97
views
How to disable HDR drawing of NSImage
I have regular NSImage from iPhone and the drawing get's extremely choppy during window resize (especially at small window sizes below 100px). When the window size is large there is no problem with ...
0
votes
1
answer
34
views
macOS How to get rid of highlighted background for my NSStatusBar.system.statusItem
I am showing a menu bar button for my app:
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
if let button = statusItem.button, let img = NSImage(named: "...
0
votes
1
answer
150
views
How to get the 'com.apple.icns' data of a file for filling the pasteboard?
When one copies a file in Finder, the pasteboard contains a 'icns' type with the various icon descriptions of the copied item(s).
I need to accomplish the same effect in my code, i.e. generate the ...
-1
votes
1
answer
96
views
How to upload an image file to a MacOS app? [closed]
I'm creating an app which requires the user to upload image files to the app.
In the app I want to obtain its info (dimensions, ecc.) and show it.
Here is what I tried:
var body: some View {
...
0
votes
0
answers
57
views
Problems in saving NSView with subviews to PDF
I have an NSView with NSImage instances as subviews that all show up correctly on the screen. I want to save them to a PDF file but the subviews are not included.
The routine works well and also saves ...
1
vote
0
answers
125
views
Converting [NSImage imageTypes] to UTType array
I am trying to use the new -[NSOpenPanel setAllowedContentTypes:] and looking for equivalent of -[NSOpenPanel setAllowedFileTypes:[NSImage imageTypes]].
Is this equivalent:
openPanel....
0
votes
1
answer
57
views
Number of assets in asset catalog causes NSImage to be unclickable
I'm having an issue where when my asset catalog have more than 2 images (all have @1x @2x and @3x), my NSImage in my NSImageView cannot be clicked. Does anyone know why this happens?
Thanks in advance!...
2
votes
2
answers
3k
views
Capture of variable with non-sendable type NSImage in a '@Sendable closure'
I'm new to swift concurrency, I noticed that my code freezes UI when trying to initialize NSImage, so I decided to do it on the global thread like this:
func chooseImage() {
Task { @MainActor in
...
0
votes
0
answers
54
views
Detect and remove excess solid color padding around and NSImage
I'm trying to build an macos utility to help me center the content of the image and not sure how I would achieve such. For example let say that I have an image as below:
As you can see there's more ...
1
vote
0
answers
91
views
NSImage resizing 10bit image using CGContext
I have 10 bit image file (HEIC, AVIF) loaded using NSImage. When attempting to resize using CGContext I get following message multiple times
This method should not be called on the main thread as it ...
2
votes
1
answer
91
views
Transform two NSImages on top of each other into a single NSImage without using `lockFocus`
I have a large image and a smaller image, both in Data type which I transformed into NSImage. I want to put the smaller image on top of the large image, top-left aligned, in a new single NSImage.
...
2
votes
0
answers
151
views
Strange Overlay with NSWorkspace.shared.icon(forFile: )
I am currently experiencing strange behavior when determining icons for files. When I determine icons using
let icon = NSWorkspace.shared.icon(forFile: path)
it generally works fine. However, for ...
0
votes
1
answer
76
views
How to create NSImage from pixel array in Xcode for macOS app
Developing apps for iOS, it is simple to extract pixels from UIImage, manipulate them, then reconstruct an UIImage from them, example:
csr = CGColorSpaceCreateDeviceRGB();
ctx = CGBitmapContextCreate(...
0
votes
1
answer
364
views
How to make a CALayer with NSImage dynamically adapt to the app appearance?
I have an NSView whose layer has various sublayers.
Its needsDisplay property is set to YES when the app changes its effective appearance, which ends up calling:
-(void)updateLayer {
// this is ...
1
vote
1
answer
415
views
How can I scale an image while retaining quality when creating a PDF in Swift on macOS?
I have a command-line Swift script that takes a series of images of close to the same pixel dimensions and creates a PDF from them. Part of what this script does is normalize the images so that each ...