save NSImage instance

macOS 开发 - NSImge格式转换/压缩(CIImage/CGImageRef/NSData) 格式转换 CGImageRe 格式转换 CGImageRef转NSImage NSImage转CGImageRef NSImage转CIImage NSView 转 NSImage 格式 jpg&png 尺寸 压缩 将图片按照比例压缩 将图片压缩到指定大小(KB) demos 修改图片尺寸并保存 1、将指定路径图片,按照比例压缩,并保存 2、组合图片 格式转换 需要导入头文件 #... 阅读详情

Save NSimage instance object , file type data  option,dictinary kye and value.

 

NSImageCompressionFactor-->JPEG ->0.0-1.0
Available in Mac OS X v10.0 and later.

NSImageCompressionMethod-->TIFF ->NSTIFFCompression

Identifies an NSNumber object identifying the compression method of the image.
Available in Mac OS X v10.0 and later.

NSImageDitherTransparency-->GIF ->Boolean value (抖动的)
Identifies an NSNumber object containing a boolean that indicates whether the image is dithered.
Available in Mac OS X v10.0 and later.

NSImageInterlaced -->PNG ->NSNumber object containing a Boolean value(交错,交织的)
Identifies an NSNumber object containing a Boolean value that indicates whether the image is interlaced.
Available in Mac OS X v10.0 and later.

NSImageRGBColorTable
Identifies an NSData object containing the RGB color table.
Used only for GIF files. It’s stored as packed RGB. It’s set when reading in and used when writing out.
Available in Mac OS X v10.0 and later.

NSImageEXIFData
Identifies an NSDictionary object containing the EXIF data for the image.
This property is used only when reading or writing JPEG files. The dictionary contains the EXIF keys and values. Th standard dictionary keys (that is, those that are not specific to camera vendors) are identical to those for kCGImagePropertyExifDictionary declared in the CGImageSource API. See kCGImagePropertyExifDictionary_Keys for details.
Available in Mac OS X v10.4 and later.

NSImageFallbackBackgroundColor
Specifies the background color to use when writing to an image format (such as JPEG) that doesn't support alpha. The color's alpha value is ignored. The default background color, when this property is not specified, is white. The value of the property should be an NSColor object.
Available in Mac OS X version 10.5 and later.

NSImageFrameCount
Identifies an NSNumber object containing the number of frames in an animated GIF file.
This value is used when reading in data.
Available in Mac OS X v10.2 and later.

NSImageGamma
Identifies an NSNumber object containing the gamma value for the image.
Used only for PNG files. The gamma values is a floating-point number between 0.0 and 1.0, with 0.0 being black and 1.0 being the maximum color. It’s set when reading in and used when writing out.
Available in Mac OS X v10.4 and later.

NSImageCurrentFrame
Identifies an NSNumber object containing the current frame for an animated GIF file.
The first frame is 0.
Available in Mac OS X v10.2 and later.

NSImageCurrentFrameDuration
Identifies an NSNumber object containing the duration (in seconds) of the current frame for an animated GIF image.
The frame duration can be a floating-point value. It is used when reading in, but not when writing out.
Available in Mac OS X v10.2 and later.

NSImageProgressive
Identifies an NSNumber object containing a boolean that indicates whether the image uses progressive encoding.
Used only for JPEG files. It’s set when reading in and used when writing out.
Available in Mac OS X v10.4 and later.

NSImageLoopCount
Identifies an NSNumber object containing the number of loops to make when animating a GIF image.
A value of 0 indicates the animation should loop indefinitely. Values should be specified as integer numbers. It is used when reading in but not when writing out the image.
Available in Mac OS X v10.3 and later.

保存不同的格式图片压缩方法,应该指定相应的属性字典

如保存jpeg文件时候:

NSDictionary *imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:0.8] forKey:NSImageCompressionFactor];

 

如保存tiff文件时候:

NSDictionary *imageProps = [NSDictionary dictionaryWithObject NSTIFFCompressionNone forKey:NSImageCompressionMethod];

 

NSTIFFCompression
These constants represent the various TIFF data-compression schemes supported by NSBitmapImageRep.

typedef enum _NSTIFFCompression {
   NSTIFFCompressionNone = 1,
   NSTIFFCompressionCCITTFAX3 = 3,
   NSTIFFCompressionCCITTFAX4 = 4,
   NSTIFFCompressionLZW = 5,
   NSTIFFCompressionJPEG = 6,
   NSTIFFCompressionNEXT = 32766,
   NSTIFFCompressionPackBits = 32773,
   NSTIFFCompressionOldJPEG = 32865
} NSTIFFCompression;


附加:

        子线程要调用主线程函数,且是否指定等待返回:

          在线程中:[self performSelectorOnMainThread:@selector(setPreviewImage:) withObject:image waitUntilDone:NO];

嵌入式SPI总线抽象设计:跨平台驱动与分层解耦实践 SPI(串行外设接口)是嵌入式系统中应用最广泛的同步串行通信协议,其核心价值在于高吞吐、低开销与硬件简洁性。其工作原理基于主从架构、全双工/半双工时序及片选(CS)控制,依赖CPOL/CPHA组合定义四种标准模式。在工程实践中,SPI常面临硬件资源受限、多外设共用总线、MCU平台迁移等挑战,导致驱动复用率低、维护成本高。通过结构体+函数指针实现的分层抽象——将物理总线、协议适配与设备驱动解耦,可显著提升代码可移植性与扩展性。该方法天然支持硬件SPI与GPIO模拟SPI双模式切换,并已在STM32等主流MCU 阅读详情

相关推荐

融合ZILN损失与深度学习的LTV预测:从概率分布到精准营销决策

本文探讨了融合ZILN损失与深度学习的LTV预测方法,通过深度概率模型精准预测用户生命周期价值(LTV),优化营销决策。文章详细解析了ZILN损失函数的优势、模型架构设计要点及工程化落地实践,帮助企业在预算分配、用户分层等场景实现数据驱动的精准营销。

weixin_29093169的博客 317

MacOS 开发 - NSOpenPanel & NSSavePanel 保存文件、打开文件夹

一、NSSavePanel 1、需要设置权限 1.1 示例:打开文件夹,并保存图片到文件夹: 二、NSOpenPanel 1、常用的属性 2、调用示例 2.1 OS X 6之后 2.2 OS X 6之前 三、参考资料: 一、NSSavePanel 1、需要设置权限 路径:target –> capabilitys –> file access ...

AI工程化、开源分享、文档翻译、代码笔记 7334

决策树(分类树、回归树)

决策树 前言:第一篇博客,最近看完决策树,想着归纳一下,也方便自己以后回顾。写的会比较全面一些,可能会有很多不太正确的地方,欢迎大家交流指正 : ) 决策树模型: 决策树模型是运用于分类以及回归的一种树结构。决策树由节点和有向边组成,一般一棵决策树包含一个根节点、若干内部节点和若干叶节点。决策树的决策过程需要从决策树的根节点开始,待测数据与决策树中的特征节点进行比较,并按照比较结果选...

你午睡了吗 9万+

NSImage加载图片

转自:http://www.leoshao.com/57.html 刚开始用NSImage,从网上查找的方法是调用 imageNamed方法 NSImage *myImage = [NSImage imageNamed:@"imageName.png"] ;

henry_sea的专栏 7595

3D视觉革命丨多相机协同拼接技术如何重塑工业检测边界

本文深入探讨了多相机协同拼接技术如何突破单台3D相机的物理局限,实现工业检测从“点面”到“立体”的无死角覆盖。通过拆解系统标定、同步融合等核心技术,并结合锂电池、长轴零件等实战案例,揭示了该技术如何以虚拟“超级视觉传感器”重塑检测边界,提升精度与效率。

weixin_29056865的博客 400

【Verilog】valid-ready双向握手机制 ——很绕但是很有意思

valid-ready双向握手机制。

GalaxyerKw的博客 1万+

NSView 转换成NSImage,并保存

[zwView lockFocus];//zwView为继承NSView类的一个对象     NSImage *image = [[NSImage alloc] initWithData:[zwView dataWithPDFInsideRect:[zwView bounds]]];     [zwView unlockFocus];     [image lockFoc

qq_27740983的博客 2565

下载igv报错:Error loading genome hg38raw.githubusercontent.com...如何解决?

🏆本文收录于 《全栈 Bug 调优(实战版)》 专栏。专栏聚焦真实项目中的各类疑难 Bug,从成因剖析 → 排查路径 → 解决方案 → 预防优化全链路拆解,形成一套可复用、可沉淀的实战知识体系。无论你是初入职场的开发者,还是负责复杂项目的资深工程师,都可以在这里构建一套属于自己的「问题诊断与性能调优」方法论,助你稳步进阶、放大技术价值 。

**My Coding Family** 1010

NSImage

转自:http://geeklu.com/2011/06/nsimage-imagenamed/ 1.图片的加载 NSImage 这个应该是经常用到的一个类,最常用的莫过于 [NSImage imageNamed:@"name"] 来加载一个资源中的图片。 可能这并没有你想象的那么简单。 NSImage *myImage = [NSImage imageNamed:@"ima

a935502404的专栏 906

用一组可复现实验讲清 ABAP 内表 Standard / Sorted / Hashed 的性能差异

摘要(150字): SAP项目中性能问题常源于ABAP内表选型不当。标准表(STANDARD TABLE)写入快但查找慢(线性扫描),适合遍历场景;排序表(SORTED TABLE)保持有序,支持二分查找,适合范围查询;哈希表(HASHED TABLE)基于唯一键实现常数级查找,适合高频精确匹配。实验表明:标准表+BINARY SEARCH需预排序,成本可能高于直接使用排序表;哈希表在键匹配时性能最优。Gateway和RAP场景中,内表选型直接影响接口响应,建议根据读写负载(追加/遍历/精确查找)选择对应类

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 217

MicroBlaze系列教程(5):AXI_UART16550的使用

axi-uart16550是Xilinx的一款串口IP核,支持配置成16450或16550模式,16550和16450是指的早期电脑主板上的串口芯片型号,16550相比于16450多了FIFO,现在已经很少使用。相比于,16550支持1或2位停止位,包括uartlite所有的功能,而且支持在SDK中灵活对波特率、数据、校验方式进行配置。与uartlite不同的是,不能单独指定发送中断和接收中断函数,只有一个中断函数,通过event参数来区分当前是发送或接收中断。

whik1194的博客 4566

NSImage转opencv图像, opencv图像转NSImage

NSImage *outImage; NSImage *inputImage = [NSImage imageNamed:@"zhangsan.jpg"]; int m_nWidth = inputImage.size.width; int m_nHeight = inputImage.size.height; //NSImage转cv图 cv::Mat mat_pt = cv::Mat(m_nHeigh

weixin_44210987的博客 390

【ARM Trace32(劳特巴赫) 使用介绍 1.3 - ARM 系统调试中常见的挑战】

每一个独立的gust os或者一个OS 内部里面美格独立的进程它使用虚拟地址是可能是重叠的,比如linux中每个用户进程它的运行地址(虚拟地址)都是0x0,这时如果想去同时调试所有进程,那么必须要有个办法把这些进程区分开来,trace32 就在虚拟地址前面加前缀的方法,这个前缀称为space id, 这个space id 实际上就是processor id或者是task id, 这样就可以把一个os内部的不同的进程区分开来。如果工具和内核中的连接是可以建立起来的,那么接下来就是调试工具使用的问题了。

CodingCos的博客 1968

macOS开发:调整NSImage尺寸大小

extension NSImage { func resize(_ to: CGSize, isPixels: Bool = false) -> NSImage { var toSize = to let screenScale: CGFloat = NSScreen.main?.backingScaleFactor ?? ...

我只是一个攻城狮 2045

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

将一个NSImage实例保存成图片文件

这里例子中将NSImage对象以png的格式保存到本地硬盘。 - (void )saveImage:(NSImage *)image {     [image lockFocus];        //先设置 下面一个实例     NSBitmapImageRep *bits = [[[NSBitmapImageRep alloc]initWithFocusedViewRect:NS

Secret Island 5964

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

关于CGImageRef

一、概念 1)NSImage 是一个抽象类,它能代表各种图像类型,同时也能定义各种图像。通常,大家如果对图像的类型不在意的话,NSImage是很好用的。同时,他也是Appkit唯一能接受的图像类,至少到目前为止是这样。(Appkit , UIKit 是iphone里界面,UI的库) 2)CGImage只能代表bitmaps。如果你像直接和bitmap 数据打交道,CGImage是很好的

Benson的学习笔记 3497

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

NSImage 存储为jpg或png文件的方法

相同:     NSData *imageData = [image TIFFRepresentation];     NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData];     [imageRep setSize:[[_imageView image] size]];     不同

yuanya的专栏 3945

Mac图像NSimage缩放、组合、压缩及CIImageRef和NSImage转换处理

声名:图片均来自于网络,如有侵权请联系删除!!! 1. 图片改变size: 挤压图片到目标尺寸 截取中间部分为目标尺寸 原图 2. 图片组合 3. ZLImage // // ZLImage.h // ImageDemo // // Created by Jiaozl 2018 on 2018/9/7. // Copyright © 2018年 Jia...

ADreamClusive的博客 5079

nsimage 转 png ,jpg的nsdata 类型

NSImage * image = ..........; NSData *imageData = [image TIFFRepresentation]; NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData];[imageRep setSize:[[_imageView image] size

bravegogo的专栏 5626

NSImage 操作扩展类别(category)

在开发的时候从国外网站搜集到的: http://cocoadev.com/wiki/NSImageCategory NSImage+CCDAdditions.h @interface NSImage (CocoaDevUsersAdditions) + (NSImage *)scaleImage:(NSImage *)p_w_picpath toSize:(...

weixin_34378767的博客 225

NSData,NSImage,NSDictionary,NSString,NSURL 等等互相转换

一:NSString和NSURL 转换 //NSString->NSURL NSString *urlString=[@"http://www.baidu.com" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url=[NSURL URLWithString:urlString];

jueyi1127的博客 1095

[Cocoa]_[初级]_[NSString 、NSImage、NSData、std::string之间的转换]

NSString *filePath =@"/Users/mac-d1/work/Untitled.gif"; NSImage *gifImage = [[NSImage alloc] initWithContentsOfFile:filePath]; NSData *imageData = [gifImage TIFFRepresentation];

moqj_123的专栏 2084

NSimage的size和pixels

    使用[image size] 获得图片的NSSize,宽和长。他们可以是 点,像素,英寸,厘米,毫秒为单位,    在NSImageRep 对象可以获得像素和size,pixelsHeight和pixelsWidth。如:1024*768.    一般NSSize和像素值应该是相等的。但是我们取到的size和像素有可能是不相等的。   当进行缩放的时候一般是安装size进行缩放

Codelife 1870

NSImage的缓存

The NSImage class incorporates an internal caching scheme aimed at improving your application’s drawing performance. This caching scheme

SlimApp 1039

How to save PNG file from NSImage (retina issues)

参考网址:https://stackoverflow.com/questions/17507170/how-to-save-png-file-from-nsimage-retina-issues  /** 保存指定大小图片到本地路径下 @param image image 实体 @param filePath 文件的绝对路径 @param size imageSize (像素大小) ...

天道酬勤 701
上一篇: objective-c invoke javascript object and function
下一篇: 使用javascript来编写动态Html
nitghost
博客等级 码龄19年 32粉丝 111原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址