简单的bitmap处理
来源:互联网 发布:淘宝虚拟物品记录 编辑:程序博客网 时间:2024/05/21 09:44
package com.example.testbitmap;import android.os.Bundle;import android.os.Environment;import android.app.Activity;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.view.Menu;import android.view.WindowManager;import android.widget.ImageView;public class MainActivity extends Activity {private ImageView imageView;int width, height;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);width = manager.getDefaultDisplay().getWidth();height = manager.getDefaultDisplay().getHeight();imageView = (ImageView) findViewById(R.id.iv);// showImage_0();showImage();}private void showImage() {BitmapFactory.Options options = new BitmapFactory.Options();// 不是真的拿到图片 , 只是拿到图片的头信息options.inJustDecodeBounds = true;BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+ "/big.jpg", options);int h = options.outHeight;int w = options.outWidth;System.out.println("outWidth:" + w);System.out.println("outHeight:" + h);int scalx = w / width;int scaly = h / height;int scale = 1;if (scalx > scaly & scaly >= 1) {scale = scalx;}if (scaly > scalx & scalx >= 1) {scale = scaly;}// 真的获取图片options.inJustDecodeBounds = false;// 采样率options.inSampleSize = scale;Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+ "/big.jpg", options);imageView.setImageBitmap(bitmap);}private void showImage_0() {// 不做处理Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/big.jpg");imageView.setImageBitmap(bitmap);}}
setImageResource setImageDrawable setImageBitmap
这三种内存占用升序为 bitmap resource drawable
0 0
- 简单的bitmap处理
- Bitmap的简单特效处理
- Bitmap图片的处理
- BitMap的处理
- 安卓中Bitmap的处理
- Bitmap的处理优化
- Bitmap的压缩处理
- Bitmap的简单保存
- Bitmap 处理 之加载大的Bitmap
- 性能优化-Bitmap简单处理分析
- Android Bitmap图片的处理
- Bitmap处理的一些方法
- Bitmap的一个简单实现
- Bitmap的加载简单优化
- Android中的Bitmap、Drawable、Byte[]、String、之间的转换及图像简单处理
- bitmap处理
- 简单异步处理 获取bitmap 和json string
- Android的Bitmap处理大图片解决方法
- MapReduce:超大机群上的简单数据处理(别人翻译的Google论文)
- 项目管理--不利团队建设的性格病历
- Reading device input directly from/to /dev/input/eventX in Ubuntu with C
- 来自别人的话,微软也开源了
- 命名规范
- 简单的bitmap处理
- open cl 教程
- android 命令行模式启动模拟器
- POJ 2299 解题报告
- DBus services
- uvaoj 624 CD 动态规划 01背包 记录答案
- 自己用django+html+SAE搭建自己的博客,最后部署(持续更新)
- 几种页面置换算法
- Out of Hay(poj2395)(并查集)