我需要缩小图像,但需要以锐利的方式缩小.例如,在Photoshop中有图像尺寸缩小选项"Bicubic Smoother"(模糊)和"Bicubic Sharper".
这个图像缩减算法是在某处开源或记录的,还是SDK提供了这样做的方法?
我试图通过使用CAShapeLayer并在其上设置圆形路径来绘制一个描边圆.但是,这种方法在渲染到屏幕时的效果始终低于使用borderRadius或直接在CGContextRef中绘制路径.
以下是所有三种方法的结果:
请注意,第三个渲染效果不佳,尤其是在顶部和底部的笔划内.
我已将该contentsScale
属性设置为[UIScreen mainScreen].scale
.
这是我对这三个圆圈的绘图代码.使CAShapeLayer顺利绘制的缺失是什么?
@interface BCViewController ()
@end
@interface BCDrawingView : UIView
@end
@implementation BCDrawingView
- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
self.backgroundColor = nil;
self.opaque = YES;
}
return self;
}
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
[[UIColor whiteColor] setFill];
CGContextFillRect(UIGraphicsGetCurrentContext(), rect);
CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), NULL);
[[UIColor redColor] setStroke];
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 1);
[[UIBezierPath bezierPathWithOvalInRect:CGRectInset(self.bounds, 4, 4)] stroke];
}
@end
@interface BCShapeView : UIView
@end
@implementation BCShapeView
+ (Class)layerClass
{
return [CAShapeLayer class];
} …
Run Code Online (Sandbox Code Playgroud) 我在iOS应用程序中有一系列用户自定义图像,这些图像以简单的逐帧翻书风格进行动画制作.
我的问题是:有没有办法让用户将动画导出为GIF动画?理想情况下,我想让他们通过电子邮件,社交分享(T/FB)或(最糟糕的情况......)将动画gif保存到他们的文档文件夹中,以便通过iTunes进行检索.
我知道如何将.png保存到照片库,我找到了一种将动画录制为QT文件的方法(http://www.cimgf.com/2009/02/03/record-your-core-animation - 动画/),但我还没有找到一种方法来踢出一个普通的老动画GIF.我在Core Animation或其他地方遗漏了什么吗?是否有任何人可以推荐的方法,框架或资源?对不起,如果问题太笼统 - 努力找到一个起点.
我一直试图找出一种绘制线段的方法,如下图所示:
我想:
我一直试图用CGContextAddArc
类似的电话来做这件事,但没有走得太远.
有人可以帮忙吗?
我想知道是否有人可以准确区分这些?据我所知,Core Graphics只是一个包含Quartz Core和Quartz 2D的"Framework Package".但我不确定Quartz 2D是否真的是Quartz Core?也许有人可以在那里画一些线?是什么构成了这些之间的差异?
在查看文档时,我看到Quartz Core仅列出了所有Core Animation的内容.那么Quartz Core ==核心动画?
我正试图CIImage
从屏幕上显示的ImageView 获取.
UIImage *image = myImageView.image;
Run Code Online (Sandbox Code Playgroud)
将图像转换UIImage
为CIImage
.
CIImage *cImage = [....];
Run Code Online (Sandbox Code Playgroud)
这该怎么做?
我们正在为OS X创建一个使用Quartz Events移动光标的用户空间设备驱动程序,当游戏 - 特别是那些以窗口模式运行的游戏 - 无法正确捕获鼠标指针时,我们遇到了一个问题(=包含/将其保持在窗口的边界内).例如,它将移出游戏窗口并单击桌面或附近的非活动应用程序.
如果我们只能检测到活动应用程序何时调用CGAssociateMouseAndMouseCursorPosition,我们就可以解决这个问题.
你会怎么做?任何想法都表示赞赏.
我有一个UIScrollView
实现takeScreenshot方法的decedent,如下所示:
-(void)takeScreenshot {
CGRect contextRect = CGRectMake(0, 0, 768, 1004);
UIGraphicsBeginImageContext(contextRect.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// do something with the viewImage here.
}
Run Code Online (Sandbox Code Playgroud)
这基本上移动到滚动视图的顶部,并截取可见区域的屏幕截图.当iPad面向人像时,它可以正常工作,但当它处于横向时,图像的底部会被切断(因为可见区域的高度仅为748,而不是1004).
是否有可能获得快照UIScrollView
,包括不在屏幕上的区域?或者我需要向下滚动视图,拍摄第二张照片并将它们拼接在一起?
我在iOS 4.1中使用新的ImageIO框架.我使用以下代码成功检索exif元数据:
CFDictionaryRef metadataDict = CMGetAttachment(sampleBuffer, kCGImagePropertyExifDictionary , NULL);
Run Code Online (Sandbox Code Playgroud)
阅读它,它似乎是有效的.保存图像有效,但图像中从不存在任何exif数据.
CGImageDestinationRef myImageDest = CGImageDestinationCreateWithURL((CFURLRef) docurl, kUTTypeJPEG, 1, NULL);
// Add the image to the destination using previously saved options.
CGImageDestinationAddImage(myImageDest, iref, NULL);
//add back exif
NSDictionary *props = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:.1], kCGImageDestinationLossyCompressionQuality,
metadataDict, kCGImagePropertyExifDictionary, //the exif metadata
nil];
//kCGImagePropertyExifAuxDictionary
CGImageDestinationSetProperties(myImageDest, (CFDictionaryRef) props);
// Finalize the image destination.
bool status = CGImageDestinationFinalize(myImageDest);
Run Code Online (Sandbox Code Playgroud) 我们偶然发现了Quartz Events的性能问题,更具体地说是CGEventPost:在繁重的GPU加载期间,CGEventPost会阻塞.我们已经创建了一个小型基准测试应用程序来演示该问题.此应用程序只是一个创建,发布和发布事件的循环.
您可以在下面看到运行该应用程序的结果.第一次运行是在空闲系统上.第二次运行是使用FurMark(GPU压力测试),表盘尽可能地加速.
18:58:01.683 EventPerformance[4946:707] Measurements: (outer should be close to 10)
18:58:01.684 EventPerformance[4946:707] inner (ms): 0.04, outer (ms): 11.02, CGEventPost (ms): 0.03
18:58:01.684 EventPerformance[4946:707] inner (ms): 0.04, outer (ms): 11.02, CGEventPost (ms): 0.03
18:58:01.685 EventPerformance[4946:707] inner (ms): 0.07, outer (ms): 10.26, CGEventPost (ms): 0.03
18:58:01.685 EventPerformance[4946:707] inner (ms): 0.06, outer (ms): 10.85, CGEventPost (ms): 0.05
18:58:01.686 EventPerformance[4946:707] inner (ms): 0.07, outer (ms): 10.41, CGEventPost (ms): 0.04
18:58:01.686 EventPerformance[4946:707] inner (ms): 0.04, outer …
Run Code Online (Sandbox Code Playgroud) core-graphics ×10
ios ×5
iphone ×3
macos ×3
mouseevent ×2
uikit ×2
animated-gif ×1
calayer ×1
cashapelayer ×1
cocoa-touch ×1
core-image ×1
exif ×1
image ×1
ios5 ×1
ipad ×1
objective-c ×1
quartz-2d ×1
scaling ×1
swift ×1
uiimage ×1