ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:131.19KB ,
资源ID:17256198      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/17256198.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Android图片镜像倒影特效Word格式文档下载.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Android图片镜像倒影特效Word格式文档下载.docx

1、paint.setShader(shader);/ Set the Transfer mode to be porter duff and destination inpaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN);/ Draw a rectangle using the paint with our linear gradientcanvas.drawRect(0, height, width, bitmapWithReflection.getHeight()+ reflectionGap, paint);return bitmap

2、WithReflection;android Gallery镜像倒影特效2011-06-25 14:5888人阅读评论(0)收藏举报本文档将介绍在android上如何实现一个倒影效果的Gallery。代码如下:MirrorView.java是我自己实现的一个类,继承自Gallery类。重写了getChildStaticTransformation() 方法.package com.demo;import android.content.Context;import android.graphics.Camera;import android.graphics.Matrix;import and

3、roid.util.AttributeSet;import android.view.View;import android.view.animation.Transformation;import android.widget.Gallery;import android.widget.ImageView;public class MirrorView extends Gallery private Camera mCamera = new Camera(); / 是用来做类3D效果处理,比如z轴方向上的平移,绕y轴的旋转等 private int mMaxRotationAngle = 6

4、0; / 是图片绕y轴最大旋转角度,也就是屏幕最边上那两张图片的旋转角度 private int mMaxZoom = -380; / 是图片在z轴平移的距离,视觉上看起来就是放大缩小的效果. private int mCoveflowCenter; private boolean mAlphaMode = true; private boolean mCircleMode = false; public MirrorView(Context context) super(context); this.setStaticTransformationsEnabled(true); public

5、MirrorView(Context context, AttributeSet attrs) super(context, attrs); public MirrorView(Context context, AttributeSet attrs, int defStyle) super(context, attrs, defStyle); public int getMaxRotationAngle() return mMaxRotationAngle; public void setMaxRotationAngle(int maxRotationAngle) mMaxRotationAn

6、gle = maxRotationAngle; public boolean getCircleMode() return mCircleMode; public void setCircleMode(boolean isCircle) mCircleMode = isCircle; public boolean getAlphaMode() return mAlphaMode; public void setAlphaMode(boolean isAlpha) mAlphaMode = isAlpha; public int getMaxZoom() return mMaxZoom; pub

7、lic void setMaxZoom(int maxZoom) mMaxZoom = maxZoom; private int getCenterOfCoverflow() return (getWidth() - getPaddingLeft() - getPaddingRight() / 2 + getPaddingLeft(); /得到子对象的中线 private static int getCenterOfView(View view) return view.getLeft() + view.getWidth() / 2; protected boolean getChildSta

8、ticTransformation(View child, Transformation t) final int childCenter = getCenterOfView(child); final int childWidth = child.getWidth(); int rotationAngle = 0; t.clear(); t.setTransformationType(Transformation.TYPE_MATRIX); if (childCenter = mCoveflowCenter) transformImageBitmap(ImageView) child, t,

9、 0); else rotationAngle = (int) (float) (mCoveflowCenter - childCenter) / childWidth) * mMaxRotationAngle); if (Math.abs(rotationAngle) mMaxRotationAngle) rotationAngle = (rotationAngle 0) ? - mMaxRotationAngle : mMaxRotationAngle; transformImageBitmap(ImageView) child, t, rotationAngle); return tru

10、e; /* This is called during layout when the size of this view has changed. If* you were just added to the view hierarchy, youre called with the old* values of 0.* param w Current width of this view.* param h Current height of this view.* param oldw Old width of this view.* param oldh Old height of t

11、his view.*/ protected void onSizeChanged(int w, int h, int oldw, int oldh) mCoveflowCenter = getCenterOfCoverflow(); super.onSizeChanged(w, h, oldw, oldh);* Transform the Image Bitmap by the Angle passed* param imageView ImageView the ImageView whose bitmap we want to rotate* param t transformation*

12、 param rotationAngle the Angle by which to rotate the Bitmap private void transformImageBitmap(ImageView child, Transformation t, int rotationAngle) mCamera.save(); final Matrix imageMatrix = t.getMatrix(); final int imageHeight = child.getLayoutParams().height; final int imageWidth = child.getLayou

13、tParams().width; final int rotation = Math.abs(rotationAngle); mCamera.translate(0.0f, 0.0f, 100.0f); / As the angle of the view gets less, zoom in if (rotation = mMaxRotationAngle) float zoomAmount = (float) (mMaxZoom + (rotation * 1.5); mCamera.translate(0.0f, 0.0f, zoomAmount); if (mCircleMode) 4

14、0) mCamera.translate(0.0f, 155, 0.0f); else mCamera.translate(0.0f, (255 - rotation * 2.5f), 0.0f); if (mAlphaMode) (ImageView) (child).setAlpha(int) (255 - rotation * 2.5); mCamera.rotateY(rotationAngle); mCamera.getMatrix(imageMatrix); imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2)

15、; imageMatrix.postTranslate(imageWidth / 2), (imageHeight / 2); mCamera.restore();-自己实现的一个ReflectionImage类,用来实现图片的反转以及蒙板效果。import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.graphics.Canvas;import android.graphics.LinearGradient;import android.graphics.Paint;import a

16、ndroid.graphics.PorterDuffXfermode;import android.graphics.Bitmap.Config;import android.graphics.PorterDuff.Mode;import android.graphics.Shader.TileMode;import android.graphics.drawable.BitmapDrawable;public class ReflectionImage extends ImageView /是否为Reflection模式 private boolean mReflectionMode = t

17、rue; public ReflectionImage(Context context) public ReflectionImage(Context context, AttributeSet attrs) /取得原始图片的bitmap并重画 Bitmap originalImage = (BitmapDrawable)this.getDrawable().getBitmap(); DoReflection(originalImage); public ReflectionImage(Context context, AttributeSet attrs, int defStyle) pub

18、lic void setReflectionMode(boolean isRef) mReflectionMode = isRef; public boolean getReflectionMode() return mReflectionMode; /偷懒了,只重写了setImageResource,和构造函数里面干了同样的事情 Override public void setImageResource(int resId) Bitmap originalImage = BitmapFactory.decodeResource( getResources(), resId); /super.

19、setImageResource(resId); private void DoReflection(Bitmap originalImage) final int reflectionGap = 4; /原始图片和反射图片中间的间距 int width = originalImage.getWidth(); int height = originalImage.getHeight(); /反转 Matrix matrix = new Matrix(); matrix.preScale(1, -1); /reflectionImage就是下面透明的那部分,可以设置它的高度为原始的3/4,这样效

20、果会更好些 Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, 0, width, height, matrix, false); /创建一个新的bitmap,高度为原来的两倍 Bitmap bitmapWithReflection = Bitmap.createBitmap(width, (height + height), Config.ARGB_8888); Canvas canvasRef = new Canvas(bitmapWithReflection); /先画原始的图片 canvasRef.drawBit

21、map(originalImage, 0, 0, null); /画间距 Paint deafaultPaint = new Paint(); canvasRef.drawRect(0, height, width, height + reflectionGap, deafaultPaint); /画被反转以后的图片 canvasRef.drawBitmap(reflectionImage, 0, height + reflectionGap, null); / 创建一个渐变的蒙版放在下面被反转的图片上面 Paint paint = new Paint(); LinearGradient shader = new LinearGradient(0, originalImage.getHeight(), 0, bitmapWithReflection.getHeight()+ reflectionGap, 0x80ffffff, 0x00ffffff, TileMode.CLAMP);

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1