導航:首頁 > 操作系統 > android圖像

android圖像

發布時間:2022-04-19 20:03:51

android 圖像處理 用什麼庫

沒有,只有GPU

② Android如何進行圖片編輯

裁剪選取或拍攝的圖片
public static void cropphoto(Fragment fragment, Uri uri){ //設置裁剪圖片保存位置 File bomb=new File(fragment.getContext().getExternalCacheDir(),"bmob"); Log.d("tag", "cropphoto: "+bomb); if (!bomb.exists()){ bomb.mkdir(); } File file=new File(bomb,"user_icon.jpg"); if (!file.exists()){ try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } Intent intent=new Intent("com.android.camera.action.CROP");//intent隱式調用啟動拍照界面 intent.setDataAndType(uri,"image/*");//設置需要裁剪的圖片地址 intent.putExtra("crop", "true");//通過put(key,value)方法設置相關屬相 intent.putExtra("aspectX", 1);//設置圖片寬高比例 intent.putExtra("aspectY", 1); intent.putExtra("outputX", 240);//設置圖片寬高 intent.putExtra("outputY", 240); intent.putExtra("return-data", false);//該屬性設置為false表示拍照後不會將數據返回到onResluet方法中(建議設置為false,這樣獲取的圖片會比較清晰) intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));//該屬性設置的是拍照後圖片保存的位置 intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//設置輸出格式 intent.putExtra("noFaceDetection", true);//是否取消人臉識別 /*ComponentName componentName = intent.resolveActivity(context.getPackageManager()); Log.d("TAG", "cropphoto: "+componentName); if (componentName!=null){ fragment.startActivityForResult(intent,Variable.request_crop); }*/ fragment.startActivityForResult(intent,Variable.request_crop); }

③ android設置圖片

1、創建imageview對象

2、設置imageview的圖片
3、添加到布局中
示例代碼
ViewGroup group = (ViewGroup) findViewById(R.id.viewGroup); //獲取原來的布局容器
ImageView imageView = new ImageView(this); //創建imageview
imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); //image的布局方式
imageView.setImageResource(R.drawable.ic_launcher); //設置imageview呈現的圖片
group.addView(imageView); //添加到布局容器中,顯示圖片。

④ Android 保存圖片到本地。

這里只介紹按下「保存」後如何將一個Bitmap對象保存為圖片文件的執行步驟,對圖片的下載,圖片到Bitmap對象的轉換,Bitmap對象的格式轉換和壓縮,以及界面設計部分全部都忽略了。

⑤ android中 怎麼顯示一直圖片為圓形圖片

android中的imageview只能顯示矩形的圖片,這樣一來不能滿足我們其他的需求,比如要顯示圓形的圖片,這個時候,我們就需要自定義imageview了,其原理就是首先獲取到圖片的bitmap,然後進行裁剪圓形的bitmap,然後在ondraw()進行繪制圓形圖片輸出。

⑥ 求助,關於android圖像識別。

你有圖像識別庫嗎?如果有的話,App具體操作其實很簡單,啟動Camera采圖嗲用庫識別。
但是如果你沒有圖像識別庫的話,你要自己去實現,一般庫都是C++寫的,我們公司用圖像識別技術都是有專門的人寫一個對應的圖像識別庫,而且對應掃描不同的東西都要單寫一個庫,然後打包給我們App調用,當然具體怎麼寫一個識別庫,肯定也不是那麼簡單,必須要對C++如何實現圖像識別技術要有一定基礎的。

你要是有時間和精力想自己弄的話,推薦一個國外網站http://opencv.org/platforms/android.html,希望對你有幫助,都是這么苦逼過來的。

⑦ android怎麼實現 圖像隨著手指的移動而移動

總得一句話要重寫onTouchEvent 1.手勢滾動有很多方法: 可用viewpager實現view的左右滑屏,也可以用ViewFlipper,還有笨方法就是一個imageview,獲取按下抬起坐標,判斷左滑右滑,然後set另一張圖片進去。 2.縮放也有很多做法 正統的做法是把imageview的屬性scaleType設置為matrix(矩陣),然後獲取滑動手勢,來操作矩陣獲得縮放的效果

⑧ android如何實現圖片預覽

main.xml

先定義一個GridView,然後再定義一個ImageSwitcher

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="horizontal">

<GridView

android:id="@+id/gridView1"

android:layout_height="fill_parent"

android:layout_width="300px"

android:layout_marginTop="6px"

android:horizontalSpacing="3px"

android:verticalSpacing="3px"

android:numColumns="4"/>

<ImageSwitcher

android:id="@+id/imageSwicher1"

android:padding="20px"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

></ImageSwitcher>

</LinearLayout>

MainActivity代碼如下

{

privateint[]imageId=newint[]{R.drawable.w1,R.drawable.w2,

R.drawable.w3,R.drawable.w4,R.drawable.w5,R.drawable.w6};

;

@Override

protectedvoidonCreate(BundlesavedInstanceState){

//TODOAuto-generatedmethodstub

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

imageSwitcher=(ImageSwitcher)findViewById(R.id.imageSwicher1);

imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,

android.R.anim.fade_in));//設置淡入動畫

imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,

android.R.anim.fade_out));//設置談出動畫

imageSwitcher.setFactory(newViewFactory(){

@Override

publicViewmakeView(){

//TODOAuto-generatedmethodstub

ImageViewimageView=newImageView(MainActivity.this);//實例化一個ImageView類的對象

imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);//設置保持縱橫比居中縮放圖像

imageView.setLayoutParams(newImageSwitcher.LayoutParams(//主要要是用ImageSwitcher的LayoutParams

LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));

returnimageView;

}

});

imageSwitcher.setImageResource(imageId[0]);

GridViewgridView=(GridView)findViewById(R.id.gridView1);

BaseAdapteradapter=newBaseAdapter(){

/*

*獲得數量

*

*@seeandroid.widget.Adapter#getCount()

*/

@Override

publicintgetCount(){

//TODOAuto-generatedmethodstub

returnimageId.length;

}

@Override

publicObjectgetItem(intposition){

//TODOAuto-generatedmethodstub

returnposition;

}

/**

*獲得當前選項

*/

@Override

publiclonggetItemId(intposition){

//TODOAuto-generatedmethodstub

returnposition;

}

@Override

publicViewgetView(intposition,ViewconvertView,ViewGroupparent){

//TODOAuto-generatedmethodstub

ImageViewimageView;

if(convertView==null){

imageView=newImageView(MainActivity.this);

/**設置圖像的寬度和高度**/

imageView.setAdjustViewBounds(true);

imageView.setMaxWidth(150);

imageView.setMaxHeight(113);

imageView.setPadding(5,5,5,5);

}else{

imageView=(ImageView)convertView;

}

imageView.setImageResource(imageId[position]);

returnimageView;

}

};

gridView.setAdapter(adapter);

gridView.setOnItemClickListener(newOnItemClickListener(){

@Override

publicvoidonItemClick(AdapterView<?>arg0,Viewarg1,intarg2,

longarg3){

//TODOAuto-generatedmethodstub

imageSwitcher.setImageResource(imageId[arg2]);//顯示選中的圖片

}

});

}

}

⑨ Android繪制圖片的幾種方式

在android中做圖像鏡像有很多方法,今天算是學習了!
兩種方法如下:

復制代碼 代碼如下:

//方法一
Matrix matrix = new Matrix();
matrix.postScale(leftOrRight, 1, bmpW/2, bmpH/2);//前兩個是xy變換,後兩個是對稱軸中心點
matrix.postTranslate(x, y);
canvas.drawBitmap(bmpLuffy[0], matrix, paint);
//方法二
// canvas.save();
// canvas.scale(-1, 1, x + bmpLuffy[0].getWidth() / 2, y + bmpLuffy[0].getHeight() / 2);
// canvas.drawBitmap(bmpLuffy[0], x, y, paint);
// canvas.restore();

方法一,使用矩陣的方式(3x3)矩陣:
1、先使用postScale的方式將圖片以點(bmpW/2,bmpH/2)為中心,以x=bmpW/2為對稱軸翻轉;
2、使用postTranslate,將圖片移到(x,y)坐標
方法二,畫布翻轉(略)
注意如下問題:
對於其中的bmpW和bmpH是指所用圖片的寬高,需要使用圖片bmp.getWidth()和bmp.getHeight()獲取,
不能使用PC上看到的大小,否則可能會出現錯位!

閱讀全文

與android圖像相關的資料

熱點內容
windows下編譯python 瀏覽:607
linux藍牙連接 瀏覽:898
安卓qq郵箱格式怎麼寫 瀏覽:431
如何電信租用伺服器嗎 瀏覽:188
編程中計算根號的思維 瀏覽:183
可愛的程序員16集背景音樂 瀏覽:446
軟體代碼內容轉換加密 瀏覽:797
什麼app看電視不要錢的 瀏覽:16
烏班圖怎麼安裝c語言編譯器 瀏覽:278
plc通訊塊編程 瀏覽:923
我的世界伺服器怎麼清地皮 瀏覽:421
ftp伺服器如何批量改名 瀏覽:314
網易我的世界伺服器成員如何傳送 瀏覽:268
公司雲伺服器遠程訪問 瀏覽:633
法哲學pdf 瀏覽:638
清大閱讀app是什麼 瀏覽:447
怎麼用qq瀏覽器整體解壓文件 瀏覽:587
肺組織壓縮15 瀏覽:271
安卓手機為什麼換電話卡沒反應 瀏覽:797
諸子集成pdf 瀏覽:340