cgimageref

CGImageRef width doesn't agree with bytes-per-row

∥☆過路亽.° 提交于 2019-12-06 02:26:11
问题 I'm trying to read pixels out of the screen buffer, I'm creating a CGImageRef with CGDisplayCreateImage , but the values for CGImageGetWidth and CGImageGetBytesPerRow Don't make sense together, dividing the bytes per row by the bytes per pixel gives me 1376 pixels per row, but the width of the image is 1366. What's going on here? Is there some kind of padding in the image? How do I read from the data I'm getting out of it safely, and with the correct results? Edit: The minimal code needed to

Resize CGImageRef without anti-liasing

可紊 提交于 2019-12-05 01:58:28
问题 I am trying to resize a 10x10 pixel CGImageRef, captured like this: CGImageRef imageRef = CGImageCreateWithImageInRect(screenShot, CGRectMake(mouseLoc.x-5, screen_height-mouseLoc.y-5, 10, 10)); CGContextRef mainViewContentContext = CGBitmapContextCreate (NULL, maskImage.size.width, maskImage.size.height, 8, maskImage.size.height*4, colorSpace, kCGImageAlphaPremultipliedFirst); CGContextDrawImage(mainViewContentContext, NSMakeRect(0,0, maskImage.size.width, maskImage.size.height), imageRef);

How to create a ICNS icon programmatically?

好久不见. 提交于 2019-12-04 12:06:31
OK this is what I want : Take some NSImage s Add them to an ICNS file Save it This is what I've done so far (purely as a test) : - (CGImageRef)refFromImage:(NSImage*)img { CGImageSourceRef source; source = CGImageSourceCreateWithData((CFDataRef)[img TIFFRepresentation], NULL); CGImageRef maskRef = CGImageSourceCreateImageAtIndex(source, 0, NULL); return maskRef; } - (void)awakeFromNib { NSImage* img1 = [NSImage imageNamed:@"image1"]; NSImage* img2 = [NSImage imageNamed:@"image2"]; NSLog(@"%@",img1); CGImageRef i1 = [self refFromImage:img1]; CGImageRef i2 = [self refFromImage:img2]; NSURL

Getting message in console: “CreateWrappedSurface() failed for a dataprovider-backed CGImageRef.”

Deadly 提交于 2019-12-04 11:29:45
问题 Updated to Xcode 7 and getting this (warning?) message while an image was being rendered in an operation: CreateWrappedSurface() failed for a dataprovider-backed CGImageRef. There was no message like this under Xcode 6.4. Got which code part threw the message: if (!self.originalImage) // @property (nonatomic, strong) UIImage *originalImage; return; CGImageRef originalCGImage = self.originalImage.CGImage; NSAssert(originalCGImage, @"Cannot get CGImage from original image"); CIImage

Any way to encode a PNG faster than UIImagePNGRepresentation?

允我心安 提交于 2019-12-04 10:23:24
问题 I'm generating a bunch of tiles for CATiledLayer . It takes about 11 seconds to generate 120 tiles at 256 x 256 with 4 levels of detail on an iPhone 4S. The image itself fits within 2048 x 2048. My bottleneck is UIImagePNGRepresentation . It takes about 0.10-0.15 seconds to generate every 256 x 256 image. I've tried generating multiple tiles on different background queue's, but this only cuts it down to about 9-10 seconds. I've also tried using the ImageIO framework with code like this: -

CGImageRef width doesn't agree with bytes-per-row

旧城冷巷雨未停 提交于 2019-12-04 07:08:03
I'm trying to read pixels out of the screen buffer, I'm creating a CGImageRef with CGDisplayCreateImage , but the values for CGImageGetWidth and CGImageGetBytesPerRow Don't make sense together, dividing the bytes per row by the bytes per pixel gives me 1376 pixels per row, but the width of the image is 1366. What's going on here? Is there some kind of padding in the image? How do I read from the data I'm getting out of it safely, and with the correct results? Edit: The minimal code needed to reproduce this is the following: #import <Foundation/Foundation.h> #import <ApplicationServices

Getting NSImage from CGImageRef

末鹿安然 提交于 2019-12-03 22:14:32
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 iOS the class method is imageWithCGImage: , how can you do this in Mac OS? The matching method in NSImage is initWithCGImage:size: . The second argument takes the image's size in points. The factor between the size in pixels (of the CGImage) and the size in points is the scale factor. So, for example, if you have a 100×100px CGImage, and pass a size

Resize CGImageRef without anti-liasing

半腔热情 提交于 2019-12-03 16:41:59
I am trying to resize a 10x10 pixel CGImageRef, captured like this: CGImageRef imageRef = CGImageCreateWithImageInRect(screenShot, CGRectMake(mouseLoc.x-5, screen_height-mouseLoc.y-5, 10, 10)); CGContextRef mainViewContentContext = CGBitmapContextCreate (NULL, maskImage.size.width, maskImage.size.height, 8, maskImage.size.height*4, colorSpace, kCGImageAlphaPremultipliedFirst); CGContextDrawImage(mainViewContentContext, NSMakeRect(0,0, maskImage.size.width, maskImage.size.height), imageRef); Then I need to make a 250x250 pixel image like this this , but the upscaled image looks like there is

Setting the contents of a CALayer to a CGImageRef on iOS with ARC on

て烟熏妆下的殇ゞ 提交于 2019-12-03 13:01:51
The following code compiles fine with manual memory management, but fails under ARC: CALayer *layer = [CALayer layer]; layer.contents = [[UIImage imageNamed:@"dial.png"] CGImage]; The error is: Automatic Reference Counting Issue: Implicit conversion of a non-Objective-C pointer type 'CGImageRef' (aka 'struct CGImage *') to 'id' is disallowed with ARC How can I get this running with ARC? CoreFoundation objets aren't managed by ARC. ARC only works with Objective-C objets and does not implicitly know how to transfer the ownership when casting from (or to) an non-object pointer type. You need to

Getting message in console: “CreateWrappedSurface() failed for a dataprovider-backed CGImageRef.”

对着背影说爱祢 提交于 2019-12-03 08:12:06
Updated to Xcode 7 and getting this (warning?) message while an image was being rendered in an operation: CreateWrappedSurface() failed for a dataprovider-backed CGImageRef. There was no message like this under Xcode 6.4. Got which code part threw the message: if (!self.originalImage) // @property (nonatomic, strong) UIImage *originalImage; return; CGImageRef originalCGImage = self.originalImage.CGImage; NSAssert(originalCGImage, @"Cannot get CGImage from original image"); CIImage *inputCoreImage = [CIImage imageWithCGImage:originalCGImage]; // this results the console message I replaced my