Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Android judgment toward camera pictures     - Apache POI Excel Document Processing (Linux)

- How to configure a server in a MySQL Cluster (Database)

- History and Statistics tuptime use tools to view Linux server system boot time (Server)

- RedHat Performance Tuning (Server)

- To convert into a binary search tree sorted doubly linked list (Programming)

- About Leetcode on Binary Tree Algorithm summary (Programming)

- Ubuntu UFW firewall settings Introduction (Linux)

- Android Service service applications and the phone SMS Listener Listener (Programming)

- MySQL loose index scan (Database)

- MySQL optimization tabs (Database)

- MongoDB fragmentation (Cluster) (Database)

- Python common data type summary (Programming)

- Spring declarative transaction management (Programming)

- IPTABLES configuration steps under Linux (Linux)

- How do I cancel (almost) any operations in Git, (Linux)

- Formatted output printf command (Programming)

- Daemon under Linux (Linux)

- Linux ps command (Linux)

- Teach you to diagnose problems with strace (Linux)

- RedHat Linux 6.4 install Oracle 10g error (Database)

 
         
  Android judgment toward camera pictures
     
  Add Date : 2017-08-31      
         
         
         
  Android applications in a question that must be considered when using the camera image is the image orientation toward the only judge to adjust the picture in order to better show. This article describes a picture toward judging by ExifInterface way!

Code is as follows:

 / **
  *
  * Use the given path to the picture settings ImageView
  *
  * @param ImgPath phone image file path
  * ImageView @param imgView need to set
  * /
 public void setImg (String imgPath, ImageView imgView) {
  File file = new File (imgPath);
  if (file.exists () && file.canRead ()) {
   // -------1 Image zoom --------

   // Phone screen information
   DisplayMetrics metric = new DisplayMetrics ();
   getWindowManager () getDefaultDisplay () getMetrics (metric)..;
   int dw = metric.widthPixels; // Wide Screen
   int dh = metric.heightPixels; // high screen

   // Load the image, just to get the size
   BitmapFactory.Options options = new BitmapFactory.Options ();
   options.inJustDecodeBounds = true; // Set the following size information can be obtained
   Bitmap bitmap = BitmapFactory.decodeFile (imgPath, options);
   // Calculate the horizontal and vertical scaling factor
   int heightRatio = (int) Math.ceil (options.outHeight / (float) dh);
   int widthRatio = (int) Math.ceil (options.outWidth / (float) dw);
   // Determine which big
   if (heightRatio> 1 && widthRatio> 1) {
    if (heightRatio> widthRatio) {
     options.inSampleSize = heightRatio;
    } Else {
     options.inSampleSize = widthRatio;
    }
   }
   // Image scaling
   options.inJustDecodeBounds = false;
   bitmap = BitmapFactory.decodeFile (imgPath, options);

   // -------2. Analyzing image toward --------
   try {
    ExifInterface exif = new ExifInterface (imgPath);
    int degree = 0; // Image rotation angle
    if (exif! = null) {
     int orientation = exif.getAttributeInt (
       ExifInterface.TAG_ORIENTATION, -1);
     if (orientation! = -1) {
      switch (orientation) {
      case ExifInterface.ORIENTATION_ROTATE_90:
       degree = 90;
       break;

      case ExifInterface.ORIENTATION_ROTATE_180:
       degree = 180;
       break;

      case ExifInterface.ORIENTATION_ROTATE_270:
       degree = 270;
       break;
      default:
       break;
      }
     }
    }

    if (degree! = 0) {// need to rotate the image
     int width = bitmap.getWidth ();
     int height = bitmap.getHeight ();
     Matrix matrix = new Matrix ();
     matrix.preRotate (degree);
     Bitmap mRotateBitmap = Bitmap.createBitmap (bitmap, 0, 0,
       width, height, matrix, true);

     imgView.setImageBitmap (mRotateBitmap);
    } Else {
     imgView.setImageBitmap (bitmap);
    }
   } Catch (IOException e) {
   }
  }
 }
     
         
         
         
  More:      
 
- Difference Redhat5 and 6 YUM source configuration (Linux)
- Linux systems dmesg command processing failures and system information collected seven usage (Linux)
- New experience Budgie (Budgerigar) desktop environment (Linux)
- Hadoop 0.23 compile common errors (Server)
- Linux operating system set up to effectively prevent ARP attacks (Linux)
- CentOS 6 / Linux su: Unable to set user ID: Resource temporarily unavailable (Linux)
- To create a problem by the statement date comparison of the difference between MySQL and Oracle (Database)
- Install mono offline on CentOS (Server)
- CentOS 6/7 Series Docker Installation (Linux)
- Debian 8 (amd64) installation deployment Memcached management tools MemAdmin (Server)
- Let OpenCV face detection score output codes (Programming)
- How to implement Linux host Telnet SSH password Free (Server)
- Swift notes - let you two hours to learn Swift (Programming)
- Between the two to achieve the main MySQL database synchronization from (Database)
- How to modify the SQL Server auto-increment value and the corresponding solution (Database)
- Nginx version of helloworld (Server)
- When RHEL7 use fdisk partition, all partitions can not be used (Linux)
- Usage sed some of the parameters (Linux)
- Oracle archive log size than the size of the online journal of the much smaller (Database)
- Examples of safety testing system notes for RedHat Linux (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.