OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.resources.statics; | 5 package org.chromium.ui.resources.statics; |
6 | 6 |
7 import android.graphics.Bitmap; | 7 import android.graphics.Bitmap; |
8 import android.graphics.NinePatch; | 8 import android.graphics.NinePatch; |
9 import android.graphics.Rect; | 9 import android.graphics.Rect; |
10 | 10 |
11 import java.nio.BufferUnderflowException; | 11 import java.nio.BufferUnderflowException; |
12 import java.nio.ByteBuffer; | 12 import java.nio.ByteBuffer; |
13 import java.nio.ByteOrder; | 13 import java.nio.ByteOrder; |
14 | 14 |
15 /** | 15 /** |
16 * A helper class to decode and expose relevant 9-patch data from a Bitmap. | 16 * A helper class to decode and expose relevant 9-patch data from a Bitmap. |
17 */ | 17 */ |
18 class NinePatchData { | 18 public class NinePatchData { |
19 private final int mWidth; | 19 private final int mWidth; |
20 private final int mHeight; | 20 private final int mHeight; |
21 private final Rect mPadding; | 21 private final Rect mPadding; |
22 private final int[] mDivX; | 22 private final int[] mDivX; |
23 private final int[] mDivY; | 23 private final int[] mDivY; |
24 | 24 |
25 private Rect mAperture; | 25 private Rect mAperture; |
26 | 26 |
27 /** | 27 /** |
28 * Creates a {@link NinePatchData} that stores 9-patch metadata. | 28 * Creates a {@link NinePatchData} that stores 9-patch metadata. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // uint32_t uint32_t uint32_t ... | 127 // uint32_t uint32_t uint32_t ... |
128 int[] divY = new int[numDivY]; | 128 int[] divY = new int[numDivY]; |
129 for (int i = 0; i < numDivY; i++) divY[i] = buffer.getInt(); | 129 for (int i = 0; i < numDivY; i++) divY[i] = buffer.getInt(); |
130 | 130 |
131 return new NinePatchData(bitmap.getWidth(), bitmap.getHeight(), padd
ing, divX, divY); | 131 return new NinePatchData(bitmap.getWidth(), bitmap.getHeight(), padd
ing, divX, divY); |
132 } catch (BufferUnderflowException ex) { | 132 } catch (BufferUnderflowException ex) { |
133 return null; | 133 return null; |
134 } | 134 } |
135 } | 135 } |
136 } | 136 } |
OLD | NEW |