• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            xiaoguozi's Blog
            Pay it forword - 我并不覺的自豪,我所嘗試的事情都失敗了······習慣原本生活的人不容易改變,就算現狀很糟,他們也很難改變,在過程中,他們還是放棄了······他們一放棄,大家就都是輸家······讓愛傳出去,很困難,也無法預料,人們需要更細心的觀察別人,要隨時注意才能保護別人,因為他們未必知道自己要什么·····

            001package cn.m15.test;
            002 
            003import java.io.ByteArrayOutputStream;
            004import java.io.File;
            005import android.app.Activity;
            006import android.content.Intent;
            007import android.graphics.Bitmap;
            008import android.net.Uri;
            009import android.os.Bundle;
            010import android.os.Environment;
            011import android.provider.MediaStore;
            012import android.view.View;
            013import android.view.View.OnClickListener;
            014import android.widget.Button;
            015import android.widget.ImageView;
            016 
            017public class testActivity extends Activity {
            018 
            019    public static final int NONE = 0;
            020    public static final int PHOTOHRAPH = 1;// 拍照
            021    public static final int PHOTOZOOM = 2; // 縮放
            022    public static final int PHOTORESOULT = 3;// 結果
            023 
            024    public static final String IMAGE_UNSPECIFIED = "image/*";
            025    ImageView imageView = null;
            026    Button button0 = null;
            027    Button button1 = null;
            028 
            029    @Override
            030    public void onCreate(Bundle savedInstanceState) {
            031        super.onCreate(savedInstanceState);
            032        setContentView(R.layout.main);
            033        imageView = (ImageView) findViewById(R.id.imageID);
            034        button0 = (Button) findViewById(R.id.btn_01);
            035        button1 = (Button) findViewById(R.id.btn_02);
            036 
            037        button0.setOnClickListener(new OnClickListener() {
            038            @Override
            039            public void onClick(View v) {
            040                Intent intent = new Intent(Intent.ACTION_PICK, null);
            041                intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_UNSPECIFIED);
            042                startActivityForResult(intent, PHOTOZOOM);
            043            }
            044        });
            045 
            046        button1.setOnClickListener(new OnClickListener() {
            047 
            048            @Override
            049            public void onClick(View v) {
            050                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            051                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "temp.jpg")));
            052                startActivityForResult(intent, PHOTOHRAPH);
            053            }
            054        });
            055    }
            056 
            057    @Override
            058    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            059        if (resultCode == NONE)
            060            return;
            061        // 拍照
            062        if (requestCode == PHOTOHRAPH) {
            063            //設置文件保存路徑這里放在跟目錄下
            064            File picture = new File(Environment.getExternalStorageDirectory() + "/temp.jpg");
            065            startPhotoZoom(Uri.fromFile(picture));
            066        }
            067         
            068        if (data == null)
            069            return;
            070         
            071        // 讀取相冊縮放圖片
            072        if (requestCode == PHOTOZOOM) {
            073            startPhotoZoom(data.getData());
            074        }
            075        // 處理結果
            076        if (requestCode == PHOTORESOULT) {
            077            Bundle extras = data.getExtras();
            078            if (extras != null) {
            079                Bitmap photo = extras.getParcelable("data");
            080                ByteArrayOutputStream stream = new ByteArrayOutputStream();
            081                photo.compress(Bitmap.CompressFormat.JPEG, 75, stream);// (0 - 100)壓縮文件
            082                imageView.setImageBitmap(photo);
            083            }
            084 
            085        }
            086 
            087        super.onActivityResult(requestCode, resultCode, data);
            088    }
            089 
            090    public void startPhotoZoom(Uri uri) {
            091        Intent intent = new Intent("com.android.camera.action.CROP");
            092        intent.setDataAndType(uri, IMAGE_UNSPECIFIED);
            093        intent.putExtra("crop", "true");
            094        // aspectX aspectY 是寬高的比例
            095        intent.putExtra("aspectX", 1);
            096        intent.putExtra("aspectY", 1);
            097        // outputX outputY 是裁剪圖片寬高
            098        intent.putExtra("outputX", 64);
            099        intent.putExtra("outputY", 64);
            100        intent.putExtra("return-data", true);
            101        startActivityForResult(intent, PHOTORESOULT);
            102    }
            103}

            01<?xml version="1.0" encoding="utf-8"?>
            02<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            03    android:orientation="vertical" android:layout_width="fill_parent"
            04    android:layout_height="fill_parent">
            05    <TextView android:layout_width="fill_parent"
            06        android:layout_height="wrap_content" android:text="@string/hello" />
            07    <ImageView android:id="@+id/imageID"
            08        android:adjustViewBounds="true" android:maxWidth="50dip"
            09        android:maxHeight="50dip" android:layout_width="wrap_content"
            10        android:layout_height="wrap_content" />
            11    <Button android:id="@+id/btn_01" android:layout_height="50dip"
            12            android:text="相冊" android:layout_width="150dip"/>
            13    <Button android:id="@+id/btn_02" android:layout_height="50dip"
            14            android:text="拍照" android:layout_width="150dip"/>
            15</LinearLayout>


            posted on 2012-03-15 12:12 小果子 閱讀(487) 評論(0)  編輯 收藏 引用
            国产高清美女一级a毛片久久w| 久久国产免费直播| 久久精品中文字幕久久| 97精品国产97久久久久久免费 | 久久精品国产一区二区三区| 久久久久97国产精华液好用吗| 久久这里的只有是精品23| 亚洲精品无码成人片久久| 国产综合免费精品久久久| 99久久精品免费看国产一区二区三区 | 久久成人精品视频| 亚洲国产精品综合久久一线 | 青草国产精品久久久久久| 国产叼嘿久久精品久久| 亚洲精品高清国产一线久久| 久久91精品综合国产首页| 久久久久久毛片免费播放| 综合久久一区二区三区 | 久久这里只有精品18| 精品视频久久久久| 久久91综合国产91久久精品| 久久亚洲AV无码精品色午夜麻豆| 青青国产成人久久91网| 久久人人爽人人爽人人AV| 色综合合久久天天给综看| 日本免费一区二区久久人人澡 | 久久婷婷色综合一区二区| 久久精品国产亚洲一区二区三区| 97久久精品人妻人人搡人人玩| 午夜精品久久久久久中宇| 狠狠色丁香婷婷久久综合| 亚洲国产精品无码久久九九| 久久国产AVJUST麻豆| 97热久久免费频精品99| 丰满少妇高潮惨叫久久久| 久久国产劲爆AV内射—百度| 超级碰久久免费公开视频| 久久国产色AV免费看| 久久99国产综合精品女同| 久久丫精品国产亚洲av不卡 | 亚洲国产成人精品女人久久久|