cgimageref

Creating a thumbnail from UIImage using CGImageSourceCreateThumbnailAtIndex

梦想与她 提交于 2021-02-05 20:14:36
问题 I want to use the function CGImageSourceCreateThumbnailAtIndex to create a thumbnail from an UIImage . All I have is the UIImage itself. The image is the snapshot on a UIView . Please, I don't want to use any other method to create the thumbnail, just the one using CGImageSourceCreateThumbnailAtIndex , because I want to compare its performance with the other methods I already have. Said that, this is the code I have so far. I have create a UIImage category with this code: - (UIImage *

Creating a thumbnail from UIImage using CGImageSourceCreateThumbnailAtIndex

不想你离开。 提交于 2021-02-05 20:11:14
问题 I want to use the function CGImageSourceCreateThumbnailAtIndex to create a thumbnail from an UIImage . All I have is the UIImage itself. The image is the snapshot on a UIView . Please, I don't want to use any other method to create the thumbnail, just the one using CGImageSourceCreateThumbnailAtIndex , because I want to compare its performance with the other methods I already have. Said that, this is the code I have so far. I have create a UIImage category with this code: - (UIImage *

iOS中使用像素位图(CGImageRef)对图片进行处理

血红的双手。 提交于 2020-02-29 08:41:21
iOS中对图片进行重绘处理的方法总结 一、CGImageRef是什么 CGImageRef是定义在QuartzCore框架中的一个结构体指针,用C语言编写。在CGImage.h文件中,我们可以看到下面的定义: typedef struct CGImage *CGImageRef; CGImageRef 和 struct CGImage * 是完全等价的。这个结构用来创建像素位图,可以通过操作存储的像素位来编辑图片。 QuartzCore这个框架是可移植的。 二、CGImageRef相关的一些方法解析 CFTypeID CGImageGetTypeID( void ) 这个方法返回的是一个编号,每个 Core Foundation框架中得结构都会有一个这样的编号,CFTypeID定义如下: #if __LLP64__ typedef unsigned long long CFTypeID; typedef unsigned long long CFOptionFlags; typedef unsigned long long CFHashCode; typedef signed long long CFIndex; #else typedef unsigned long CFTypeID; typedef unsigned long CFOptionFlags; typedef

LeavesCache.m works on simulator but not on device

橙三吉。 提交于 2020-01-16 20:06:18
问题 Its my first time posting so please bear with me. I have been searching sites after sites and I can't seem to find any which has resolved this issue. Would be happy if someone could answer me. LeavesCache.m was modified last year if not mistaken to accommodate ios 7 i think. The code is below however I receive a EXC_BAD_ACCESS for return pageImage.CGImage . I changed it to return (__bridge CGImageRef)(pageImage) but now my page comes out blank even though it prints the correct page index.

Converting NSData to CGImage and then back to NSData makes the file too big

柔情痞子 提交于 2020-01-04 04:10:48
问题 I have built a camera using AVFoundation . Once my AVCaptureStillImageOutput has completed its captureStillImageAsynchronouslyFromConnection:completionHandler: method, I create a NSData object like this: NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer]; Once I have the NSData object, I would like to rotate the image -without- converting to a UIImage . I have found out that I can convert to a CGImage to do so. After I have the imageData,

How to create a ICNS icon programmatically?

▼魔方 西西 提交于 2020-01-01 14:22:07
问题 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(@"%@"

Create new image using just some pixels data from the source image based on them color

馋奶兔 提交于 2019-12-25 04:07:01
问题 I have original image and I can cycle all pixels using @patrick-rutkowski answer here. Also I have this answer seems to create image with pixel data. But I can't understand how to combine these two answers. So the first task is get pixel and second is add it to another CGImage. For example if I want to extract all red pixels from the original image and add these red pixels to another image. I suppose it's way to go. 来源: https://stackoverflow.com/questions/28310186/create-new-image-using-just

UIImage from GRKPhoto using ALAsset

与世无争的帅哥 提交于 2019-12-23 12:27:30
问题 I'm using grabKit in order to allow users to import their Instagram, Facebook and local pictures to my app. The problem comes when the photo is local. In this case, I use a method that works when the user selects the photo. The standard code I found in order to do so is the following: - (void)picker:(GRKPickerViewController*)picker didSelectPhoto:(GRKPhoto *)photo{ [popover dismissPopoverAnimated:YES]; GRKImage *originalImage = [photo originalImage]; NSLog(@" the URL of the original image of

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

瘦欲@ 提交于 2019-12-21 04:14:21
问题 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? 回答1: CoreFoundation objets aren't managed by ARC. ARC only works with Objective-C objets and does not

NSImage to cv::Mat and vice versa

你。 提交于 2019-12-17 17:59:11
问题 while working with OpenCV I need to convert a NSImage to an OpenCV multi-channel 2D matrix (cvMat) and vice versa. What's the best way to do it? Greets, Dom 回答1: Here's my outcome, which works pretty well. NSImage+OpenCV.h: // // NSImage+OpenCV.h // #import <AppKit/AppKit.h> @interface NSImage (NSImage_OpenCV) { } +(NSImage*)imageWithCVMat:(const cv::Mat&)cvMat; -(id)initWithCVMat:(const cv::Mat&)cvMat; @property(nonatomic, readonly) cv::Mat CVMat; @property(nonatomic, readonly) cv::Mat