zoukankan      html  css  js  c++  java
  • 解决NSImage绘制的时候图像模糊

    Mac下NSImage绘制模糊的原因之一是draw到了非整数像素上,框架在渲染的时候就会模糊. 针对这一原因写了以下工具:

    /**
     * @brief 一劳永逸的解决NSImage绘制的时候绘到浮点值像素上造成的图像模糊.
     * @note 目前只hook了drawInRect:fromRect:operation:fraction:这个函数.
     * @author hUyIncHun
     */
    
    #import <Cocoa/Cocoa.h>
    
    @interface NSImage(dIR)
    
    + (void)doMyWork;
    
    @end
    //
    //  NSImage+DrawSafely.m
    //  RTX
    //
    //  Created by hUyIncHun on 13-10-24.
    //
    
    #import "NSImage+DrawSafely.h"
    #import <objc/runtime.h>
    #import <objc/message.h>
    
    
    
    static IMP g_oldImp_drawInRect;
    
    
    static void newImp_drawInRect(id self, SEL _cmd, NSRect rect, NSRect rect2, NSCompositingOperation op, CGFloat f)
    {
        rect.origin.x = (int)rect.origin.x;
        rect.origin.y = (int)rect.origin.y;
        g_oldImp_drawInRect(self, _cmd, rect, rect2, op, f);
    }
    
    
    @implementation NSImage(dIR)
    
    + (void)doMyWork
    {
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken,^
                      {
    
                          g_oldImp_drawInRect =
                          method_setImplementation(
                                                   class_getInstanceMethod(self, @selector(drawInRect:fromRect:operation:fraction:))
                                                   , (IMP)newImp_drawInRect
                                                   );
                      });
    }
    
    @end
  • 相关阅读:
    Kindeditor 代码审计
    tamper参数
    大学站注入点(安全狗)
    sqlmap注入小结
    tamper绕WAF详解
    网站安全狗最新版绕过测试
    大学站防SQL注入代码(ASP版)
    防SQL注入代码(ASP版)
    xss利用和检测平台
    tamper绕WAF小结
  • 原文地址:https://www.cnblogs.com/xiaouisme/p/3387238.html
Copyright © 2011-2022 走看看