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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_ANDROID_JAVA_BITMAP_H_
6 #define UI_GFX_ANDROID_JAVA_BITMAP_H_
8 #include "base/android/scoped_java_ref.h"
9 #include "ui/gfx/size.h"
15 // This class wraps a JNI AndroidBitmap object to make it easier to use. It
16 // handles locking and unlocking of the underlying pixels, along with wrapping
17 // various JNI methods.
18 class UI_EXPORT JavaBitmap
{
20 explicit JavaBitmap(jobject bitmap
);
23 inline void* pixels() { return pixels_
; }
24 inline const gfx::Size
& size() const { return size_
; }
25 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888
26 inline int format() const { return format_
; }
27 inline uint32_t stride() const { return stride_
; }
36 DISALLOW_COPY_AND_ASSIGN(JavaBitmap
);
39 UI_EXPORT
base::android::ScopedJavaLocalRef
<jobject
> CreateJavaBitmap(
40 const gfx::Size
& size
);
42 UI_EXPORT
base::android::ScopedJavaLocalRef
<jobject
> ConvertToJavaBitmap(
43 const SkBitmap
* skbitmap
);
45 SkBitmap
CreateSkBitmapFromResource(const char* name
);
49 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_