+ (CGImageRef) newFliteredCGImage:(CGImageRef)image withCIFilter:(CIFilter*)filter {
CIImage* input_image = [CIImage imageWithCGImage:image];
NSSize image_size = NSMakeSize(CGImageGetWidth(image),
CGImageGetHeight(image));
[filter setValue:input_image forKey:kCIInputImageKey];
CIImage* output_image = [filter valueForKey:kCIOutputImageKey];
CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
CGContextRef bitmap_context
= CGBitmapContextCreate(nil,
image_size.width,
image_size.height,
8,
image_size.width * 4,
color_space,
(CGBitmapInfo)kCGImageAlphaNoneSkipFirst);
CGColorSpaceRelease(color_space);
CIContext* ci_bitmap_context
= [CIContext contextWithCGContext:bitmap_context
options:nil];
[ci_bitmap_context drawImage:output_image
inRect:[output_image extent]
fromRect:(CGRect){CGPointZero, image_size}];
CGImageRef result_img = CGBitmapContextCreateImage(bitmap_context);
CGContextRelease(bitmap_context);
return result_img;
}
参数的CGImageRef和返回的CGImageRef由CGImageRelease释放,但它有内存泄漏
我认为CIContext有问题,但我找不到问题
请给我帮助
答案 0 :(得分:1)
在@autoReleasePool中进行..
Set<List<String>> keySet = new HashSet<>();
for (int i = 0; i <= totalrows; i++) {
for (int j = 0; j < sheet.getRow(0).getPhysicalNumberOfCells(); j++) {
HSSFCell cell = sheet.getRow(i).getCell(j);
// writing keywords from excel into a hashmap
data[i][j]=cell.getRichStringCellValue().getString();
}
keySet.add(Arrays.asList(data[i]));
}
Iterator<List<String>> iterator = keySet.iterator();
System.out.println("Output Set is as below");
while(iterator.hasNext()){
List<String> next = iterator.next();
System.out.println(next.get(0) + "\t"+ next.get(1) +"\t "+next.get(2));
}
希望它可以帮助你..