package com.Gallery3D;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import com.Gallary3D.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;
import android.graphics.Bitmap.Config;
import android.graphics.PorterDuff.Mode;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
private Context mContext;
private String[] mImagePaths;
private Drawable m_Drawable=null;
private Bitmap m_Bitmap=null;
public ImageAdapter(Context c, String[] strImagePath) {
mContext = c;
mImagePaths = strImagePath;
}
// public boolean createReflectedImages() {
//
// // 我们想要的差距之间的省思与原始图像
//
// final int reflectionGap = 4;
//
// int index = 0;
//
// for (String strPath : mImagePaths) {
//
// if (strPath != null && strPath.length() > 0) {
// InputStream stream = null;
// BitmapFactory.Options opt = null;
// try {
// FileInputStream inputstream = new FileInputStream(strPath);
//
// opt = new BitmapFactory.Options();
// opt.inSampleSize = 15;
// inputstream = new FileInputStream(strPath);
// stream = new BufferedInputStream(inputstream);
// Bitmap originalImage = BitmapFactory.decodeStream(stream, null, opt);
// inputstream.close();
//
//
//
//
// int width = originalImage.getWidth();
//
// int height = originalImage.getHeight();
//
//
//
// // 但这并不会将规模翻在Y轴上
//
// Matrix matrix = new Matrix();
//
// matrix.preScale(1, -1);
//
//
//
// // 创建一个位图与翻转矩阵,适用于这。
//
// // 我们只需要底部一半的形象
//
// Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0,
//
// height / 2, width, height / 2, matrix, false);
//
//
//
// // 创建一个新的位图以及相同宽度但更高的格格不入
//
//
// // 反射
//
// Bitmap bitmapWithReflection = Bitmap.createBitmap(width,
//
// (height + height / 2), Config.ARGB_8888);
//
//
// Canvas canvas = new Canvas(bitmapWithReflection);
//
// // 画出原始图像
// canvas.drawBitmap(originalImage, 0, 0, null);
//
// // 画在缝
//
// Paint deafaultPaint = new Paint();
//
// canvas.drawRect(0, height, width, height + reflectionGap,
//
// deafaultPaint);
//
// canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);
//
// Paint paint = new Paint();
//
// LinearGradient shader = new LinearGradient(0, originalImage
//
// .getHeight(), 0, bitmapWithReflection.getHeight()
//
// + reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
//
// paint.setShader(shader);
//
// paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
//
// // 画一个长方形使用油漆与我们的线性梯度
//
// canvas.drawRect(0, height, width, bitmapWithReflection.getHeight()
//
// + reflectionGap, paint);
//
// //解决图片的锯齿现象
//
// BitmapDrawable bd = new BitmapDrawable(bitmapWithReflection);
//
// bd.setAntiAlias(true);
//
// ImageView imageView = new ImageView(mContext);
//
// //imageView.setImageBitmap(bitmapWithReflection);
//
// imageView.setImageDrawable(bd);
//
// imageView.setLayoutParams(new GalleryFlow.LayoutParams(400, 400));
//
// imageView.setScaleType(ScaleType.FIT_XY);
//
// mImages[index++] = imageView;
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// finally {
// if (stream != null) {
// try {
// stream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// opt = null;
// }
// }
//
// }
//
// return true;
//
// }
public int getCount() {
return mImagePaths.length;
//循环播放时候使用
// return Integer.MAX_VALUE;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
class ViewHolder {
ImageView imageViewShow;
}
public View getView(int position, View convertView, ViewGroup parent) {
try{
final ViewHolder holder;
if (convertView == null) {
convertView = View.inflate(mContext,R.layout.gallery_item, null);
holder = new ViewHolder();
holder.imageViewShow = (ImageView) convertView.findViewById(R.id.imageViewShow);
}
else {
holder = (ViewHolder) convertView.getTag();
}
holder.imageViewShow.setImageDrawable(getDrawable(position));
convertView.setTag(holder);
return convertView;
}
catch(Exception e){
e.printStackTrace();
}
return convertView;
}
public float getScale(boolean focused, int offset) {
/* Formula: 1 / (2 ^ offset) */
return Math.max(0, 1.0f / (float) Math.pow(2, Math.abs(offset)));
}
private Drawable getDrawable(int intIndex){
// 我们想要的差距之间的省思与原始图像
final int reflectionGap = 10;
m_Drawable = null;
String strPath = mImagePaths[intIndex];
if (strPath != null && strPath.length() > 0) {
InputStream stream = null;
BitmapFactory.Options opt = null;
try {
FileInputStream inputstream = new FileInputStream(strPath);
opt = new BitmapFactory.Options();
opt.inSampleSize = 15;
inputstream = new FileInputStream(strPath);
stream = new BufferedInputStream(inputstream);
m_Bitmap = BitmapFactory.decodeStream(stream, null, opt);
inputstream.close();
int width = m_Bitmap.getWidth();
int height = m_Bitmap.getHeight();
// 但这并不会将规模翻在Y轴上
Matrix matrix = new Matrix();
matrix.preScale(1, -1);
// 创建一个位图与翻转矩阵,适用于这。
// 我们只需要底部一半的形象
Bitmap reflectionImage = Bitmap.createBitmap(m_Bitmap, 0,
height / 2, width, height / 2, matrix, false);
// 创建一个新的位图以及相同宽度但更高的格格不入
// 反射
Bitmap bitmapWithReflection = Bitmap.createBitmap(width,
(height + height / 2), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmapWithReflection);
// 画出原始图像
canvas.drawBitmap(m_Bitmap, 0, 0, null);
// 画在缝
Paint deafaultPaint = new Paint();
canvas.drawRect(0, height, width, height + reflectionGap,
deafaultPaint);
canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);
Paint paint = new Paint();
LinearGradient shader = new LinearGradient(0, m_Bitmap
.getHeight(), 0, bitmapWithReflection.getHeight()
+ reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
paint.setShader(shader);
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
// 画一个长方形使用油漆与我们的线性梯度
canvas.drawRect(0, height, width, bitmapWithReflection.getHeight()
+ reflectionGap, paint);
//解决图片的锯齿现象
BitmapDrawable bd = new BitmapDrawable(bitmapWithReflection);
bd.setAntiAlias(true);
m_Drawable = (Drawable)bd;
} catch (Exception e) {
e.printStackTrace();
}
finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
opt = null;
}
}
return m_Drawable;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
android实现Iphone的coverFlow图片浏览效果
共65个文件
png:34个
class:13个
xml:5个
4星 · 超过85%的资源 需积分: 10 343 下载量 179 浏览量
2011-07-26
08:58:35
上传
评论 2
收藏 4.74MB RAR 举报
温馨提示
主要是用Android的Gallery控件实现类似iPhone的图片浏览控件!!比较酷的效果!!可自行进行修改参数改变效果!!
资源推荐
资源详情
资源评论
收起资源包目录
Gallary3D.rar (65个子文件)
Gallary3D
bin
classes.dex 15KB
com
Gallary3D
R$layout.class 458B
R$id.class 445B
R$drawable.class 872B
R$attr.class 325B
R.class 496B
R$string.class 412B
Gallery3D
ImageAdapter$ViewHolder.class 537B
MainActivity.class 3KB
MainActivity$1.class 2KB
GalleryFlow.class 4KB
ShowImageActivity$1.class 763B
ShowImageActivity.class 4KB
ImageAdapter.class 6KB
resources.ap_ 1.56MB
Gallary3D.apk 1.57MB
res
drawable-ldpi
photo4.png 20KB
photo10.png 20KB
photo1.png 22KB
photo5.png 19KB
photo2.png 22KB
photo7.png 21KB
photo6.png 24KB
photo13.png 19KB
photo9.png 21KB
icon.png 2KB
photo16.png 10KB
photo15.png 21KB
photo11.png 23KB
photo3.png 21KB
photo8.png 22KB
photo12.png 21KB
photo14.png 429KB
drawable-hdpi
photo4.png 58KB
photo10.png 55KB
photo1.png 62KB
photo5.png 56KB
photo2.png 62KB
photo7.png 59KB
photo6.png 71KB
photo13.png 57KB
photo9.png 59KB
icon.png 4KB
photo15.png 58KB
photo11.png 66KB
photo3.png 60KB
photo8.png 63KB
photo12.png 59KB
photo14.png 32KB
values
strings.xml 171B
drawable-mdpi
icon.png 3KB
layout
main.xml 687B
show_image_activity.xml 395B
gallery_item.xml 381B
assets
default.properties 378B
gen
com
Gallary3D
R.java 2KB
proguard.cfg 1KB
.settings
org.eclipse.core.resources.prefs 86B
src
com
Gallery3D
ImageAdapter.java 8KB
MainActivity.java 3KB
ShowImageActivity.java 3KB
GalleryFlow.java 4KB
.project 845B
.classpath 280B
AndroidManifest.xml 807B
共 65 条
- 1
幸运永恒流星
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页