Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Side by Side Diff: ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java

Issue 157033007: API to Convert Java Bitmap Config to SkBitmap::Config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding webview dependecy build changes. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 bitmapConfig The Bitmap Configuration value.
83 * @return Matching integer constant for the Bitmap.Config value passed.
84 */
85 @CalledByNative
86 private static int bitmapConfig(Bitmap.Config bitmapConfig) {
87 switch (bitmapConfig) {
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698