日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用内置的Gallery应用程序选择图形

發布時間:2024/4/17 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用内置的Gallery应用程序选择图形 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用一個預裝的Intent.Action_Pick通知Android選擇一塊數據。android.provider.MediaStore.Images.EXTERNAL_CONETENT_URI.

Intent choosePictureIntent=new Intent(Intent.ACTION_PICK,android.provider.Mediastore.Images.Media.EXTERNAL_CONTENT_URI);

觸發onActivityResult(int requestCode,int resultCode,Intent intent){

? ?super.onActivityResult(requestCode,resultCode,intent);

? if(resultCode==RESULT_OK){

? ? Uri imageFileUri=intent.getData();

? ?

? ?}

}

3.2 在位圖上繪制位圖

? Bitmap bmp=BitmapFactory.decodeStream(getContentResolver().openInputStream(imageFileUri),null,bmpFactoryOptions);

? Bitmap alteredBitmap=Bitmap.createBitmap(bmp.getWidth(),bmp.getheight(),bmp.getConfig());

? 繪制:

? 1.獲得畫布和Paint對象

? ? ? Canvas canvas=new Canvas(alteredBitmap);

? ? ? Paint paint=new Paint();

? 2.繪制

? ? ? canvas.drawBitmap(bmp,0,0,paint);

3.3.1 輸入矩陣

? ? ? ? Matrix matrix=new Matrix();

? ? ? ? matrix.setValues(new float[]{

? ? ? ? ?1,0,0,

? ? ? ? ?0,1,0,

? ? ? ? ?0,0,1});

? ? ? ?canvas.drawBitmap(bmp,matrix,paint);

3.3.2 Matix類的方法

? ? Mtrix matrix=new Matrix();

? ?matrix.setRotate(15);

? ?canvas.drawBitmap(bmp,matrix,paint);

2.縮放

? ?Matix有用的方法是setscale方法,第一個參數是x軸的縮放比例,第二個參數是y軸的縮放比例

matrix.setScale(1.5f,1);

3.平移

? ?Matrix類中setTranslate方法,平移setTranslate(1.5f,-10);

5.鏡像

matrix.setScale(-1,1);

matrix.postTranslate(bmp.getWidth(),0);


繪圖設置字體

Typeface serif_italic=Typeface.create(Typeface.SERIF,Typeface.ITALIC);

paint.setTypeface(serif_italic);

Typeface chops=Typeface.createFromAsset(getAssets(),"chopinScript.ttf");

paint.setTypeface(chops);

4.路徑上的文本

Paint paint=new Paint();

paint.setColor(Color.Green);

paint.setTextSize(20);

paint.setTypeface(Typeface.DEFAULT);

canvas.drawTextOnPath("Hello this is text on a path",p,0,0,paint);

4.2 手指繪圖

4.2.1 觸摸事件

SimpleFingerDraw extends Activity implements OnTouchListener{

? ?boolean onTouch(View v,MotionEvent event){

? ? ? ? ? int action=event.getAction();

? ? ? ? ? switch(action){

? ? ? ? ? ? ? ? ?case MotionEvent.Action_down:

? ? ? ? ? ? ? ? ? ? ? ? ? downx=evnent.getX();

? ? ? ? ? ? ? ? ? ? ? ? ? downy=event.getY();

? ? ? ? ?}

}

}

總結

以上是生活随笔為你收集整理的使用内置的Gallery应用程序选择图形的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。