Coder Social home page Coder Social logo

picturecolor's Introduction

PictureColor

图片调色的java实现

运行环境 jdk8 以上.

示例图: 示例图

颜色计算代码

	
	/**
	 * 蓝色变换
	 * @param pix
	 * @param offSet
	 * @return
	 */
	public static int bTransform(int pix, int offSet){
		int f1 = pix & 0x000000ff;
		if((f1+offSet) < 0){
			return pix & 0xffffff00;
		}else if((f1+offSet) > 255){
			return pix & 0xffffff00 | 255;
		}else{
			return pix + offSet;
		}
	}
	
	/**
	 * 红色变换
	 * @param pix
	 * @param offSet
	 * @return
	 */
	public static int rTransform(int pix, int offSet){
		offSet = offSet << 16;
		int f1 = pix & 0x00ff0000;
		if((f1+offSet) < 0){
			return pix & 0xff00ffff;
		}else if((f1+offSet) > 0x00ff0000){
			return pix & 0xff00ffff | 0x00ff0000;
		}else{
			return pix + offSet;
		}
	}
	
	/**
	 * 绿色变换
	 * @param pix
	 * @param offSet
	 * @return
	 */
	public static int gTransform(int pix, int offSet){
		offSet = offSet << 8;
		int f1 = pix & 0x0000ff00;
		if((f1+offSet) < 0){
			return pix & 0xffff00ff;
		}else if((f1+offSet) > 0x0000ff00){
			return pix & 0xffff00ff | 0x0000ff00;
		}else{
			return pix + offSet;
		}
	}
	
	/**
	 * 反向通道
	 * @param pix
	 * @return
	 */
	public static int reverseAlpha(int pix){
		return (~pix)|0xff000000;
	}
	
	/**
	 * 红色通道
	 * @param pix
	 * @return
	 */
	public static int rAlpha(int pix){
		return pix & 0xffff0000;
	}
	
	/**
	 * 绿色通道
	 * @param pix
	 * @return
	 */
	public static int gAlpha(int pix){
		return pix & 0xff00ff00;
	}
	
	/**
	 * 蓝色通道
	 * @param pix
	 * @return
	 */
	public static int bAlpha(int pix){
		return pix & 0xff0000ff;
	}

picturecolor's People

Contributors

hexhero avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.