Calling -lockFocus causes a snapshot of the image to be made. It's not something to be done lightly. Move the locking and unlocking of focus outside of the tight loop and you should be fine. Alternately, you could work out another way to read pixel data out of images. Unfortunately,...
ios,uiimage,nsimage,uiimagejpegrepresentation
About scale The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). ...
swift,cocoa,core-image,nsimage,swift2
extension NSImage { func gaussianBlurOfRadius(radius: CGFloat) -> NSImage { let image = self image.lockFocus() let beginImage = CIImage(data: image.TIFFRepresentation!)! let params = [kCIInputImageKey : beginImage, kCIInputRadiusKey: radius] let filter = CIFilter(name: "CIGaussianBlur", withInputParameters: params)! let output = filter.valueForKey("outputImage") as! CIImage let rect = NSMakeRect(0, 0, size.width, size.height) output.drawInRect(rect, fromRect: rect,...
ios,objective-c,osx,uiimage,nsimage
the icon you get back is a NSImage that has ITS size set to 32x32. Means that if you draw it now, it will choose an appropriate NSImageRepresentation. From the Log you can see it has many different ones - they are the perse data so all you need to...
cocoa,transparency,nsimage,alpha-transparency
I found a solution... I changed the representationUsingType... I used JPEGFileType so the image has no transparencies at all... here the changed code: NSData *dataToWrite = [rep representationUsingType:NSJPEGFileType properties:nil]; ...
objective-c,cocoa,nsimage,cgimageref
The documentation for initWithCGImage:size: states: You should not assume anything about the image, other than that drawing it is equivalent to drawing the CGImage. In the end I just continued on working with NSBitmapImageRep instances directly....
In this situation, you can use NSImage just like UIImage: NSImage(named: "Something") ...
objective-c,osx,afnetworking-2,nsimage
With the support of Mattijs from TinyPNG I've got it working! Thanks Mattijs! The problem was, that the TinyPNG API expects the request body to only be the image data, which isn't the case with the multipart form data body I used in my original code. My working solution is:...
Phew, this manages to pack many different issues into a tiny amount of code :-) This explanation is long so you might find you know the first part of it but may as well start at the beginning... NSImage(byReferencingFile) is what’s called a “failable initializer” – that is, an initializer...
Since OS X 10.8, NSImage has a block based initialiser to draw vector based content into a bitmap. The idea is to provide a drawing handler that is called whenever a representation of the image is requested. The relation between points and pixels is expressed by passing a NSSize (in...
osx,nsimage,xpc,nsxpcconnection
It appears that all objects passed via the connection must conform to the NSSecureCoding protocol, which NSImage does not conform to. NSData does conform to this protocol, and now I am passing it through the connection (not sure why it didn't work when I tried NSData earlier). I am creating...
objective-c,cocoa,core-graphics,nsimage,quartz-core
It seems that setPixelBufferAttributes was ignored on the first request so in the callback when the image is received from the camera I check the size and issue the request again if not correct. This seems to have fixed the issue.
Looks like a bug. File it with Apple and then just go on using the deprecated method. Deprecated doesn't mean unavailable or "don't dare use this". It means it should be avoided in new code where possible and you should considered yourself warned that it may eventually go away....
objective-c,osx,cocoa,nsimage,nsimageview
Okay, so I feel stupid now. I'm still learning stuff so I wasn't sure why it was freezing up until I noticed Xcode kept switching to the "Debug" panel, which clued me into what might be happening. I figured out I accidentally clicked a line number, which apparently sets breakpoints...
objective-c,cocoa,nsview,drawrect,nsimage
Short Version Add: imageRect.origin.x += NSWidth(drawRect) / 2 - NSHeight(drawRect) / 2; imageRect.origin.y += NSHeight(drawRect) / 2 - NSWidth(drawRect) / 2; after the call to proportionallyScale in drawRect Long Version I took this in two steps: bounding and scaling the image, and then repositioning it within viewport. You can probably...
objective-c,cocoa,nsimage,image-rotation,nsaffinetransform
I still don't know the root cause of this, but one work around is to save to the JPEG representation instead of the TIFF. The method I wrote is as follows : - (void)CompressAndSaveImg:(NSImage *)img ToDiskAt:(NSString *)path WithCompressionFactor:(float)value{ NSData *imgData = [img TIFFRepresentation]; NSBitmapImageRep *imgRep = [NSBitmapImageRep imageRepWithData:imgData]; NSNumber *compressionFactor...
objective-c,cocoa,nsview,nsimage
I am able to solve my problem with the following Code // Setup the image to render NSRect imgRect = _collageView.frame; NSSize imgSize = imgRect.size; NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:imgSize.width pixelsHigh:imgSize.height bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bitmapFormat:NSAlphaFirstBitmapFormat bytesPerRow:0 bitsPerPixel:0]; NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithBitmapImageRep:rep];...
osx,rubymotion,nsimage,nsgradient
I don’t know about RubyMotion, but here’s how to do it in Objective-C: NSGradient *grad = [[NSGradient alloc] initWithStartingColor:[NSColor redColor] endingColor:[NSColor blueColor]]; NSRect rect = CGRectMake(0.0, 0.0, 50.0, 50.0); NSImage *image = [[NSImage alloc] initWithSize:rect.size]; NSBezierPath *path = [NSBezierPath bezierPathWithRect:rect]; [image lockFocus]; [grad drawInBezierPath:path angle:0.0]; NSBitmapImageRep *imgRep = [[NSBitmapImageRep alloc]...