nsimage

AFNetworking 2 - Image upload - Request failed: unsupported media type (415)

偶尔善良 提交于 2019-12-10 21:07:31
问题 I know this question was answered multiple times, but I tried all the answers with no luck. I don't think that I do something fundamentally wrong but something goes definitely wrong here. I use the following code to upload PNG files to tinypng.com. As far as I can see the upload itself works, but I receive the error message: Request failed: unsupported media type (415) The images I use are loaded as JPEG, then resized and transformed to PNG format. The saved files are fine. Now I want send

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

我是研究僧i 提交于 2019-12-10 19:25:43
问题 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 'NSImage.Name' I have looked into the Apple Dev Documentation and from what I can tell this is correct. But for some reason I keep getting the error. I am trying to do it on macOS if that makes a difference EDIT: So I am trying to make a top menu bar app. And I

Image inside NSScrollView drawing on top of other views

亡梦爱人 提交于 2019-12-10 10:59:35
问题 I have a custom NSView that lives inside of a NSScrollView that is in a NSSplitView . The custom view uses the following drawing code: - (void)drawRect:(NSRect)dirtyRect { NSGraphicsContext *ctx = [NSGraphicsContext currentContext]; [ctx saveGraphicsState]; // Rounded Rect NSRect rect = [self bounds]; NSRect pathRect = NSMakeRect(rect.origin.x + 3, rect.origin.y + 6, rect.size.width - 6, rect.size.height - 6); NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:pathRect cornerRadius

Cocoa draw text on NSImage

混江龙づ霸主 提交于 2019-12-10 06:08:19
问题 I have an NSSegmentedControl(todayButton) that contains an image. I'm trying to draw some text onto the image using the following: NSImage *img = [todayButton imageForSegment:0] [img lockFocus] [@"15" drawAtPoint:NSZeroPoint withAttributes:nil] [img unlockFocus] [img setTemplate:YES] The image gets set as a template and no errors are thrown but no text appears on the image. 回答1: I may be entirely wrong, but my gut tells me you may be running into NSImage caching issues. The system caches

How to read PNG image to NSImage

狂风中的少年 提交于 2019-12-09 11:13:36
问题 how can i read PNG image to NSImage. I tried the following way,but when i get the width and size of the image i'm getting some weird value.. if any one can direct me in right path.. highly appropriate.. NSImage * picture = [[NSImage alloc] initWithContentsOfFile: [bundleRoot stringByAppendingString:tString]]; NSLog(@"sixe %d %d",picture.size.width, picture.size.height); if( picture ){ NSLog(@"Picture is not null"); }else { NSLog(@"Picture is null."); } Thanks 回答1: Your code to load the image

Resize and Save NSImage?

梦想与她 提交于 2019-12-09 06:27:27
问题 I have an NSImageView which I get an image for from an NSOpenPanel. That works great. Now, how can I take that NSImage, half its size and save it as the same format in the same directory as the original as well? If you can help at all with anything I'd appreciate it, thanks. 回答1: Check the ImageCrop sample project from Matt Gemmell: http://mattgemmell.com/source/ Nice example how to resize / crop images. Finally you can use something like this to save the result (dirty sample): // Write to

Get pixels and colours from NSImage

允我心安 提交于 2019-12-09 05:27:52
问题 I have created an NSImage object, and ideally would like to determine how many of each pixels colour it contains. Is this possible? 回答1: I suggest creating your own bitmap context, wrapping it in a graphics context and setting that as the current context, telling the image to draw itself, and then accessing the pixel data behind the bitmap context directly. This will be more code, but will save you both a trip through a TIFF representation and the creation of thousands or millions of NSColor

NSImage rotation

瘦欲@ 提交于 2019-12-08 08:13:11
问题 I have a window with an subclass of NSView in it. Inside the view, I put an NSImage. I want to be able to rotate the image by 90 degrees, keeping the (new) upper left corner of the image in the upper left corner of the view. Of course, I will have to rotate the image, and then translate it to put the origin back into place. In Carbon, I found CGContextRotateCTM which does what I want . However, I can't find the right call in ObjC. setFrameCenterRotation doesn't seem to do anything, and in

How to Implement Custom Image representation for NSImage

梦想的初衷 提交于 2019-12-08 05:34:14
问题 I am developing an application to draw and process specific image format not currently supported by the NSimage class. In this specific format, the images are in form of a 1D binary table preceded by an ASCII header which describe the data (number dimension, image size, bit per pixel, ...). I read in the Coco Drawing Guide that it is possible to create new image representation. I am new in Coca and Objectiv-C programming and, on this topic, I find the Coco Drawing Guide explanation very short

Creating an ICNS Programmatically : “Unsupported Image Size”

泄露秘密 提交于 2019-12-08 05:13:49
问题 I'm trying to create an ICNS (including a 1024x1024 image) programmatically. Currently I'm creating an NSImage , then I create CGImageRef objects with the appropriate resolution, finally I'm adding them to an icon by using CGImageDestinationAddImage() . Peter Hosey has helped me create '@2x' images already, but the sizes of the images don't wanna be set. This is the code (still a bit messy, sourcefile represents the path to the image) : NSSize sizes[10]; sizes[0] = NSMakeSize(1024,1024);