OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 final int widthRatio = Math.round((float) width / (float) reqWidth); | 68 final int widthRatio = Math.round((float) width / (float) reqWidth); |
69 | 69 |
70 // Choose the smallest ratio as inSampleSize value, this will guaran tee | 70 // Choose the smallest ratio as inSampleSize value, this will guaran tee |
71 // a final image with both dimensions larger than or equal to the | 71 // a final image with both dimensions larger than or equal to the |
72 // requested height and width. | 72 // requested height and width. |
73 inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; | 73 inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; |
74 } | 74 } |
75 | 75 |
76 return inSampleSize; | 76 return inSampleSize; |
77 } | 77 } |
78 | |
79 /** | |
80 * Provides a matching integer constant for the Bitmap.Config value passed. | |
81 * | |
82 * @param Bitmap Configuration value. | |
83 * @return Matching integer constant for the Bitmap.Config value passed. | |
84 */ | |
85 @CalledByNative | |
86 private static int bitmapConfig(Bitmap.Config bitmap_config) { | |
Ted C
2014/02/18 16:45:22
bitmapConfig instead of bitmap_config. Also, need
sivag
2014/02/19 10:05:54
Done.
| |
87 switch (bitmap_config) { | |
88 case ALPHA_8: | |
89 return BitmapFormat.FORMAT_ALPHA_8; | |
90 case ARGB_4444: | |
91 return BitmapFormat.FORMAT_ARGB_4444; | |
92 case ARGB_8888: | |
93 return BitmapFormat.FORMAT_ARGB_8888; | |
94 case RGB_565: | |
95 return BitmapFormat.FORMAT_RGB_565; | |
96 default: | |
97 return BitmapFormat.FORMAT_NO_CONFIG; | |
98 } | |
99 } | |
78 } | 100 } |
OLD | NEW |