`
hao3100590
  • 浏览: 130839 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Android图片处理(Matrix,ColorMatrix)

阅读更多

在编程中有时候需要对图片做特殊的处理,比如将图片做出黑白的,或者老照片的效果,有时候还要对图片进行变换,以拉伸,扭曲等等。

这些效果在android中有很好的支持,通过颜色矩阵(ColorMatrix)和坐标变换矩阵(Matrix)可以完美的做出上面的所说的效果。

下面将分别介绍这两个矩阵的用法和相关的函数。

颜色矩阵
android中可以通过颜色矩阵(ColorMatrix类)方面的操作颜色,颜色矩阵是一个5x4 的矩阵(如图1.1)

可以用来方面的修改图片中RGBA各分量的值,颜色矩阵以一维数组的方式存储如下:
 [ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t ]
他通过RGBA四个通道来直接操作对应颜色,如果会使用Photoshop就会知道有时处理图片通过控制RGBA各颜色通道来做出特殊的效果。

这个矩阵对颜色的作用计算方式如1.3示:


矩阵的运算规则是矩阵A的一行乘以矩阵C的一列作为矩阵R的一行,

C矩阵是图片中包含的ARGB信息,R矩阵是用颜色矩阵应用于C之后的新的颜色分量,运算结果如下:
 
R' = a*R + b*G + c*B + d*A + e;
G' = f*R + g*G + h*B + i*A + j;
B' = k*R + l*G + m*B + n*A + o;
A' = p*R + q*G + r*B + s*A + t;
 
颜色矩阵并不是看上去那么深奥,其实需要使用的参数很少,而且很有规律第一行决定红色第二行决定绿色

第三行决定蓝色,第四行决定了透明度,第五列是颜色的偏移量。下面是一个实际中使用的颜色矩阵。


如果把这个矩阵作用于各颜色分量的话,R=A*C,计算后会发现,各个颜色分量实际上没有任何的改变(R'=R G'=G B'=B A'=A)。

图1.5所示矩阵计算后会发现红色分量增加100,绿色分量增加100,

这样的效果就是图片偏黄,因为红色和绿色混合后得到黄色,黄色增加了100,图片当然就偏黄了。

改变各颜色分量不仅可以通过修改第5列的颜色偏移量也可如上面矩阵所示将对应的颜色值乘以一个倍数,直接放大。

上图1.6是将绿色分量乘以2变为原来的2倍。相信读者至此已经明白了如何通过颜色矩阵来改变各颜色分量。

下面编写一段代码来,通过调整颜色矩阵来获得不同的颜色效果,JavaCode如下:

MyImage.java

package com.hao.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.ho.R;

public class MyImage extends View {
	private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	private Bitmap mBitmap;
	private float[] array = new float[20];

	private float mAngle;

	public MyImage(Context context, AttributeSet attrs) {
		super(context, attrs);

		mBitmap = BitmapFactory.decodeResource(context.getResources(),
				R.drawable.sample_4);
		invalidate();
	}

	public void setValues(float[] a) {
		for (int i = 0; i < 20; i++) {
			array[i] = a[i];
		}

	}

	@Override
	protected void onDraw(Canvas canvas) {
		Paint paint = mPaint;

		paint.setColorFilter(null);
		canvas.drawBitmap(mBitmap, 0, 0, paint);

		ColorMatrix cm = new ColorMatrix();
		// 设置颜色矩阵
		cm.set(array);
		// 颜色滤镜,将颜色矩阵应用于图片
		paint.setColorFilter(new ColorMatrixColorFilter(cm));
		// 绘图
		canvas.drawBitmap(mBitmap, 0, 0, paint);
		Log.i("CMatrix", "--------->onDraw");
	}
}

 MatrixTestActivity.java

package com.hao;

import com.ho.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MatrixTestActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_one);
        Button one = (Button) findViewById(R.id.button1);
        one.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(new Intent(MatrixTestActivity.this, ColorMatrixActivity.class));
			}
		});
        
        Button two = (Button) findViewById(R.id.button2);
        two.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(new Intent(MatrixTestActivity.this, MoveMatrixActivity.class));
			}
		});
    }
}
 

加上布局文件:

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
	<com.hao.view.MyImage
		android:id="@+id/MyImage"
		android:layout_height="180dip"
		android:layout_width="fill_parent"/>
	<TableLayout 
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:orientation="vertical">
		<TableRow 
			android:orientation="horizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content">
			<EditText 
				android:id="@+id/indexa0"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa1"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa2"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa3"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa4"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
		</TableRow>	
		<TableRow 
			android:orientation="horizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content">
			<EditText 
				android:id="@+id/indexa5"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa6"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa7"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa8"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa9"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
		</TableRow>	
		<TableRow 
			android:orientation="horizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content">
			<EditText 
				android:id="@+id/indexa10"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa11"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa12"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa13"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa14"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
		</TableRow>	
		<TableRow 
			android:orientation="horizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content">
			<EditText 
				android:id="@+id/indexa15"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa16"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa17"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa18"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
				<EditText 
				android:id="@+id/indexa19"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
		</TableRow>	
	</TableLayout>
	<Button 
		android:id="@+id/set"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:text="colorMartrix变换"
	/>
</LinearLayout>
 

 

CMatrix类主要负责接收颜色矩阵的设置和重绘,没有要说的。MyImage类中进行绘图工作,首先设置颜色矩阵cm.set(..)从一维数组中读取数据20个数据给颜色矩阵赋值,paint.setColorFilter(..)设置颜色滤镜,然后绘图,效果就出来了(这个过程和PS差不多)如下:





看到这里,相信大家对颜色矩阵的作用已经有了一个直观的感受,现在也可以尝试做一个照片特效的软件。

但是各种效果并不能让用户手动调节颜色矩阵,这里需要计算公式,由于本人并不是做图形软件的也不能提供,可以参考这个链接:
http://www.adobe.com/devnet/flash/articles/matrix_transformations/ColorMatrixDemo.swf


坐标变换矩阵
坐标变换矩阵是一个3*3的矩阵如图2.1,用来对图形进行坐标变化,将原来的坐标点转移到新的坐标点,

因为一个图片是有点阵和每一点上的颜色信息组成的,所以对坐标的变换,就是对每一点进行搬移形成新的图片。

具体的说图形的放大缩小,移动,旋转,透视,扭曲这些效果都可以用此矩阵来完成。


这个矩阵的作用是对坐标x,y进行变换计算结果如下:
x'=a*x+b*y+c
y'=d*x+e*y+f
通常情况下g=h=0,这样使1=0*x+0*y+1恒成立。和颜色矩阵一样,坐标变换矩阵真正使用的参数很少也很有规律。


上图就是一个坐标变换矩阵的简单例子,计算后发现x'=x+50,y'=y+50.

可见图片的每一点都在x和y方向上平移到了(50,50)点处,这种效果就是平移效果,将图片转移到了(50,50)处。

计算上面得矩阵x'=2*x,y‘=2*y.经过颜色矩阵和上面转移效果学习,相信读者可以明白这个矩阵的作用了,这个矩阵对图片进行了放大,具体的说是放大了二倍。
下面将介绍几种常用的变换矩阵:
1.      旋转


绕原点逆时针旋转θ度角的变换公式是 x' = xcosθ − ysinθ 与 y。' = xsinθ +    ycosθ

旋转过程图解:



 
2.      缩放


变换后长宽分别放大x'=scale*x;y'=scale*y.
3.         切变


4.         反射

( , )单位向量
5.         正投影

( , )单位向量
 
上面的各种效果也可以叠加在一起,既矩阵的组合变换,可以用矩阵乘法实现之,如:R=B(A*C)=(B*A)C,注意一点就是B*A和A*B一般是不等的。

下面将编一个小程序,通过控制坐标变换矩阵来达到控制图形的目的,JavaCode如下:

MyMoveView.java

package com.hao.view;

import com.ho.R;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.util.Log;
import android.view.View;
import android.content.Context;
import android.util.AttributeSet;

public class MyMoveView extends View {
	public MyMoveView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		mBitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.music);
		invalidate();
	}

	private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	private Bitmap mBitmap;
	private float[] array = new float[9];

	public void setValues(float[] a) {
		for (int i = 0; i < 9; i++) {
			array[i] = a[i];
		}
	}

	@Override
	protected void onDraw(Canvas canvas) {
		Paint paint = mPaint;
		canvas.drawBitmap(mBitmap, 0, 0, paint);
		// new 一个坐标变换矩阵
		Matrix cm = new Matrix();
		// 为坐标变换矩阵设置响应的值
		cm.setValues(array);
		// 按照坐标变换矩阵的描述绘图
		canvas.drawBitmap(mBitmap, cm, paint);
		Log.i("CMatrix", "--------->onDraw");
	}
}

 MoveMatrixActivity.java

package com.hao;

import com.hao.view.MyMoveView;
import com.ho.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MoveMatrixActivity extends Activity {
	private Button change;
	private EditText[] et = new EditText[9];
	private float[] carray = new float[9];
	private MyMoveView sv;

	/** Called when the activity is first created. */
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_two);

		change = (Button) findViewById(R.id.change);
		sv = (MyMoveView) findViewById(R.id.moveView);

		for (int i = 0; i < 9; i++) {
			int id = R.id.ed1 + i;
			et[i] = (EditText) findViewById(id);
			carray[i] = Float.valueOf(et[i].getText().toString());
		}
		change.setOnClickListener(l);
	}

	private Button.OnClickListener l = new Button.OnClickListener() {
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			getValues();
			sv.setValues(carray);
			sv.invalidate();
		}
	};

	public void getValues() {
		for (int i = 0; i < 9; i++) {
			carray[i] = Float.valueOf(et[i].getText().toString());
		}
	}
}
 

加上布局:

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
	<com.hao.view.MyMoveView 
		android:id="@+id/moveView"
		android:layout_gravity="center_horizontal"
		android:layout_width="wrap_content"
		android:layout_height="200dip"
	/>
	<TableLayout 
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:orientation="vertical">
		<TableRow
			android:orientation="horizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content">
			<EditText
				android:id="@+id/ed1"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
			<EditText
				android:id="@+id/ed2"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
			<EditText
				android:id="@+id/ed3"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
		</TableRow>
		<TableRow
			android:orientation="horizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content">
			<EditText
				android:id="@+id/ed4"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
			<EditText
				android:id="@+id/ed5"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
			<EditText
				android:id="@+id/ed6"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
		</TableRow>
		<TableRow
			android:orientation="horizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content">
			<EditText
				android:id="@+id/ed7"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
			<EditText
				android:id="@+id/ed8"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
			<EditText
				android:id="@+id/ed9"
				android:text="0"
				android:layout_weight="1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"/>
		</TableRow>
	</TableLayout>
	<Button 
		android:id="@+id/change"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:text="moveMartrix变换"
	/>
</LinearLayout>

 
上面的代码中类CooMatrix用于接收用户输入的坐标变换矩阵参数,类MyImage接收参数,通过setValues()设置矩阵参数,然后Canvas调用drawBitmap绘图。效果如下:





上面给出了用坐标变换矩阵做出的各种效果,用坐标变换矩阵可以方面的调节图形的各种效果,

但是我们看看Matrix类就可以发现,实际上,matrix类本身已经提供了许多类似的方法,我们只要调用,就可以了。
 
setScale(float sx, float sy, float px, float py) 放大 
setSkew(float kx, float ky, float px, float py) 斜切 
setTranslate(float dx, float dy)                       平移 
setRotate(float degrees, float px, float py)    旋转 
 
上面的函数提供了基本的变换平移,放大,旋转,斜切。为了做出更复杂的变换,同时不必亲手去改动坐标变换矩阵,

Matrix类提供了许多Map方法,将原图形映射到目标点构成新的图形,

下面简述setPolyToPoly(float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount) 的用法,希望起到举一反三的作用。

参数src和dst是分别存储了原图像的点和和指定的目标点的一维数组,数组中存储的坐标格式如下:
 [x0, y0, x1, y1, x2,y2,...]
 
这个个函数将src中的坐标映射到dst中的坐标,实现图像的变换。

具体的例子可以参考APIDemos里的PolyToPoly,我在这里就不再贴代码了,只讲一下函数是怎么变换图片的。下面是效果:


图中写1的是原图,写有2,3,4的是变换后的图形。现在分析2是怎么变换来的,变换的原坐标点和目的坐标点如下:
src=new float[] { 32, 32, 64, 32 }
dst=new float[] { 32, 32, 64, 48 }

从上图标示出的坐标看出原图的(32,32)映射到原图的(32,32),(64,32)映射到原图(64,48)这样的效果是图像放大了而且发生了旋转。这样的过程相当于(32,32)点不动,然后拉住图形(64,32)点并拉到(64,48)点处,这样图形必然会被拉伸放大并且发生旋转。最后用一个平移将图形移动到右边现在的位置。希望能够好好理解这一过程,下面的3,4图是同样的道理。

代码:

 

/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.apis.graphics;

// Need the following import to get access to the app resources, since this
// class is in a sub-package.
//import com.example.android.apis.R;

import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
import android.view.View;

public class PolyToPoly extends GraphicsActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(new SampleView(this));
    }
    
    private static class SampleView extends View {
        private Paint   mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        private Matrix  mMatrix = new Matrix();
        private Paint.FontMetrics mFontMetrics;

        private void doDraw(Canvas canvas, float src[], float dst[]) {
            canvas.save();
            //这个函数很关键,是利用坐标点的对应关系进行图像变换,从src->dst
            mMatrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1);
            canvas.concat(mMatrix);
            //画一个矩形
            mPaint.setColor(Color.GRAY);
            mPaint.setStyle(Paint.Style.STROKE);
            canvas.drawRect(0, 0, 64, 64, mPaint);
            canvas.drawLine(0, 0, 64, 64, mPaint);
            canvas.drawLine(0, 64, 64, 0, mPaint);
            
            //在矩形上写字并设置其位置居于矩形中间
            mPaint.setColor(Color.RED);
            mPaint.setStyle(Paint.Style.FILL);
            // how to draw the text center on our square
            // centering in X is easy... use alignment (and X at midpoint)
            float x = 64/2;
            // centering in Y, we need to measure ascent/descent first
            float y = 64/2 - (mFontMetrics.ascent + mFontMetrics.descent)/2;
            canvas.drawText(src.length/2 + "", x, y, mPaint);
            //画一次存一次
            canvas.restore();
        }

        public SampleView(Context context) {
            super(context);

            // for when the style is STROKE
            mPaint.setStrokeWidth(4);
            // for when we draw text
            mPaint.setTextSize(40);
            mPaint.setTextAlign(Paint.Align.CENTER);
            mFontMetrics = mPaint.getFontMetrics();
        }
        
        @Override protected void onDraw(Canvas canvas) {
            Paint paint = mPaint;

            canvas.drawColor(Color.WHITE);

            canvas.save();
            //x和y轴都平移10然后画第一个矩形
            canvas.translate(10, 10);
            // translate (1 point),
            doDraw(canvas, new float[] { 0, 0 }, new float[] { 5, 5 });
            canvas.restore();
            
            canvas.save();
            canvas.translate(160, 10);
            //原图的(32,32)映射到原图的(32,32),(64,32)映射到原图(64,48)
            //这样的效果是图像放大了而且发生了旋转。这样的过程相当于(32,32)点不动,
            //然后拉住图形(64,32)点并拉到(64,48)点处,这样图形必然会被拉伸放大并且发生旋转。
            //最后用一个平移将图形移动到右边现在的位置。
            // rotate/uniform-scale (2 points)
            doDraw(canvas, new float[] { 32, 32, 64, 32 },
                           new float[] { 32, 32, 64, 48 });
            canvas.restore();

            canvas.save();
            canvas.translate(10, 110);
            // rotate/skew (3 points),初始三个点就是矩形左上三个顶点
            doDraw(canvas, new float[] { 0, 0, 64, 0, 0, 64 },
                           new float[] { 0, 0, 96, 0, 24, 64 });
            canvas.restore();

            canvas.save();
            canvas.translate(160, 110);
            // perspective (4 points),对四个顶点都拉伸和变换
            doDraw(canvas, new float[] { 0, 0, 64, 0, 64, 64, 0, 64 },
                           new float[] { 0, 0, 96, 0, 64, 96, 0, 64 });
            canvas.restore();
        }
    }
}
 

 

非常感谢

转载自:http://www.cnblogs.com/leon19870907/articles/1978065.html

还有这个http://blog.csdn.net/kuku20092009/article/details/6740865

也讲的非常好!再次感谢

 

 

 

  • 大小: 67.8 KB
分享到:
评论

相关推荐

    实战Android:图片处理之ColorMatrix和Matrix实例

    在Android开发中,图片处理是不可或缺的一部分,尤其是在创建丰富的用户界面和动态效果时。本教程将深入探讨如何利用`ColorMatrix`和`Matrix`类来实现图像色彩和形状的变换。`ColorMatrix`用于处理颜色空间转换,而`...

    Android使用Matrix矩阵类对图像进行缩放、旋转、对比度、亮度处理(原代码)

    该资源主要是结合博客...免费资源仅供大家学习参考,同时项目主要是讲述Matrix的方法,在加载大图片时可能会出现越界bug,横竖屏切换都没有考虑.希望对大家有所帮助吧!By:Eastmount

    android图片处理集合demo

    在Android开发中,图片处理是一项常见的任务,涉及到用户体验和应用性能。"android图片处理集合demo"是一个示例项目,集中展示了多种图片处理技术。虽然代码可能没有经过精心整理,但仍然能为开发者提供宝贵的参考。...

    Android图片处理demo

    在Android平台上,图片处理是一项常见的任务,涉及到许多技术细节和组件。这个"Android图片处理demo"是一个很好的起点,用于理解如何在Android应用中管理和操作图像。让我们深入探讨一下这个示例代码可能涵盖的关键...

    Android图片处理

    在Android平台上,图片处理是一项重要的任务,特别是在开发各种应用程序,如社交网络、图像编辑器或者游戏时。Android提供了丰富的API和工具,使开发者能够实现类似于Adobe Photoshop(简称PS)的效果。下面将详细...

    android 图片处理

    在Android平台上,图片处理是一项常见的任务,涉及到许多技术细节和工具。这篇博文“android 图片处理”可能探讨了如何在Android应用中有效地管理和操作图像。虽然具体的博客内容没有提供,但我们可以根据标题和标签...

    Android应用源码之100种图片处理效果大全项目.rar

    《Android应用源码之100种图片处理效果大全项目》是一个非常实用的学习资源,它提供了丰富的图片处理技术实现,适合Android开发者深入理解和实践。在这个项目中,你可以找到各种图片处理技术的应用实例,涵盖了许多...

    android常用图片特效处理

    7. **开源库支持**:在Android社区,有许多优秀的开源库可以帮助开发者快速实现各种图片特效,如Picasso、Glide、Volley等,它们不仅包含图片加载功能,还提供了图片处理和优化的API。 在实际项目中,为了提高性能...

    android图片处理总结

    ### Android 图片处理知识点总结 #### 一、Bitmap、Drawable 和 byte[] 之间的相互转换 在 Android 开发中,图片的加载与显示是常见的需求之一。对于开发者来说,掌握 Bitmap、Drawable 以及 byte[] 之间的转换是...

    android图片处理方法

    本文将详细介绍两种主要的Android图片处理方法:调整图片灰度和使用Matrix进行图像变换。 首先,我们来看如何在Android中改变图片的灰度。这个过程涉及到对图片色彩饱和度的调整。在描述中提到,当有两个IM好友的...

    一个简单的Android图片处理DEMO

    在Android开发中,图片处理是一项常见的任务,尤其在社交应用、图像编辑软件或者任何涉及到用户交互的项目中。本DEMO提供了一个简单的解决方案,涵盖了图片选择、贴图、滤镜应用、裁剪以及旋转等功能。下面我们将...

    Android常用图片特效处理源码.zip

    这个名为"Android常用图片特效处理源码.zip"的压缩包文件,很可能包含了一系列用于实现Android平台上常见图片处理功能的源代码。这些特效可能包括图片的滤镜应用、旋转、裁剪、缩放、模糊化等。 首先,我们来讨论...

    简单的android图片处理应用,实现了旋转,翻转,放大缩小,灰度,亮度,边缘检测,颜色过滤,高斯模糊,裁剪

    在Android平台上,图片处理是一项常见的任务,用于提升用户体验或实现艺术效果。本应用专注于提供一套基本但实用的图片处理功能,包括旋转、翻转、缩放、灰度处理、调整亮度、边缘检测、颜色过滤、高斯模糊以及裁剪...

    Android图片特效处理Demo

    在Android平台上,图片特效处理是移动应用开发中的一个重要领域,特别是在社交媒体、摄影应用以及个性化定制应用中。这个“Android图片特效处理Demo”旨在提供一系列预设的图像处理效果,包括负片、锐化、旋转、浅色...

    android图片特效处理

    在Android平台上,图片特效处理是一项重要的任务,它可以让应用程序呈现出丰富的视觉效果,增强用户体验。本文将深入探讨如何在Android中实现图片的灰度处理和复古风格处理,以及其他可能的图片特效。 首先,让我们...

    android 100种图片处理大全

    在Android开发中,图片处理是一项不可或缺的技术,尤其在如今视觉体验至上的移动应用时代。"Android 100种图片处理大全"项目提供了一个全面的资源库,涵盖了各种图片处理技术,这对于开发者来说是一个宝贵的参考资料...

    Android 常用图片特效处理源码.zip源码资源下载

    首先,我们关注的是Android平台下的图片处理库,例如Java内置的Bitmap类和Canvas类。Bitmap是Android中用于存储图像数据的基本类,它可以进行像素级别的操作,如颜色替换、缩放、旋转等。Canvas则提供了一个画布,...

    史上完整android图片特效代码

    11. **自定义视图**:如果标准的Android组件无法满足需求,开发者可以通过继承`View`或`ViewGroup`来自定义图片处理视图,实现独特的特效。 这些知识点只是冰山一角,实际的代码库可能包含了更多高级特性,如GPU...

    android常用图片特效处理(实用1).zip

    本资源包“android常用图片特效处理(实用1).zip”包含了一系列实用的源码,适用于毕业设计或课程设计项目,帮助开发者学习并实践Android图片处理技术。以下是基于这个资源包中的关键知识点的详细说明: 1. 图片加载...

Global site tag (gtag.js) - Google Analytics