gpt4 book ai didi

ios - 检查视网膜像素 iOS 的工具或技术?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:01:56 25 4
gpt4 key购买 nike

我正在开发一个 iOS 应用程序,它需要非常精确的绘图,并且希望有一些方法可以直观地检查正在绘制到我的 iOS 设备屏幕上的每个(物理)像素的内容,到底 .这类似于 OS X 上的 Pixie 应用程序开发工具,但对于 iOS——不是简单地放大屏幕和抗锯齿,它会显示每个像素的非常清晰的网格,以及阴影/颜色是什么被吸引到那些像素。

有人知道这样的工具或技术吗?

这是我的 Retina MacBook 上 OS X 上的 Pixie 的屏幕截图,它显示了我正在寻找的输出类型。例如,您可以清楚地看到,设计师为黄色最小化图标中的“减号”指定了 1 个点(跨越两个视网膜像素)。

enter image description here

最佳答案

假设您正在使用 Quartz 对 UIView 进行绘图,您可以使用 CGContextScaleCTM 在像素边界而不是点边界上绘图。以下是使用应用程序屏幕截图执行此操作的粗略概述。您还可以让用户截取其他应用的屏幕截图,然后将其导入您的应用。

-(void)drawRect:(CGRect)rect
{
UIView* rootView = <GET_YOUR_ROOT_VIEW>;

//You will probably want to change rect so you don't get distortion
//This assumes that this view is the same size as the screen
[rootView drawViewHierarchyInRect:CGRectMake(0,0,rect.size.width*8, rect.size.height*8, afterScreenUpdates:YES];

CGContextRef cxt = UIGraphicsGetCurrentContext();

//Assumes this is @2x retina. You should check the contentScale to be sure
//and change accordingly
CGContextScaleCTM(ctx, 0.5, 0.5);

//Since we made the screen shot be 8x bigger the pixels
//on an @2x device are in increments of 4
for (int x = 0; x < rect.size.width*8; x+=4)
{
//Draw a line at x to ctx
}

for (int y = 0; y < rect.size.height*8; y+=4)
{
//Draw a line at y to ctx
}

}

很抱歉,我没有时间亲自编写和测试这段代码,所以它可能存在一些小问题。但这应该会让您朝着正确的方向前进。

此外,由于您正在放大图像,您实际上不需要使用 CGContextScaleCTM 更改比例,您只需要以正确的间隔绘制线条。

关于ios - 检查视网膜像素 iOS 的工具或技术?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28058016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com