<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Fotoapparat讓 Android 相機(jī)更友好

          聯(lián)合創(chuàng)作 · 2023-09-29 22:41

          Fotoapparat

          讓 Camera 的 API 更簡單,支持 Camera1 和 Camera2 。

          讓拍照變得更簡單:

          Fotoapparat fotoapparat = Fotoapparat
              .with(context)  
              .into(cameraView)
              .build();
          
          fotoapparat.start();
              
          fotoapparat
              .takePicture()
              .saveToFile(someFile);

          如何運(yùn)行

          第一步:將 CameraView 添加到布局

          <io.fotoapparat.view.CameraView
              android:id="@+id/camera_view"
              android:layout_width="match_parent"
              android:layout_height="match_parent"/>

          第二步:配置 Fotoapparat 實例

          Fotoapparat
              .with(context)  
              .into(cameraView)           // view which will draw the camera preview
              .photoSize(biggestSize())   // we want to have the biggest photo possible
              .lensPosition(back())       // we want back camera
              .focusMode(firstAvailable(  // (optional) use the first focus mode which is supported by device
                      continuousFocus(),
                      autoFocus(),        // in case if continuous focus is not available on device, auto focus will be used
                      fixed()             // if even auto focus is not available - fixed focus mode will be used
              ))
              .flash(firstAvailable(      // (optional) similar to how it is done for focus mode, this time for flash
                      autoRedEye(),
                      autoFlash(),
                      torch()
              ))
              .frameProcessor(myFrameProcessor)   // (optional) receives each frame from preview stream
              .logger(loggers(            // (optional) we want to log camera events in 2 places at once
                      logcat(),           // ... in logcat
                      fileLogger(this)    // ... and to file
              ))
              .build();

          第三步:調(diào)用 start()和 stop()

          @Override
          protected void onStart() {
              super.onStart();
              fotoapparat.start();
          }
          
          @Override
          protected void onStop() {
              super.onStop();
              fotoapparat.stop();
          }

          然后,拍照吧!你有多項選擇:

          PhotoResult photoResult = fotoapparat.takePicture();
           
          // Asynchronously saves photo to file
          photoResult.saveToFile(someFile);
           
          // Asynchronously converts photo to bitmap and returns result on main thread
          photoResult
              .toBitmap()
              .whenAvailable(new PendingResult.Callback<BitmapPhoto>() {
                  @Override
                  public void onResult(BitmapPhoto result) {
                      ImageView imageView = (ImageView) findViewById(R.id.result);
          
                      imageView.setImageBitmap(result.bitmap);
                      imageView.setRotation(-result.rotationDegrees);
                  }
              });
              
          // Of course you can also get a photo in a blocking way. Do not do it on main thread though.
          BitmapPhoto result = photoResult.toBitmap().await();
           
          // Convert asynchronous events to RxJava 1.x/2.x types. See /fotoapparat-adapters/ module
          photoResult
                  .toBitmap()
                  .adapt(SingleAdapter.<BitmapPhoto>toSingle())
                  .subscribe(bitmapPhoto -> {
                      
                  });
          瀏覽 37
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  九九九成人视频 | 久操福利视频 | 精品视频在线播放 | 苍井空无码视频在线观看 | av搬运一区二区三区在线观看 |