Android to achieve the zoom image flip function

package com.easyway.andorid.hello;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout.LayoutParams;

/**
 * Android The zoom feature implemented pictures  
 * @author longgangbai
 * @date 2010-5-24
 * @version 1.0
 * @since JDK6.0
 */
public class ImageViewAndorid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         // The Setup program's title  
         setTitle(" Scale and rotate pictures  ");
         // Instantiate an object of class LinearLayout  lly
         LinearLayout lly=new LinearLayout(this);
         // Gets a picture of the information here is  icon.png , The location of the pictures stored in the res/drawable under  ,
         // At the same time here also has a itfunz.bmp, this is the application's icon  
         Bitmap bmpOrg=BitmapFactory.decodeResource(getResources(), R.drawable.icon);
         // Gets the size of the original picture  
         int width=bmpOrg.getWidth();
         int height=bmpOrg.getHeight();
         
         int newWidth=400;
         int newheight=400;
         // Define the height and width of the scaled to the size of the  
         float sw=((float)newWidth)/width;
         float sh=((float)newheight)/height;
         // Create a picture of the matrix object  
         Matrix matrix=new Matrix();
        
         matrix.postScale(sw,sh);
         // Zoom pictures of action  
         matrix.postRotate(30);
         // Rotation  30*
         Bitmap resizeBitmap=Bitmap.createBitmap(bmpOrg,0,0,width,height,matrix,true);
        
         // Create a new picture   
         BitmapDrawable bmp=new BitmapDrawable(resizeBitmap);
        
         // Create a Bitmap converted to  Drawable Object, so that it can be used in  ImageView And ImageButton in  
         ImageView imageView=new ImageView(this);
         // Create ImageView object  
         imageView.setImageDrawable(bmp);
         // The picture in the Middle  
         imageView.setScaleType(ScaleType.CENTER);
         // The picture fills the entire view  
         lly.addView(imageView, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
         // Add to the layout template ImageView  
         setContentView(lly);
    }
}
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Android to achieve the zoom image flip function

  • JS to control the size of upload files

    JS to control the size of upload files: var fileSize = 160; var fileType = "jpg, gif, bmp, png"; var bool = false; / / 0 on behalf of From the type of wrong, one representative of the type of upload correctly var str = ""; function che

  • Hibernate access picture sample

    General web users to upload picture at treatment would normally uses two types of strategies: First, put directly into the picture in the database Blob field; II database are stored only at the picture on the path of the server information?, Pictures stor

  • autotest, make your test automation RSpec (b) [windows]

    Following Part <<autotest, Let your rspec test automation >> We are the RSpec implementation of automated testing, but always want to open a dos shell look at the recent test results are also too cumbersome. Well, let us to achieve automated t

  • hibernate query cache

    hibernate query cache Query cache is cached result set of common property On the entity object cache only the result set id Query cache life cycle, when the associated table happened to amend, then the query cache of the life cycle of The End Query cache

  • hibernate how to store binary, image and other major fields.

    model categories: reportByte binary type for the database fields. public class PfReportStyle implements java.io.Serializable , Cloneable { // Fields /** * */ private static final long serialVersionUID = 1L; private Long id; private byte[] reportByte; // C

  • Wait for prompt js General category

    This is a very easy-to-use widget, the parameters have default values, default values, see the Notes wait = new WaitingTip(); wait.show(document.getElementById('id')); //Parameter 1 is displayed, in reference to the object ... wait.hide(); //Hide The use

  • hibernate study of the second

    Persistence of three main points: 1, a statement for persistent fields accessors (accessors) and whether the variable signs (mutators) Property statement is not necessarily required for the public's. Hibernate can be default, protected or private ...

  • hibernate (jpa) composite primary key annotation statement Ways

    In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,

  • jboss ejb3 Message Driven Bean

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries