鄭州app開發(fā)android加載大圖實(shí)例
為富順等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及富順網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、富順網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
MainActivity.java
package cn.xhhkj.image;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.bitmap;
import android.graphics.bitmapFactory;
import android.graphics.point;
import android.os.bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "結(jié)果是";
private static final int UpDATE_pROGRESS = 0;
public String path = src="/upload/article1/1.jpg";
private ImageView iv_image;
private int screenWidth;
private int screenHeight;
bitmap bitmap;
@Override
protected void onCreate(bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}
public void init(){
iv_image = findViewbyId(R.id.iv_pic);
screenWidth = getWindowManager().getDefaultDisplay().getWidth();
screenHeight = getWindowManager().getDefaultDisplay().getHeight();
point outSize = new point();
getWindowManager().getDefaultDisplay().getSize(outSize);
Log.d(TAG,"寬度"+outSize.x+"高度"+outSize.y);
}
public void loadpic(View view) {
bitmap bitmap = bitmapFactory.decodeFile(path);
iv_image.setImagebitmap(bitmap);
//loadpic2();
}
public void loadpic2(){
bitmapFactory.Options option =new bitmapFactory.Options();
option.inJustDecodebounds = true;
int width = option.outWidth;
int height = option.outHeight;
if(width>screenWidth||height>screenHeight){
int widthIndex = Math.round((float)width/(float)screenWidth);
int heightIndex = Math.round((float)height/(float)screenHeight);
option.inSampleSize = Math.max(widthIndex, heightIndex);
}
option.inJustDecodebounds = false;
bitmap = bitmapFactory.decodeFile(path, option);
iv_image.setImagebitmap(bitmap);
}
public void loadpic3(){
bitmapFactory.Options option =new bitmapFactory.Options();
option.inSampleSize = 1;
bitmap bitmap = null;
int i = 1;
for(;;){
try {
option.inSampleSize = i;
bitmap = bitmapFactory.decodeFile(path, option);
break;
} catch (Error e) {
i*=2;
System.out.println("i = "+i);
}
}
iv_image.setImagebitmap(bitmap);
}
}
新聞標(biāo)題:android加載大圖實(shí)例
轉(zhuǎn)載注明:http://jinyejixie.com/article12/scssdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、網(wǎng)頁設(shè)計(jì)公司、動態(tài)網(wǎng)站、服務(wù)器托管、移動網(wǎng)站建設(shè)、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)