正如我注意到当CIGaussianBlur应用于图像时,图像的角落变得模糊,因此它看起来比原始的小.所以我发现我需要正确裁剪它以避免图像的透明边缘.但是如何计算我需要根据模糊量裁剪多少?
例:
原始图片:

图像有50 inputRadius的CIGaussianBlur(蓝色是一切的背景):

我NSBitmapImageRep是WX H的大小.我创造NSImage并做addRepresentation:.然后我需要调整大小NSImage.我试过setSize方法,但它不起作用.我该怎么办?
我做了什么:
我有一个模块
myfield = fields.Many2one('res.partner', string="Graduate", domain=[('is_graduated', '=', True)])
Run Code Online (Sandbox Code Playgroud)
然后我又上了一堂课
_inherit = 'res.partner'
is_graduated = fields.Boolean("Graduated before?", default=False)
graduations = fields.Many2many('my_module.courses', string="Graduation courses")
Run Code Online (Sandbox Code Playgroud)
我得到了什么:
该myfield作品不错,但graduations字段为空.如果您编辑user 1配置文件,您可以使用添加条目到graduation字段Add item,但我需要自动填充.
我期待的是:
我希望当你打开个人资料时,所有myfield设置的记录user 1都可以在字段中看到.当我创建记录和设置值时,该记录必须在字段中的配置文件中可见.怎么实现呢?graduationsuser 1myfielduser 1user 1graduations
如何将NSImage转换为NSBitmapImageRep?我有代码:
- (NSBitmapImageRep *)bitmapImageRepresentation
{
NSBitmapImageRep *ret = (NSBitmapImageRep *)[self representations];
if(![ret isKindOfClass:[NSBitmapImageRep class]])
{
ret = nil;
for(NSBitmapImageRep *rep in [self representations])
if([rep isKindOfClass:[NSBitmapImageRep class]])
{
ret = rep;
break;
}
}
if(ret == nil)
{
NSSize size = [self size];
size_t width = size.width;
size_t height = size.height;
size_t bitsPerComp = 32;
size_t bytesPerPixel = (bitsPerComp / CHAR_BIT) * 4;
size_t bytesPerRow = bytesPerPixel * width;
size_t totalBytes = height * bytesPerRow;
NSMutableData *data = [NSMutableData dataWithBytesNoCopy:calloc(totalBytes, 1) …Run Code Online (Sandbox Code Playgroud) 我有代码:
NSMutableArray *vertices = [[NSMutableArray alloc] init];
//Getting mouse coordinates
loc = [self convertPoint: [event locationInWindow] fromView:self];
[vertices addObject:loc]; // Adding coordinates to NSMutableArray
//Converting from NSMutableArray to GLfloat to work with OpenGL
int count = [vertices count] * 2; // * 2 for the two coordinates of a loc object
GLFloat []glVertices = (GLFloat *)malloc(count * sizeof(GLFloat));
int currIndex = 0;
for (YourLocObject *loc in vertices) {
glVertices[currIndex++] = loc.x;
glVertices[currIndex++] = loc.y;
}
Run Code Online (Sandbox Code Playgroud)
loc是CGPoint,所以我需要以某种方式从CGPoint更改为NSValue以将其添加到NSMutableArray,然后将其转换回CGPoint.怎么可能呢?
我做了一个绘画程序.一切都按照我的预期运作.但在绘画时,有时会发生一些奇怪的事情.
我运行app,然后在图像上按鼠标左键.它应该从代码中得出点:
glEnableClientState(GL_VERTEX_ARRAY);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, brushTextura);
glPointSize(100);
glVertexPointer(2, GL_FLOAT, 0,GLVertices);
glDrawArrays(GL_POINTS, 0, count);
glDisableClientState(GL_VERTEX_ARRAY);
Run Code Online (Sandbox Code Playgroud)
在我按下的地方.mouseDown注册mouseDown位置,将其转换为NSValue,发送到数组,然后在绘制之前我将NSValue提取到CGPoint并将其发送到GLfloat,以便glDrawArrays可以绘制它.但无论我在图像上单击鼠标,它都会在坐标(0,0)处绘制点.之后,每件事情都可以.见图:

这是第一个问题.第二个问题是当我用它绘画时(拖动按下的鼠标),有时会出现点未绘制的位置.图片:

当我继续拖动它消失.拖动后再次出现并再次消失.等等.图片:

任何想法为什么会发生?我将发布以下代码:
鼠标按下:
- (void) mouseDown:(NSEvent *)event
{
location = [self convertPoint: [event locationInWindow] fromView:self];
NSValue *locationValue = [NSValue valueWithPoint:location];
[vertices addObject:locationValue];
[self drawing];
}
Run Code Online (Sandbox Code Playgroud)
拖动鼠标:
- (void) mouseDragged:(NSEvent *)event
{
location = [self convertPoint: [event locationInWindow] fromView:self];
NSValue *locationValue = [NSValue valueWithPoint:location];
[vertices addObject:locationValue];
[self drawing];
}
Run Code Online (Sandbox Code Playgroud)
画画:
- (void) drawing {
int count = [vertices count] * 2;
NSLog(@"count: %d", …Run Code Online (Sandbox Code Playgroud) 我怎样才能将我的DocumentView(女巫是NSOpenGLView的子类)置于中心位置NSScrollView?
现在它看起来像这样(灰色区域是NSScrollView边界):

我希望它看起来像这样:

为什么InterfaceBuilder文件中的FirstResponder缺少redo:连接(在Received Actions列表中)?undo:存在,但redo:没有.我该怎么办呢?
背景
我正在尝试构建一个使用本机 IKEv2 实现连接到 VPN 的应用程序。该应用程序应为 iOS 构建,但也应使用 Catalyst 平台在 macOS 上运行。
情况
在 iOS/macOS 中使用本机 IKEv2 实现连接到 VPN 时 - 要使用用户名和密码身份验证,应用程序必须将持久的钥匙串引用传递给包含密码的钥匙串项目。(参考)
问题
在 iOS 上它工作得很好,但是在 Catalyst 平台上启动 VPN 连接时,VPN 服务无法使用给定的持久引用检索密码。控制台打印:
[] (null): Failed to copy content, SecKeychainItemCopyContent returned The contents of this item cannot be retrieved.
Run Code Online (Sandbox Code Playgroud)
钥匙串项存储在钥匙串中,持久引用不是nil,但由于某种原因,操作系统的 VPN 服务无法检索密码。
如果我尝试使用相同的持久引用检索密码 - 一切都按预期工作,并检索密码。
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrPersistentReference as String: persistentRef,
kSecReturnData as String: true
]
var item: CFTypeRef?
let …Run Code Online (Sandbox Code Playgroud) 我在我的视图中添加了NSTrackingArea以捕获mouseEntered/mouseExited事件.有用.然后,当我捕获mouseEntered事件时
[self.window invalidateCursorRectsForView:self];
Run Code Online (Sandbox Code Playgroud)
在- (void)resetCursorRects方法中我绘制图像,从中创建NSCursor然后:
[self addCursorRect:self.bounds cursor:myCursor];
Run Code Online (Sandbox Code Playgroud)
看起来效果不错,但有时,当拖动鼠标(鼠标向下拖动)在视图光标上闪烁时(光标下方出现一些神秘的黑色四边形,其大小完全符合我的光标大小.只有我的光标是圆形.顺便说一下如果我的光标很小,则不会出现问题.当它变大时会开始闪烁.并且在没有其他绘图同时进行时它不会出现.
可能是什么问题呢?
屏幕:
好时刻:

坏时刻:

macos ×9
objective-c ×8
cocoa ×2
nsimage ×2
xcode ×2
bitmap ×1
core-image ×1
cursor ×1
jpeg ×1
keychain ×1
mac-catalyst ×1
nevpnmanager ×1
odoo ×1
openerp ×1
opengl ×1
postgresql ×1
python ×1
redo ×1
swift ×1
undo ×1
xml ×1