<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                不久前,我們有一個問題是如何用 Glide 旋轉圖像,因為 Picasso 提供了這個方法 [out-of-the-box](https://futurestud.io/blog/picasso-image-rotation-and-transformation)。不幸的是,Glide 并不提供這樣的小方法的調用,但是在這個博客中我們將會告訴你怎么做的跟它一樣簡單。 如果你需要關于 Glide 的更多內容,瀏覽我們這些博客列表: **如何用 Glide 旋轉圖片**? 事實上,[android.graphics.Matrix](https://developer.android.com/reference/android/graphics/Matrix.html?hl=zh-cn) 類提供了我們所需要的準確辦法(甚至更多辦法)。這個代碼片段就是用來旋轉圖像的: ~~~ Bitmap toTransform = ... // your bitmap source Matrix matrix = new Matrix(); matrix.postRotate(rotateRotationAngle); Bitmap.createBitmap(toTransform, 0, 0, toTransform.getWidth(), toTransform.getHeight(), matrix, true); ~~~ 為了使它對我們有用,尤其是用在 Glide 中,我們會包裹它作為一個 `BitmapTransformation`: ~~~ public class RotateTransformation extends BitmapTransformation { private float rotateRotationAngle = 0f; public RotateTransformation(Context context, float rotateRotationAngle) { super( context ); this.rotateRotationAngle = rotateRotationAngle; } @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { Matrix matrix = new Matrix(); matrix.postRotate(rotateRotationAngle); return Bitmap.createBitmap(toTransform, 0, 0, toTransform.getWidth(), toTransform.getHeight(), matrix, true); } @Override public String getId() { return "rotate" + rotateRotationAngle; } } ~~~ 如果你不知道上面這個類發生了,去看看我們介紹的 [Custom Transformations](https://futurestud.io/blog/glide-custom-transformation),它將告訴你所有你要知道的。 最后,讓我們看看新的轉換的實例: ~~~ private void loadImageOriginal() { Glide .with( context ) .load( eatFoodyImages[0] ) .into( imageView1 ); } private void loadImageRotated() { Glide .with( context ) .load( eatFoodyImages[0] ) .transform( new RotateTransformation( context, 90f )) .into( imageView3 ); } ~~~ ![](http://i.imgur.com/WjrWD77.png) 當然,你可以改變第二個參數來設置你需要的旋轉的角度。你甚至可以動態設置它! 這應該提供了所有的代碼和知識你需要在 Glide 中旋轉的圖片,即使它沒有直接在庫中提供。如果這對你來說有用的,在評論中讓我們知道唄!
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看