Android Open Source - wpaper Bitmap Operation






From Project

Back to project page wpaper.

License

The source code is released under:

MIT License

If you think the Android project wpaper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.uniwall;
/*from w  w  w  . j  a v  a2  s  .  com*/
import java.io.InputStream;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

//?M?w????bitmap?B???X?~???AbimapOperation.java
//?p??j?p?B???????
//MainActivity.java?h?O?n?????X??????A?]?w?I????C
//???T?wbimapOperation.java???B??|???|??????s????????A?y???t?@??out of memory

public class BitmapOperation{
  //Declare variable
  private static int picWidth;
  private static int picHeight;
  //Method for reading file
  public static  Bitmap  readBitMap(Context context, int resId){
    BitmapFactory.Options opt = new BitmapFactory.Options();
        opt.inPreferredConfig = Bitmap.Config.RGB_565;
        opt.inPurgeable = true;
        opt.inInputShareable = true;
        // ????????
        InputStream is = context.getResources().openRawResource(resId);
        return BitmapFactory.decodeStream(is, null, opt);
  }
  
  //Scale the bitmap
  public BitmapFactory.Options getBitmapOptions(int scale){
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inPurgeable = true;
      options.inInputShareable = true;
      options.inSampleSize = scale;
      return options;
  }
  
  //Method for show the information of bitmap without loading picture. 
  public static void informBitmap(String pathName){
    BitmapFactory.Options opts = new BitmapFactory.Options();    
      // ?]?minJustDecodeBounds??true    
      opts.inJustDecodeBounds = true;    
      // ???decodeFile??k?o???????e?M?? 
      BitmapFactory.decodeFile(pathName, opts);    
      // ?C?L?X??????e?M??
      Log.d("example", opts.outWidth + "," + opts.outHeight);
      
    picWidth  = opts.outWidth;  
    picHeight = opts.outHeight; 
  }
  
  //Get method & set method
//  public int getWidth(){
//    return opts.outWidth;
//  }
//  public int getHeight(){
//    return opts.outHeight;
//  }
}




Java Source Code List

com.example.uniwall.BitmapOperation.java
com.example.uniwall.CoViewPagerAdapter.java
com.example.uniwall.Controller.java
com.example.uniwall.MainActivity.java
com.example.uniwall.MainApplication.java
net.DownloadImageTask.java
net.DownloadMethod.java