- Swift4.0: 利用图形上下文画基础图?
Dayu大鱼
步骤:开启图片上下文获取上下文配置上下文3.1填充颜色cgColor3.2填充尺寸从图形上下文中获取图片关闭上下文返回图片importFoundationimportUIKitextensionUIImage{///画一个白色背景的图片classfuncimageWithWhiteBackGroundColor()->UIImage{//开始图形上下文UIGraphicsBeginImageCon
- 获取image信息
布丶Ding
NSData*data=UIImageJPEGRepresentation(image,1.0);CGImageSourceRefref=CGImageSourceCreateWithData((__bridgeCFDataRef)data,NULL);CFDictionaryRefdicRef=CGImageSourceCopyPropertiesAtIndex(ref,0,NULL);NSDi
- 2018-01-16判断相机
super_2e20
pragmamark-摄像头和相册相关的公共类//判断设备是否有摄像头-(BOOL)isCameraAvailable{return[UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];}//前面的摄像头是否可用-(BOOL)isFrontCameraAvailable{retu
- iOS 图片添加模糊效果
海边的遐想
iOS.图片模糊效果的两种实现方法://1,vImage_Buffer可以调整模糊度pragmamark-----图片添加模糊效果----------------+(UIImage*)blurryImage:(UIImage*)imagewithBlurLevel:(CGFloat)blur{if(blur1.f){blur=0.5f;}intboxSize=(int)(blur*40);boxS
- 图片倒影
child_cool
A87C5877-1A82-4ED8-A48C-382C39708A6A.png方法一将图片添加到两个相同的layer上对要倒影的结果layer进行180度旋转使用渐变图层进行颜色处理letballoon=UIImage(named:"1.jpeg")lettopLayer=CALayer()topLayer.bounds=CGRect(x:0.0,y:0.0,width:balloon?.siz
- ios 图片加载内存尺寸_iOS图片内存优化
weixin_39606244
ios图片加载内存尺寸
基于现在iOS11新生成的图片都是HEIF,该图片使用UIImage(named:name)已不在那么优雅,图片大小为1.8m大小的,读进手机内存,直接飙升了45M,这是我们不想看到的结果,一个页面有多个这样子的图的话,恐怕就是灾难了。既然原图不能读入,那么如何可以用更少的内存和CPU来解决呢?这就要先了解该图片的编码了。HEICHEIF带有元数据的HEIF的另一种形式。HEIC文件包含一个或多个
- 某项目 需要在UITabbar 上显示小红点,在此搜罗了三个方法。
小蜗牛爬楼梯
1.使用系统自带的,并且可以在小红点上显示数字。[itemOnesetBadgeValue:@""];//显示不带数字的小红点[itemOnesetBadgeValue:@"1"];//显示小红点并且带数字以上的缺点:小红点太大了,伤不起啊!2.使用图片,创建图片的时候,设置图片的渲染。UIImage*normalImage=[[UIImageimageNamed:@"pic_msg_yes_no
- iOS 改变左右侧距离
王家小雷
(void)initNavBar{UIButton*addBtn=[[UIButtonalloc]initWithFrame:CGRectMake(0,0,24,24)];[addBtnsetImage:[UIImageimageNamed:@"NewBack"]forState:UIControlStateNormal];[addBtnsetContentHorizontalAlignment:
- Alamofire 上传图片
闲鱼尼克
letaddress=Service().avatarUrlString()letheaders=["authorization":"111111"]letimgData=UIImageJPEGRepresentation(uploadImage,0.2)!letURL=try!URLRequest(url:address,method:.post,headers:headers)Alamofir
- iOS 使用Image I/O 实现超大图片降采样
刘小哈哈哈
ios
一个图片解码成未压缩的位图的时候,占用的内存和图片的文件大小没有关系,和图片的尺寸大小有关系,尺寸越大,所需要的像素点越多,所以超大图片,我们需要进行优化处理这里直接上降采样代码给UIImage添加一个分类,在分类中添加一个方法,该size就是UIImageView的大小-(UIImage*)resizeCG:(CGSize)size{CGFloatmaxPixelSize=MAX(size.wi
- 图片解压缩
嘿丶花姑娘
(UIImage*)decompressedImageWithData:(NSData*)data{CGImageSourceRefsource=CGImageSourceCreateWithData((__bridgeCFDataRef)data,NULL);CGImageRefcgImage=CGImageSourceCreateImageAtIndex(source,0,(__bridgeC
- UICollectionView使用
搬砖行家
首先我们自定义一个UICollectionViewCell,和自定义UITableViewCell差不多,只是这里定义的是一个网格。-(id)initWithFrame:(CGRect)frame{self=[superinitWithFrame:frame];if(self){//设置CollectionViewCell中的图像框self.imageView=[[UIImageViewalloc
- (IOS)删除UISearchBar系统默认边框
rightmost
//方法一searchBar.searchBarStyle=UISearchBarStyleMinimal;//方法二[searchBarsetBackgroundImage:[[UIImagealloc]init]];//方法三searchBar.barTintColor=[UIColorwhiteColor];
- IOS的图片处理
X_code_ZH
1、定制图片大小,将图片定制为kAppIconSize宽高,用于图片的页面适应缩放UIImage*image=[[UIImagealloc]initWithData:data];if(image.size.width!=kAppIconSize||image.size.height!=kAppIconSize){CGSizeitemSize=CGSizeMake(kAppIconSize,kApp
- iOS高效图片压缩:HEIC图像压缩
DearDan_f92e
前言:HEIF(即高效图像文件格式)是一种新的图像文件格式,在许多方面都比其JPEG更好。该格式由MPEG在2013年开发,声称保存的数据量是JPEG的两倍,并且支持多种类型的图像数据。extensionUIImage{enumHEICError:Error{caseheicNotSupportedcasecgImageMissingcasecouldNotFinalize}//接口iOS4+。其
- 使用OpenCV处理图片的亮度、对比度、曝光、高光、阴影、饱和度、色温,色相(附源码)
奔跑的蚂蚁01
iOSopencv人工智能计算机视觉
屏幕录制2023-05-2222.09.32集成opencv的方式请参照上一个帖子OpenCV在iOS端的集成及Mat和UIImage互相转化(附源码)废话不多说直接上代码,伸手党福利:代码中记得引入头文件及命名空间#import#import"CVTools.h"//对应的.h文件命名空间在自己的.h文件后定义usingnamespacecv;usingnamespacestd;下面的处理方法统
- UIImage转PixelBuffer
陆号
extensionUIImage{publicfuncpixelBuffer(width:Int,height:Int)->CVPixelBuffer?{varmaybePixelBuffer:CVPixelBuffer?letattrs=[kCVPixelBufferCGImageCompatibilityKey:kCFBooleanTrue,kCVPixelBufferCGBitmapCont
- iOS面试题:SDWebImage原理
IOS应用
SDWebImage一个为UIImageView提供一个分类来支持远程服务器图片加载的库。功能简介:1、一个添加了web图片加载和缓存管理的UIImageView分类2、一个异步图片下载器3、一个异步的内存加磁盘综合存储图片并且自动处理过期图片4、支持动态gif图5、支持webP格式的图片6、后台图片解压处理7、确保同样的图片url不会下载多次8、确保伪造的图片url不会重复尝试下载9、确保主线程
- iOS13去掉tabBar黑线(Swift版)
ShineYangGod
iOS13之前,去掉黑线:设置UITarBar的backgroundImage和shadowImage即可:self.tabBar.backgroundImage=UIImage.init()self.tabBar.shadowImage=UIImage.init()iOS13之后不好使了,改用下面的方法:if#available(iOS13,*){letappearance=tabBar.sta
- Swift ImageView 加载SVG图片
冯汉栩
Swift基础swift开发语言ios
一直觉得自己写的不是技术,而是情怀,一个个的教程是自己这一路走来的痕迹。靠专业技能的成功是最具可复制性的,希望我的这条路能让你们少走弯路,希望我能帮你们抹去知识的蒙尘,希望我能帮你们理清知识的脉络,希望未来技术之巅上有你们也有我。前言在网上有网友总结过一遍写得不错的文章:iOS端矢量图解决方案汇总(SVG篇)正题添加SVG图片按键加载SVG图片button.setImage(UIImage(nam
- ios 获取视频中的某一帧图片
飞行的理想
/**获取视频的某一帧@paramcurrentTime某一时刻单位s@parampath视频路径@returnreturn返回image*/+(UIImage*)getVideoImageWithTime:(Float64)currentTimevideoPath:(NSURL*)path{AVURLAsset*asset=[[AVURLAssetalloc]initWithURL:pathop
- object-c一些基础内容--简单整理版
小白不想秃头
c语言ios开发语言objective
#import@interfaceViewController()@property(strong,nonatomic)UIImageView*imageView;@property(strong,nonatomic)UIButton*cameraButton;@end@implementationViewController-(void)viewDidLoad{[superviewDidLoad
- IOS 根据显示的空间尺寸来压缩显示图片尺寸
贼噶人
//按照显示控件的size来设置重新加载图片的尺寸funccompresImage(srcImage:UIImage,size:CGSize)->UIImage{ifsize.width>=srcImage.size.width&&size.height>=srcImage.size.height{returnsrcImage}varnewSize=CGSize.init()ifsrcImage.
- (IOS)获得灰度图
rightmost
+(UIImage*)covertToGrayImageFromImage:(UIImage*)sourceImage{intwidth=sourceImage.size.width;intheight=sourceImage.size.height;CGColorSpaceRefcolorSpace=CGColorSpaceCreateDeviceGray();CGContextRefconte
- iOS开发技巧-UIImageView 的contentMode属性说明和使用
Pandakingli
contentMode这个属性是用来设置图片的显示方式,如居中、居右,是否缩放等。苹果api里面的说明typedefNS_ENUM(NSInteger,UIViewContentMode){UIViewContentModeScaleToFill,UIViewContentModeScaleAspectFit,//contentsscaledtofitwithfixedaspect.remaind
- UIImage 图片处理:截图,缩放,设定大小,存储
S大偉
图片的处理大概分截图(capture),缩放(scale),设定大小(resize),存储(save)1.等比率缩放-(UIImage*)scaleImage:(UIImage*)imagetoScale:(float)scaleSize{UIGraphicsBeginImageContext(CGSizeMake(image.size.width*scaleSize,image.size.hei
- iOS UIButton 点击无响应的解决办法
CoderLGL
按钮不响应的原因按钮添加到了一个没有开启用户交互的父View上,例如UIImageView,这时候开启父试图的交互view.userInteractionEnabled=YES设为YES就可以解决问题按钮自身被遮挡,点击的时候根本就没有点击到button,而是他上面一层View,自然就不会响应,使用xcode看图层的方法,可以清晰看出.按钮的frame超出了父视图的frame,这个是最容易出现的,
- iOS改变UIBarButtonItem的大小
雪山飞狐_91ae
我们在写代码自定义UIBarButtonItem的时候,一般是像下面这样来定义的:self.navigationItem.rightBarButtonItem=[[UIBarButtonItemalloc]initWithImage:[UIImageimageNamed:@"qr-code"]style:UIBarButtonItemStylePlaintarget:selfaction:nil]
- iOS-圆角的另外两种实现方式
良人不归_墨染锦年
-(void)ImageV1{UIImageView*imageView=[[UIImageViewalloc]initWithFrame:CGRectMake(200,200,200,200)];imageView.image=[UIImageimageNamed:@"1"];UIBezierPath*maskPath=[UIBezierPathbezierPathWithRoundedRect
- swift BUtton调整左右subView的间距
LiYaoPeng
extensionUIButton{funcsetSubViewPosition(imageanImage:UIImage?=nil,title:String?=nil,titlePosition:UIViewContentMode,additionalSpacing:CGFloat,state:UIControlState){self.imageView?.contentMode=.center
- java线程Thread和Runnable区别和联系
zx_code
javajvmthread多线程Runnable
我们都晓得java实现线程2种方式,一个是继承Thread,另一个是实现Runnable。
模拟窗口买票,第一例子继承thread,代码如下
package thread;
public class ThreadTest {
public static void main(String[] args) {
Thread1 t1 = new Thread1(
- 【转】JSON与XML的区别比较
丁_新
jsonxml
1.定义介绍
(1).XML定义
扩展标记语言 (Extensible Markup Language, XML) ,用于标记电子文件使其具有结构性的标记语言,可以用来标记数据、定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言。 XML使用DTD(document type definition)文档类型定义来组织数据;格式统一,跨平台和语言,早已成为业界公认的标准。
XML是标
- c++ 实现五种基础的排序算法
CrazyMizzz
C++c算法
#include<iostream>
using namespace std;
//辅助函数,交换两数之值
template<class T>
void mySwap(T &x, T &y){
T temp = x;
x = y;
y = temp;
}
const int size = 10;
//一、用直接插入排
- 我的软件
麦田的设计者
我的软件音乐类娱乐放松
这是我写的一款app软件,耗时三个月,是一个根据央视节目开门大吉改变的,提供音调,猜歌曲名。1、手机拥有者在android手机市场下载本APP,同意权限,安装到手机上。2、游客初次进入时会有引导页面提醒用户注册。(同时软件自动播放背景音乐)。3、用户登录到主页后,会有五个模块。a、点击不胫而走,用户得到开门大吉首页部分新闻,点击进入有新闻详情。b、
- linux awk命令详解
被触发
linux awk
awk是行处理器: 相比较屏幕处理的优点,在处理庞大文件时不会出现内存溢出或是处理缓慢的问题,通常用来格式化文本信息
awk处理过程: 依次对每一行进行处理,然后输出
awk命令形式:
awk [-F|-f|-v] ‘BEGIN{} //{command1; command2} END{}’ file
[-F|-f|-v]大参数,-F指定分隔符,-f调用脚本,-v定义变量 var=val
- 各种语言比较
_wy_
编程语言
Java Ruby PHP 擅长领域
- oracle 中数据类型为clob的编辑
知了ing
oracle clob
public void updateKpiStatus(String kpiStatus,String taskId){
Connection dbc=null;
Statement stmt=null;
PreparedStatement ps=null;
try {
dbc = new DBConn().getNewConnection();
//stmt = db
- 分布式服务框架 Zookeeper -- 管理分布式环境中的数据
矮蛋蛋
zookeeper
原文地址:
http://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/
安装和配置详解
本文介绍的 Zookeeper 是以 3.2.2 这个稳定版本为基础,最新的版本可以通过官网 http://hadoop.apache.org/zookeeper/来获取,Zookeeper 的安装非常简单,下面将从单机模式和集群模式两
- tomcat数据源
alafqq
tomcat
数据库
JNDI(Java Naming and Directory Interface,Java命名和目录接口)是一组在Java应用中访问命名和目录服务的API。
没有使用JNDI时我用要这样连接数据库:
03. Class.forName("com.mysql.jdbc.Driver");
04. conn
- 遍历的方法
百合不是茶
遍历
遍历
在java的泛
- linux查看硬件信息的命令
bijian1013
linux
linux查看硬件信息的命令
一.查看CPU:
cat /proc/cpuinfo
二.查看内存:
free
三.查看硬盘:
df
linux下查看硬件信息
1、lspci 列出所有PCI 设备;
lspci - list all PCI devices:列出机器中的PCI设备(声卡、显卡、Modem、网卡、USB、主板集成设备也能
- java常见的ClassNotFoundException
bijian1013
java
1.java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 添加包common-logging.jar2.java.lang.ClassNotFoundException: javax.transaction.Synchronization
- 【Gson五】日期对象的序列化和反序列化
bit1129
反序列化
对日期类型的数据进行序列化和反序列化时,需要考虑如下问题:
1. 序列化时,Date对象序列化的字符串日期格式如何
2. 反序列化时,把日期字符串序列化为Date对象,也需要考虑日期格式问题
3. Date A -> str -> Date B,A和B对象是否equals
默认序列化和反序列化
import com
- 【Spark八十六】Spark Streaming之DStream vs. InputDStream
bit1129
Stream
1. DStream的类说明文档:
/**
* A Discretized Stream (DStream), the basic abstraction in Spark Streaming, is a continuous
* sequence of RDDs (of the same type) representing a continuous st
- 通过nginx获取header信息
ronin47
nginx header
1. 提取整个的Cookies内容到一个变量,然后可以在需要时引用,比如记录到日志里面,
if ( $http_cookie ~* "(.*)$") {
set $all_cookie $1;
}
变量$all_cookie就获得了cookie的值,可以用于运算了
- java-65.输入数字n,按顺序输出从1最大的n位10进制数。比如输入3,则输出1、2、3一直到最大的3位数即999
bylijinnan
java
参考了网上的http://blog.csdn.net/peasking_dd/article/details/6342984
写了个java版的:
public class Print_1_To_NDigit {
/**
* Q65.输入数字n,按顺序输出从1最大的n位10进制数。比如输入3,则输出1、2、3一直到最大的3位数即999
* 1.使用字符串
- Netty源码学习-ReplayingDecoder
bylijinnan
javanetty
ReplayingDecoder是FrameDecoder的子类,不熟悉FrameDecoder的,可以先看看
http://bylijinnan.iteye.com/blog/1982618
API说,ReplayingDecoder简化了操作,比如:
FrameDecoder在decode时,需要判断数据是否接收完全:
public class IntegerH
- js特殊字符过滤
cngolon
js特殊字符js特殊字符过滤
1.js中用正则表达式 过滤特殊字符, 校验所有输入域是否含有特殊符号function stripscript(s) { var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]"
- hibernate使用sql查询
ctrain
Hibernate
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.hibernate.Hibernate;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.Transa
- linux shell脚本中切换用户执行命令方法
daizj
linuxshell命令切换用户
经常在写shell脚本时,会碰到要以另外一个用户来执行相关命令,其方法简单记下:
1、执行单个命令:su - user -c "command"
如:下面命令是以test用户在/data目录下创建test123目录
[root@slave19 /data]# su - test -c "mkdir /data/test123" 
- 好的代码里只要一个 return 语句
dcj3sjt126com
return
别再这样写了:public boolean foo() { if (true) { return true; } else { return false;
- Android动画效果学习
dcj3sjt126com
android
1、透明动画效果
方法一:代码实现
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_main, container, fals
- linux复习笔记之bash shell (4)管道命令
eksliang
linux管道命令汇总linux管道命令linux常用管道命令
转载请出自出处:
http://eksliang.iteye.com/blog/2105461
bash命令执行的完毕以后,通常这个命令都会有返回结果,怎么对这个返回的结果做一些操作呢?那就得用管道命令‘|’。
上面那段话,简单说了下管道命令的作用,那什么事管道命令呢?
答:非常的经典的一句话,记住了,何为管
- Android系统中自定义按键的短按、双击、长按事件
gqdy365
android
在项目中碰到这样的问题:
由于系统中的按键在底层做了重新定义或者新增了按键,此时需要在APP层对按键事件(keyevent)做分解处理,模拟Android系统做法,把keyevent分解成:
1、单击事件:就是普通key的单击;
2、双击事件:500ms内同一按键单击两次;
3、长按事件:同一按键长按超过1000ms(系统中长按事件为500ms);
4、组合按键:两个以上按键同时按住;
- asp.net获取站点根目录下子目录的名称
hvt
.netC#asp.nethovertreeWeb Forms
使用Visual Studio建立一个.aspx文件(Web Forms),例如hovertree.aspx,在页面上加入一个ListBox代码如下:
<asp:ListBox runat="server" ID="lbKeleyiFolder" />
那么在页面上显示根目录子文件夹的代码如下:
string[] m_sub
- Eclipse程序员要掌握的常用快捷键
justjavac
javaeclipse快捷键ide
判断一个人的编程水平,就看他用键盘多,还是鼠标多。用键盘一是为了输入代码(当然了,也包括注释),再有就是熟练使用快捷键。 曾有人在豆瓣评
《卓有成效的程序员》:“人有多大懒,才有多大闲”。之前我整理了一个
程序员图书列表,目的也就是通过读书,让程序员变懒。 写道 程序员作为特殊的群体,有的人可以这么懒,懒到事情都交给机器去做,而有的人又可
- c++编程随记
lx.asymmetric
C++笔记
为了字体更好看,改变了格式……
&&运算符:
#include<iostream>
using namespace std;
int main(){
int a=-1,b=4,k;
k=(++a<0)&&!(b--
- linux标准IO缓冲机制研究
音频数据
linux
一、什么是缓存I/O(Buffered I/O)缓存I/O又被称作标准I/O,大多数文件系统默认I/O操作都是缓存I/O。在Linux的缓存I/O机制中,操作系统会将I/O的数据缓存在文件系统的页缓存(page cache)中,也就是说,数据会先被拷贝到操作系统内核的缓冲区中,然后才会从操作系统内核的缓冲区拷贝到应用程序的地址空间。1.缓存I/O有以下优点:A.缓存I/O使用了操作系统内核缓冲区,
- 随想 生活
暗黑小菠萝
生活
其实账户之前就申请了,但是决定要自己更新一些东西看也是最近。从毕业到现在已经一年了。没有进步是假的,但是有多大的进步可能只有我自己知道。
毕业的时候班里12个女生,真正最后做到软件开发的只要两个包括我,PS:我不是说测试不好。当时因为考研完全放弃找工作,考研失败,我想这只是我的借口。那个时候才想到为什么大学的时候不能好好的学习技术,增强自己的实战能力,以至于后来找工作比较费劲。我
- 我认为POJO是一个错误的概念
windshome
javaPOJO编程J2EE设计
这篇内容其实没有经过太多的深思熟虑,只是个人一时的感觉。从个人风格上来讲,我倾向简单质朴的设计开发理念;从方法论上,我更加倾向自顶向下的设计;从做事情的目标上来看,我追求质量优先,更愿意使用较为保守和稳妥的理念和方法。
&