| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.ui.gfx; | 5 package org.chromium.ui.gfx; |
| 6 | 6 |
| 7 import android.content.res.Resources; | 7 import android.content.res.Resources; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 import android.graphics.BitmapFactory; | 9 import android.graphics.BitmapFactory; |
| 10 import org.chromium.base.CalledByNative; | 10 import org.chromium.base.CalledByNative; |
| 11 import org.chromium.base.JNINamespace; | 11 import org.chromium.base.JNINamespace; |
| 12 | 12 |
| 13 @JNINamespace("ui") | 13 @JNINamespace("gfx") |
| 14 public class BitmapHelper { | 14 public class BitmapHelper { |
| 15 @CalledByNative | 15 @CalledByNative |
| 16 public static Bitmap createBitmap(int width, int height) { | 16 public static Bitmap createBitmap(int width, int height) { |
| 17 return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); | 17 return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
| 18 } | 18 } |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Decode and sample down a bitmap resource to the requested width and heigh
t. | 21 * Decode and sample down a bitmap resource to the requested width and heigh
t. |
| 22 * | 22 * |
| 23 * @param name The resource name of the bitmap to decode. | 23 * @param name The resource name of the bitmap to decode. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // Choose the smallest ratio as inSampleSize value, this will guaran
tee | 61 // Choose the smallest ratio as inSampleSize value, this will guaran
tee |
| 62 // a final image with both dimensions larger than or equal to the | 62 // a final image with both dimensions larger than or equal to the |
| 63 // requested height and width. | 63 // requested height and width. |
| 64 inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; | 64 inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; |
| 65 } | 65 } |
| 66 | 66 |
| 67 return inSampleSize; | 67 return inSampleSize; |
| 68 } | 68 } |
| 69 } | 69 } |
| OLD | NEW |