图片相关

1. Bitmap位图

<!-- 对应于代码中的对象时BitmapDrawable -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_launcher"
android:antialias="true"   //抗锯齿
android:tileMode="mirror"  
//repeat:使图片平铺显示,mirror:使用图片又有镜像又有平铺显示,clamp:复制边缘的颜色,disabled:为默认选项
android:filter="true"      //位图过滤
android:dither="true"      //启用或禁用抖动的位图
android:gravity="center"   //设置图片的绘制位置 >
</bitmap>

2.selector背景选择器

使用:1.在ListView中配置android:listSelector="@drawable/list_item_bg"
            2.在listview的item中添加属性android:background=“@drawable/list_item_bg"
            3.代码中使用 Drawable drawable = getResources().getDrawable(R.drawable.list_item_bg);
               ListView.setSelector(drawable);android:cacheColorHint="@android:color/transparent" 

<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 默认时的背景图片 -->
    <item android:drawable="@drawable/pic1" />
    <!-- 没有焦点时的背景图片 -->
    <item android:state_window_focused="false" android:drawable="@drawable/pic1" />
    <!-- 非触摸模式下获得焦点并单击时的背景图片 -->
    <item android:state_focused="true" android:state_pressed="true" android:drawable= "@drawable/pic2" />
    <!-- 触摸模式下单击时的背景图片 -->
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pic3" />
    <!--选中时的图片背景  -->
    <item android:state_selected="true" android:drawable="@drawable/pic4" />
    <!--获得焦点时的图片背景  -->
    <item android:state_focused="true" android:drawable="@drawable/pic5" />
</selector>

3.shape控件显示属性

<shape android:shape="rectangle"
    xmlns:android="http://schemas.android.com/apk/res/android">

   <!-- 实心,就是填充的意思 -->
    <solid
        android:color="#ffeaeaea"/>

   <!-- 渐变,android:angle是渐变角度,渐变默认的模式为android:type="linear",即线性渐变,
        可以指定渐变为径向渐变,android:type="radial",径向渐变需要指定半径android:gradientRadius="50"-->
    <gradient
        android:startColor="#ffeaeaea"
        android:endColor="#ffeaeaea"
        android:angle="270.0"
        android:type="linear"
        android:centerY="0.5" />

   <padding
        android:left="7.0dip"
        android:top="7.0dip"
        android:right="7.0dip"
        android:bottom="7.0dip" />

   <!-- 圆角,android:radius为角的弧度,值越大角越圆 -->
    <corners
        android:radius="6.0dip" />

   <!-- 描边,把描边弄成虚线的形式,设置方式为:android:dashWidth="5dp" 横线宽度 android:dashGap="3dp" 隔开的距离 -->
    <stroke
        android:color="#ffeaeaea"/>
</shape>

4.读取本地图片转为Bitmap

    public class FileToBitmap {  
        public static Bitmap getBitmapFromFile(File dst, int width, int height) {  
            if (null != dst && dst.exists()) {  
                BitmapFactory.Options opts = null;  
                if (width > 0 && height > 0) {  
                    opts = new BitmapFactory.Options();  
                    opts.inJustDecodeBounds = true;  
                    BitmapFactory.decodeFile(dst.getPath(), opts);  
                    final int minSideLength = Math.min(width, height);  
                    opts.inSampleSize = computeSampleSize(opts, minSideLength,  
                            width * height);  
                    opts.inJustDecodeBounds = false;  
                    opts.inInputShareable = true;  
                    opts.inPurgeable = true;  
                }  
                try {  
                    return BitmapFactory.decodeFile(dst.getPath(), opts);  
                } catch (OutOfMemoryError e) {  
                    e.printStackTrace();  
                }  
            }  
            return null;  
        }  
      
        public static int computeSampleSize(BitmapFactory.Options options,  
                int minSideLength, int maxNumOfPixels) {  
            int initialSize = computeInitialSampleSize(options, minSideLength,  
                    maxNumOfPixels);  
      
            int roundedSize;  
            if (initialSize <= 8) {  
                roundedSize = 1;  
                while (roundedSize < initialSize) {  
                    roundedSize <<= 1;  
                }  
            } else {  
                roundedSize = (initialSize + 7) / 8 * 8;  
            }  
      
            return roundedSize;  
        }  
      
        private static int computeInitialSampleSize(BitmapFactory.Options options,  
                int minSideLength, int maxNumOfPixels) {  
            double w = options.outWidth;  
            double h = options.outHeight;  
      
            int lowerBound = (maxNumOfPixels == -1) ? 1 : (int) Math.ceil(Math  
                    .sqrt(w * h / maxNumOfPixels));  
            int upperBound = (minSideLength == -1) ? 128 : (int) Math.min(  
                    Math.floor(w / minSideLength), Math.floor(h / minSideLength));  
      
            if (upperBound < lowerBound) {  
                return lowerBound;  
            }  
      
            if ((maxNumOfPixels == -1) && (minSideLength == -1)) {  
                return 1;  
            } else if (minSideLength == -1) {  
                return lowerBound;  
            } else {  
                return upperBound;  
            }  
        }  
    }  

参考文章:http://www.tuicool.com/articles/63emAv
         http://blog.csdn.net/haozipi/article/details/47183543?ref=myread
         http://bugly.qq.com/bbs/forum.php?mod=viewthread&tid=498&fromuid=6  Bitmap 究竟占多大内存  

5.图片上传

    @Override  
        public void run() {  
            // TODO Auto-generated method stub  
            super.run();  
            new Runnable() {  
                public void run() {  
                    int res = 0;  
                    String BOUNDARY = UUID.randomUUID().toString(); // 边界标识 随机生成  
                    String PREFIX = "--", LINE_END = "\r\n";  
                    String CONTENT_TYPE = "multipart/form-data"; // 内容类型  
      
                    try {  
                        URL url = new URL(Content.SERVICE_URL + urlString);  
                        L.i(TAG, "url:" + url);  
                        HttpURLConnection conn = (HttpURLConnection) url  
                                .openConnection();  
                        conn.setReadTimeout(Content.CONNECT_TIMEOUT);  
                        conn.setConnectTimeout(Content.CONNECT_TIMEOUT);  
                        conn.setDoInput(true); // 允许输入流  
                        conn.setDoOutput(true); // 允许输出流  
                        conn.setUseCaches(false); // 不允许使用缓存  
                        conn.setRequestMethod("POST"); // 请求方式  
                        conn.setRequestProperty("Charset", "UTF-8"); // 设置编码  
                        conn.setRequestProperty("connection", "keep-alive");  
                        conn.setRequestProperty("Content-Type", CONTENT_TYPE  
                                + ";boundary=" + BOUNDARY);  
      
                        if (file != null) {  
                            DataOutputStream dos = new DataOutputStream(  
                                    conn.getOutputStream());  
                            StringBuffer sb = new StringBuffer();  
                            sb.append(PREFIX);  
                            sb.append(BOUNDARY);  
                            sb.append(LINE_END);  
                            sb.append("Content-Disposition: form-data; name=\"file\"; filename=\""  
                                    + file.getName() + "\"" + LINE_END);  
                            sb.append("Content-Type: application/octet-stream; charset="  
                                    + "UTF-8" + LINE_END);  
                            sb.append(LINE_END);  
                            dos.write(sb.toString().getBytes());  
                            InputStream is = new FileInputStream(file);  
                            byte[] bytes = new byte[1024];  
                            int len = 0;  
                            while ((len = is.read(bytes)) != -1) {  
                                dos.write(bytes, 0, len);  
                            }  
                            is.close();  
                            dos.write(LINE_END.getBytes());  
                            byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINE_END)  
                                    .getBytes();  
                            dos.write(end_data);  
                            dos.flush();  
                            res = conn.getResponseCode();  
                            L.i(TAG, "response code:" + res);  
                            if (res == 200) {  
                                L.i(TAG, "request success");  
                                InputStream input = conn.getInputStream();  
                                StringBuffer sb1 = new StringBuffer();  
                                int ss;  
                                while ((ss = input.read()) != -1) {  
                                    sb1.append((char) ss);  
                                }  
                                result = sb1.toString();  
                                L.i(TAG, "result : " + result);  
                                Message msg = new Message();  
                                msg.what = 1;  
                                msg.obj = sb1.toString();  
                                handler2.sendMessage(msg);  
                            } else {  
                                L.i(TAG, "request error");  
                            }  
                        }  
                    } catch (MalformedURLException e) {  
                        e.printStackTrace();  
                    } catch (IOException e) {  
                        e.printStackTrace();  
                    }  
                }  
            }.run();  
        }  

6.图片下载

public class InternetTest {   
    // 读取的方法   
    public byte[] readStream(InputStream inStream) throws Exception {   
        ByteArrayOutputStream outstream = new ByteArrayOutputStream();   
        byte[] buffer = new byte[1024]; // 用数据装   
        int len = -1;   
        while ((len = inStream.read(buffer)) != -1) {   
            outstream.write(buffer, 0, len);   
        }   
        outstream.close();   
        inStream.close();   
        // 关闭流一定要记得。   
        return outstream.toByteArray();   
    }   
   
    @Test   
    public void getImage() throws Exception {   
        //要下载的图片的地址,   
        String urlPath = "http://t2.gstatic.com/images?q=tbn:9g03SOE7gW2gEM:http://dev.10086.cn/cmdn/supesite";   
        URL url = new URL(urlPath);//获取到路径   
        // http协议连接对象   
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();   
        conn.setRequestMethod("GET");// 这里是不能乱写的,详看API方法   
        conn.setConnectTimeout(6 * 1000);   
        // 别超过10秒。   
        System.out.println(conn.getResponseCode());   
        if (conn.getResponseCode() == 200) {   
            InputStream inputStream = conn.getInputStream();   
            byte[] data = readStream(inputStream);   
            File file = new File("smart.jpg");// 给图片起名子   
            FileOutputStream outStream = new FileOutputStream(file);//写出对象   
            outStream.write(data);// 写入   
            outStream.close();  // 关闭流   
        }   
    }   
}   
7.图片压缩

第一:我们先看下质量压缩方法:
    private Bitmap compressImage(Bitmap image) {  
      
            ByteArrayOutputStream baos = new ByteArrayOutputStream();  
            image.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中  
            int options = 100;  
            while ( baos.toByteArray().length / 1024>100) {  //循环判断如果压缩后图片是否大于100kb,大于继续压缩         
                baos.reset();//重置baos即清空baos  
                image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中  
                options -= 10;//每次都减少10  
            }  
            ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());//把压缩后的数据baos存放到ByteArrayInputStream中  
            Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片  
            return bitmap;  
        }  

第二:图片按比例大小压缩方法(根据路径获取图片并压缩):
    private Bitmap getimage(String srcPath) {  
            BitmapFactory.Options newOpts = new BitmapFactory.Options();  
            //开始读入图片,此时把options.inJustDecodeBounds 设回true了  
            newOpts.inJustDecodeBounds = true;  
            Bitmap bitmap = BitmapFactory.decodeFile(srcPath,newOpts);//此时返回bm为空  
              
            newOpts.inJustDecodeBounds = false;  
            int w = newOpts.outWidth;  
            int h = newOpts.outHeight;  
            //现在主流手机比较多是800*480分辨率,所以高和宽我们设置为  
            float hh = 800f;//这里设置高度为800f  
            float ww = 480f;//这里设置宽度为480f  
            //缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可  
            int be = 1;//be=1表示不缩放  
            if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放  
                be = (int) (newOpts.outWidth / ww);  
            } else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放  
                be = (int) (newOpts.outHeight / hh);  
            }  
            if (be <= 0)  
                be = 1;  
            newOpts.inSampleSize = be;//设置缩放比例  
            //重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了  
            bitmap = BitmapFactory.decodeFile(srcPath, newOpts);  
            return compressImage(bitmap);//压缩好比例大小后再进行质量压缩  
        }  
第三:图片按比例大小压缩方法(根据Bitmap图片压缩): 
    private Bitmap comp(Bitmap image) {  
              
            ByteArrayOutputStream baos = new ByteArrayOutputStream();         
            image.compress(Bitmap.CompressFormat.JPEG, 100, baos);  
            if( baos.toByteArray().length / 1024>1024) {//判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出    
                baos.reset();//重置baos即清空baos  
                image.compress(Bitmap.CompressFormat.JPEG, 50, baos);//这里压缩50%,把压缩后的数据存放到baos中  
            }  
            ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());  
            BitmapFactory.Options newOpts = new BitmapFactory.Options();  
            //开始读入图片,此时把options.inJustDecodeBounds 设回true了  
            newOpts.inJustDecodeBounds = true;  
            Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);  
            newOpts.inJustDecodeBounds = false;  
            int w = newOpts.outWidth;  
            int h = newOpts.outHeight;  
            //现在主流手机比较多是800*480分辨率,所以高和宽我们设置为  
            float hh = 800f;//这里设置高度为800f  
            float ww = 480f;//这里设置宽度为480f  
            //缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可  
            int be = 1;//be=1表示不缩放  
            if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放  
                be = (int) (newOpts.outWidth / ww);  
            } else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放  
                be = (int) (newOpts.outHeight / hh);  
            }  
            if (be <= 0)  
                be = 1;  
            newOpts.inSampleSize = be;//设置缩放比例  
            //重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了  
            isBm = new ByteArrayInputStream(baos.toByteArray());  
            bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);  
            return compressImage(bitmap);//压缩好比例大小后再进行质量压缩  
        }  

8.图片分辨率减少方法,防止OOM

    public Bitmap getBitmapFromFile(File dst, int width, int height) {    
        if (null != dst && dst.exists()) {    
            BitmapFactory.Options opts = null;    
            if (width > 0 && height > 0) {    
                opts = new BitmapFactory.Options();    
                opts.inJustDecodeBounds = true;    
                BitmapFactory.decodeFile(dst.getPath(), opts);    
                // 计算图片缩放比例    
                final int minSideLength = Math.min(width, height);    
                opts.inSampleSize = computeSampleSize(opts, minSideLength,    
                        width * height);    
                opts.inJustDecodeBounds = false;    
                opts.inInputShareable = true;    
                opts.inPurgeable = true;    
            }    
            try {    
                return BitmapFactory.decodeFile(dst.getPath(), opts);    
            } catch (OutOfMemoryError e) {    
                e.printStackTrace();    
            }    
        }    
        return null;    
    }   
      
        public static int computeSampleSize(BitmapFactory.Options options,    
                int minSideLength, int maxNumOfPixels) {    
            int initialSize = computeInitialSampleSize(options, minSideLength,    
                    maxNumOfPixels);    
            
            int roundedSize;    
            if (initialSize <= 8) {    
                roundedSize = 1;    
                while (roundedSize < initialSize) {    
                    roundedSize <<= 1;    
                }    
            } else {    
                roundedSize = (initialSize + 7) / 8 * 8;    
            }    
            
            return roundedSize;    
        }    
            
        private static int computeInitialSampleSize(BitmapFactory.Options options,    
                int minSideLength, int maxNumOfPixels) {    
            double w = options.outWidth;    
            double h = options.outHeight;    
            
            int lowerBound = (maxNumOfPixels == -1) ? 1 : (int) Math.ceil(Math    
                    .sqrt(w * h / maxNumOfPixels));    
            int upperBound = (minSideLength == -1) ? 128 : (int) Math.min(Math    
                    .floor(w / minSideLength), Math.floor(h / minSideLength));    
            
            if (upperBound < lowerBound) {    
                // return the larger one when there is no overlapping zone.    
                return lowerBound;    
            }    
            
            if ((maxNumOfPixels == -1) && (minSideLength == -1)) {    
                return 1;    
            } else if (minSideLength == -1) {    
                return lowerBound;    
            } else {    
                return upperBound;    
            }    
        }    

9.打开相机照片和本机相册选择图片

1、PopActivity
    File file = new File(Content.CACHE_PATH + "/"+System.currentTimeMillis()+".png");  
                    if(!file.exists())  
                        try {  
                            file.createNewFile();  
                        } catch (IOException e) {  
                            // TODO Auto-generated catch block  
                            e.printStackTrace();  
                        }  
                    uri = Uri.fromFile(file);  
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);  
                            startActivityForResult(intent, TAKE_PHOTO);  
          
    @Override  
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
              
            if (resultCode != RESULT_OK) return;  
            switch (requestCode) {  
            case TAKE_PHOTO:  
                intent.setData(uri);  
                cropBitmap(uri);  
                break;  
      
    public void cropBitmap(Uri mUri) {  
              
            Intent intent = new Intent("com.android.camera.action.CROP");  
            intent.setDataAndType(mUri, "image/*");  
            intent.putExtra("crop", "true");  
            intent.putExtra("aspectX", 1);  
            intent.putExtra("aspectY", 1);  
            intent.putExtra("outputX", 200);  
            intent.putExtra("outputY", 200);  
            intent.putExtra("outputFormat", "png");  
            intent.putExtra("noFaceDetection", true);  
            intent.putExtra("return-data", true);  
            startActivityForResult(intent, CROP_PICTURE);  
        }  
          
          
    @Override  
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
              
            if (resultCode != RESULT_OK) return;  
            switch (requestCode) {  
            case CROP_PICTURE:  
                if(mark==2){  
                    if(data.getData()!=null){  
                        intent.setData(data.getData());  
                    }else{  
                        intent.putExtras(data.getExtras());  
                    }  
                }else{  
                    intent.putExtras(data.getExtras());  
                }  
                setResult(RESULT_OK, intent);  
                finish();  
                break;  
2、Activity

    @Override  
    protected void onActivityResult(int arg0, int arg1, Intent arg2) {  
            // TODO Auto-generated method stub  
            super.onActivityResult(arg0, arg1, arg2);  
      
            case TAKE_PHOTO:  
                if (arg2 != null) {  
                    Bitmap one = null;  
                    Uri photoUri = arg2.getData();  
                    L.i(TAG, "photoUri#" + arg2);  
                    if (photoUri.toString().contains("content://media")) {  
                        Cursor cursor = getContentResolver().query(photoUri, null,  
                                null, null, null);  
                        cursor.moveToFirst();  
                        String picturePath = cursor  
                                .getString(cursor  
                                        .getColumnIndexOrThrow(MediaStore.Images.Media.DATA));  
                        one = Util.getDiskBitmap(picturePath);  
                        cursor.close();  
                        iv3.setImageBitmap(one);  
                        String picPath = Util.saveBitmap(  
                                "" + System.currentTimeMillis(), Util.comp(one));  
                        String semd = Util.bitmaptoString(one);  
                        L.i(TAG, "p#" + picPath);  
                        new ImageUpLoader("postImg/picture?uid=" + uid, picPath,  
                                handler2).start();  
                    } else {  
                        Bundle extra = arg2.getExtras();    
                        if (extra != null) {    
                            one = (Bitmap)extra.get("data");  
                        }  
                        iv3.setImageBitmap(ImageToRound.toRoundBitmap(one));  
                        String picPath = Util.saveBitmap(  
                                "" + System.currentTimeMillis(), Util.comp(one));  
                        L.i(TAG, "p:"+picPath);  
                         new ImageUpLoader("postImg/picture?uid=" + uid, picPath,  
                         handler2).start();  
                    }  
                }  
                break;  


12.Android-Universal-Image-Loader 图片异步加载类库的使用

http://blog.csdn.net/vipzjyno1/article/details/23206387

1、
   private ImageLoader imageLoader;  
    private DisplayImageOptions options;  
      
      
    imageLoader = ImageLoader.getInstance();  
    imageLoader.init(ImageLoaderConfiguration.createDefault(context));  
    options = new DisplayImageOptions.Builder()  
                    .showStubImage(Content.NO_PHOTO)  
                    .showImageForEmptyUri(Content.NO_PHOTO)  
                    .showImageOnFail(Content.NO_PHOTO).cacheInMemory(true)  
                    .cacheOnDisc(true).bitmapConfig(Bitmap.Config.ARGB_8888)  
                    .build();  
                      
    imageLoader.displayImage(url2, vh.touImageView, options);  

2、

 public static void initImageLoader(Context context) {  
              
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(  
                    context).threadPriority(Thread.NORM_PRIORITY - 2)  
                    .denyCacheImageMultipleSizesInMemory()  
                    .discCacheFileNameGenerator(new Md5FileNameGenerator())  
                    .tasksProcessingOrder(QueueProcessingType.LIFO)  
                    .writeDebugLogs().build();  
        ImageLoader.getInstance().init(config);  
              
        }  

3、Configuration所有配置简介
    .memoryCacheExtraOptions(480, 800) //即保存的每个缓存文件的最大长宽    
    .threadPriority(Thread.NORM_PRIORITY - 2) //设置图片加载线程的优先级,默认为Thread.NORM_PRIORITY-1  线程池中线程的个数  注:如果设置了taskExecutor或者taskExecutorForCachedImages 此设置无效  
    .threadPoolSize(3) // 设置显示图片线程池大小,默认为3  注:如果设置了taskExecutor或者taskExecutorForCachedImages 此设置无效  
    .denyCacheImageMultipleSizesInMemory() // 设置拒绝缓存在内存中一个图片多个大小 默认为允许,(同一个图片URL)根据不同大小的imageview保存不同大小图片  
    .memoryCache(new LRULimitedMemoryCache(40*1024*1024)) //缓存策略  
    .memoryCacheSize(50 * 1024 * 1024) //设置内存缓存的大小   
    .diskCacheFileNameGenerator(new Md5FileNameGenerator()) // 设置硬盘缓存文件名生成规范 默认为new HashCodeFileNameGenerator()  
    .diskCacheSize(200 * 1024 * 1024) //磁盘缓存大小  
    .tasksProcessingOrder(QueueProcessingType.LIFO) //工作队列  设置图片加载和显示队列处理的类型 默认为QueueProcessingType.FIFO 注:如果设置了taskExecutor或者taskExecutorForCachedImages 此设置无效  
    .diskCacheFileCount(200) //缓存的文件数量    
    .diskCache(new UnlimitedDiskCache(cacheDir)) //自定义缓存路径   
    .taskExecutor(DefaultConfigurationFactory.createExecutor(3,Thread.NORM_PRIORITY - 1, QueueProcessingType.FIFO))  // 设置自定义加载和显示图片的线程池  
    .taskExecutorForCachedImages(DefaultConfigurationFactory.createExecutor(3,Thread.NORM_PRIORITY - 1, QueueProcessingType.FIFO)) // 设置自定义加载和显示内存缓存或者硬盘缓存图片的线程池  
    .memoryCache(new LruMemoryCache(2 * 1024 * 1024))  // 设置内存缓存 默认为一个当前应用可用内存的1/8大小的LruMemoryCache         
    .memoryCacheSize(2 * 1024 * 1024) // 设置内存缓存的最大大小 默认为一个当前应用可用内存的1/8  
    .memoryCacheSizePercentage(13)   // 设置内存缓存最大大小占当前应用可用内存的百分比 默认为一个当前应用可用内存的1/8  
    .discCache(new UnlimitedDiscCache(StorageUtils.getCacheDirectory(getApplicationContext())))   // 设置硬盘缓存默认为StorageUtils.getCacheDirectory(getApplicationContext())即/mnt/sdcard/android/data/包名/cache/              
    .discCacheSize(50 * 1024 * 1024)   // 设置硬盘缓存的最大大小              
    .discCacheFileCount(100)    // 设置硬盘缓存的文件的最多个数              
    .imageDownloader(new HttpClientImageDownloader(getApplicationContext(),new DefaultHttpClient()))  // 设置图片下载器 默认为 DefaultConfigurationFactory.createBitmapDisplayer()              
    .imageDecoder(DefaultConfigurationFactory.createImageDecoder(false))   // 设置图片解码器 ,默认为DefaultConfigurationFactory.createImageDecoder(false)              
    .defaultDisplayImageOptions(DisplayImageOptions.createSimple())  // 设置默认的图片显示选项 ,默认为DisplayImageOptions.createSimple()  
    .writeDebugLogs()   // 打印DebugLogs  
    .build();    // 建立   

4、DisplayImageOptions所有配置简介
.showImageOnLoading(R.drawable.ic_chat_def_pic) // 设置图片加载时的默认图片  
.showImageOnFail(R.drawable.ic_chat_def_pic_failure) // 设置图片加载失败的默认图片  
.showImageForEmptyUri(R.drawable.ic_chat_def_pic) // 设置图片URI为空时默认图片  
.resetViewBeforeLoading(false) // 设置是否将View在加载前复位  
.delayBeforeLoading(100) // 设置延迟部分时间才开始加载 默认为0  
.cacheInMemory(true)  // 设置添加到内存缓存 默认为false  
.cacheOnDisc(true)   // 设置添加到硬盘缓存 默认为false  
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)  // 设置规模类型的解码图像 默认为ImageScaleType.IN_SAMPLE_POWER_OF_2  
.bitmapConfig(Bitmap.Config.ARGB_8888)   // 设置位图图像解码配置  默认为Bitmap.Config.ARGB_8888  
.decodingOptions(new Options())    // 设置选项的图像解码  
.displayer(new FadeInBitmapDisplayer(300))  // 设置自定义显示器  默认为DefaultConfigurationFactory.createBitmapDisplayer()  
.handler(new Handler())    // 设置自定义的handler   默认为new Handler()  
.build();   // 建立 

13、基于LruCache的图片缓存

http://blog.csdn.net/u013064109/article/details/51756551

14、openCV4android

http://blog.csdn.net/hbl_for_android/article/details/51941106  openCV4android常用变换(一)
http://blog.csdn.net/hbl_for_android/article/details/51989105 opencv4android常用变换(二)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在现有省、市港口信息化系统进行有效整合基础上,借鉴新 一代的感知-传输-应用技术体系,实现对码头、船舶、货物、重 大危险源、危险货物装卸过程、航管航运等管理要素的全面感知、 有效传输和按需定制服务,为行政管理人员和相关单位及人员提 供高效的管理辅助,并为公众提供便捷、实时的水运信息服务。 建立信息整合、交换和共享机制,建立健全信息化管理支撑 体系,以及相关标准规范和安全保障体系;按照“绿色循环低碳” 交通的要求,搭建高效、弹性、高可扩展性的基于虚拟技术的信 息基础设施,支撑信息平台低成本运行,实现电子政务建设和服务模式的转变。 实现以感知港口、感知船舶、感知货物为手段,以港航智能 分析、科学决策、高效服务为目的和核心理念,构建“智慧港口”的发展体系。 结合“智慧港口”相关业务工作特点及信息化现状的实际情况,本项目具体建设目标为: 一张图(即GIS 地理信息服务平台) 在建设岸线、港口、港区、码头、泊位等港口主要基础资源图层上,建设GIS 地理信息服务平台,在此基础上依次接入和叠加规划建设、经营、安全、航管等相关业务应用专题数据,并叠 加动态数据,如 AIS/GPS/移动平台数据,逐步建成航运管理处 "一张图"。系统支持扩展框架,方便未来更多应用资源的逐步整合。 现场执法监管系统 基于港口(航管)执法基地建设规划,依托统一的执法区域 管理和数字化监控平台,通过加强对辖区内的监控,结合移动平 台,形成完整的多维路径和信息追踪,真正做到问题能发现、事态能控制、突发问题能解决。 运行监测和辅助决策系统 对区域港口与航运业务日常所需填报及监测的数据经过科 学归纳及分析,采用统一平台,消除重复的填报数据,进行企业 输入和自动录入,并进行系统智能判断,避免填入错误的数据, 输入的数据经过智能组合,自动生成各业务部门所需的数据报 表,包括字段、格式,都可以根据需要进行定制,同时满足扩展 性需要,当有新的业务监测数据表需要产生时,系统将分析新的 需求,将所需字段融合进入日常监测和决策辅助平台的统一平台中,并生成新的所需业务数据监测及决策表。 综合指挥调度系统 建设以港航应急指挥中心为枢纽,以各级管理部门和经营港 口企业为节点,快速调度、信息共享的通信网络,满足应急处置中所需要的信息采集、指挥调度和过程监控等通信保障任务。 设计思路 根据项目的建设目标和“智慧港口”信息化平台的总体框架、 设计思路、建设内容及保障措施,围绕业务协同、信息共享,充 分考虑各航运(港政)管理处内部管理的需求,平台采用“全面 整合、重点补充、突出共享、逐步完善”策略,加强重点区域或 运输通道交通基础设施、运载装备、运行环境的监测监控,完善 运行协调、应急处置通信手段,促进跨区域、跨部门信息共享和业务协同。 以“统筹协调、综合监管”为目标,以提供综合、动态、实 时、准确、实用的安全畅通和应急数据共享为核心,围绕“保畅通、抓安全、促应急"等实际需求来建设智慧港口信息化平台。 系统充分整合和利用航运管理处现有相关信息资源,以地理 信息技术、网络视频技术、互联网技术、移动通信技术、云计算 技术为支撑,结合航运管理处专网与行业数据交换平台,构建航 运管理处与各部门之间智慧、畅通、安全、高效、绿色低碳的智 慧港口信息化平台。 系统充分考虑航运管理处安全法规及安全职责今后的变化 与发展趋势,应用目前主流的、成熟的应用技术,内联外引,优势互补,使系统建设具备良好的开放性、扩展性、可维护性。
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值