当前位置: 首页 > 软件库 > iOS代码库 > 图像(Image) >

UIImage-ImageWithColor

颜色创建图像工具
授权协议 MIT
开发语言 Objective-C
所属分类 iOS代码库、 图像(Image)
软件类型 开源软件
地区 不详
投 递 者 皇甫乐
操作系统 iOS
开源组织
适用人群 未知
 软件概览

UIImage-ImageWithColor 是一款使用颜色创建图像的工具。

用法

  • 用另一张图像制作模糊的图像
#import "UIImage+Blur.h"
...

// jpeg quality image data
float quality = .00001f;

// intensity of blurred
float blurred = .5f;
    
NSData *imageData = UIImageJPEGRepresentation([self.imageViewNormal image], quality);
UIImage *blurredImage = [[UIImage imageWithData:imageData] blurredImage:blurred];
self.imageViewBlurred.image = blurredImage;
  • 截屏
#import "UIImage+Screenshot.h"
...

UIImage *image = [UIImage screenshot];
self.imageView.image = image;
  • 生成彩色图像
#import "UIImage+ImageWithColor.h"
...
UIColor *purpleColor = [UIColor colorWithRed:.927f green:.264f blue:.03f alpha:1];
UIImage *image = [UIImage imageWithColor:purpleColor];
    
[self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
  • 获取图片上一点的颜色 根据图片上的一点,获得对应的颜色值。 UIImage *image = [UIImage imageNamed:@"sns_icon_15"]; UIColor *color = [self getColorAtPoint:CGPointMake(4, 44) atImage:image]; 实现代码: - (UIColor*) getColorAtPoint:(CGPoin

  • UIImage图片处理,旋转、截取、平铺、缩放等操作 有时候我们需要处理图片,比如改变大小,旋转,截取等等,所以今天说一说图片处理相关的一些操作。 本文所说的方法都是写在UIImage的Category中,这样使用起来也方便;由于代码太多,这里就不贴具体实现代码了,大家可以去我的Github查看demo,效果如下: 颜色相关 1.根据颜色生成纯色图片 就是根据制定的颜色生成一张纯色的图片 + (U

  • UIImage赋颜色:给image赋16进制颜色值 本讲: 在今天的项目中遇到了一个问题:从网络段解析的数据中得到的image是透明的(白色的),看不到它,研究好久,发现数据解析里有一个16进制的颜色值。需要把这个颜色值赋给image。 问题: <UIKit/UIKit.h>中并没有现成的直接给image赋值的方法。 办法: 1.写一个类目,把16进制的颜色值转化成10进制颜色值; 2.写

  • UIColor 转UIImage - (UIImage*) createImageWithColor: (UIColor*) color { CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGrap

  • UIImage扩展类压缩图片 1. @interface UIImage (UIImageExt) - (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize; @end @implementation UIImage (UIImageExt) - (UIImage*)imageByScalingAndCroppingForSiz

  • 代码如下: -(UIImage*) imageWithColor:(UIColor*)color { CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentCont

  • 在开发中使用分类对原有的系统类进行方法扩展,是增强系统原有类功能的常见做法。 /** * 自由拉伸一张图片 * * @param name 图片名字 * @param left 左边开始位置比例 值范围0-1 * @param top 上边开始位置比例 值范围0-1 * * @return 拉伸后的Image */ + (UIImage *)resizedImag

  • title: iOS中通过UIColor生成UIImage date: 2012-05-06 12:45:14 tags: UIColor UIImage categories: iOS iOS-Tips 创建一个UIImage的Category添加一下方法: + (instancetype)imageWithColor:(UIColor *)color { CGRect rect = C

  • 利用image属性renderingMode UIImageRenderingModeAutomatic  // 根据图片的使用环境和所处的绘图上下文自动调整渲染模式。   UIImageRenderingModeAlwaysOriginal   // 始终绘制图片原始状态,不使用Tint Color。   UIImageRenderingModeAlwaysTemplate   // 始终根据T

  • //  颜色转换为背景图片 + (UIImage *)imageWithColor:(UIColor *)color {     CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);     UIGraphicsBeginImageContext(rect.size);     CGContextRef context = UIGraphicsGetC

  • UIColor 转UIImage(可将该方法作为一个UIImage的分类) +(UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size; {         //描述一个矩形         CGRect rect = CGRectMake(0.0f, 0.0f,size.width,size.height);        

  • 将一个View保存为PNG保存到本地   1.首先写一个UIImage的分类,加入这个方法。 + (UIImage *)imageWithView:(UIView *)view { UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, view.layer.contentsScale); [vie

  • 用UIImage加载图像的方法很多,最常用的是下面两种:     1、用imageNamed函数 [UIImage imageNamed:ImageName];     2、用NSData的方式加载,例如:    1. NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:extension];   

  • @interface UIImage (Color) + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size; @end @implementation UIImage (Color) + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {

  • +(UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {          @autoreleasepool {                  CGRect rect = CGRectMake(0, 0, size.width, size.height);         UIGraphicsBeginImageContex

  • @interface UIImage (Color) + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size; @end @implementation UIImage (Color) + (UIImage *)imageWithColor:(UIColor *)color size:(C

  •   //UIColor 转UIImage - (UIImage*)imageWithColor: (UIColor*)color {          CGRect rect=CGRectMake(0.0f, 0.0f, 100.0f, 50.0f);     UIGraphicsBeginImageContext(rect.size);     CGContextRef context = UI

  • + (UIImage *)wm_imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); //开启图片上下文 UIGraphicsBeginImageContext(rect.size); //获取上下文 CGContextRef context = UIGraphicsGetC

 相关资料
  • 很抱歉问这个问题,但我不知道如何将UIImage表示为每个像素的UIColor数组。我尽了最大努力转换,但没有得到想要的结果。

  • 问题内容: 对于给定的多色PNG (具有透明度),什么是最好的/快速惯用的方法: 创建一个副本 在副本中找到所有黑色像素并将其更改为红色 (返回修改后的副本) 关于SO有一些相关的问题,但我一直无法找到可行的方法。 问题答案: 您必须提取图像的像素缓冲区,然后可以循环浏览,并根据需要更改像素。最后,从缓冲区创建一个新图像。 在Swift 3中,这看起来像:

  • 问题内容: 我想以编程方式创建由纯色填充的UIImage。有人知道如何在Swift中执行此操作吗? 问题答案: 另一个与 Swift 2.2 兼容的不错的解决方案是以这种方式在UIImage中创建另一个构造函数: 这样,您可以通过以下方式创建自定义彩色图像: 或者,可以选择创建具有自定义尺寸的图像: 斯威夫特3.0

  • 我正在尝试将一个十六进制值转换为一个int,这样我就可以创建一个新的彩色绘图。我不确定这是否可能,但根据文档,这是应该的。它很明显地要求

  • 主要内容:颜色命名,getrgb()方法,getcolor()Pillow 提供了颜色处理模块 ImageColor,该模块支持不同格式的颜色,比如 RGB 格式的颜色三元组、十六进制的颜色名称(#ff0000)以及颜色英文单词("red")。同时,它还可以将 CSS(层叠样式表,用来修饰网页)风格的颜色转换为 RGB 格式。 注意,在 ImageColor 模块对颜色的大小并不敏感,比如 "Red" 也可以写为 " red"。 颜色命名 ImageColo

  • 问题内容: 我正在尝试使用Swift来获取UIImage中像素的颜色,但它似乎总是返回0。这是从@Minas 对此线程的回答中转换的代码: 提前致谢! 问题答案: 由于遇到了类似的问题,一些搜索将我引到了这里。您的代码工作正常。该问题可能是由您的图像引起的。 码: 发生的是此方法将从图像的CGImage中选择像素颜色。因此,请确保您选择的是正确的图像。例如,如果您的UIImage是200x200,