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_
10 #include "base/android/scoped_java_ref.h"
11 #include "ui/gfx/size.h"
17 // This class wraps a JNI AndroidBitmap object to make it easier to use. It
18 // handles locking and unlocking of the underlying pixels, along with wrapping
19 // various JNI methods.
20 class UI_EXPORT JavaBitmap
{
22 explicit JavaBitmap(jobject bitmap
);
25 inline void* pixels() { return pixels_
; }
26 inline const gfx::Size
& size() const { return size_
; }
27 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888
28 inline int format() const { return format_
; }
29 inline uint32_t stride() const { return stride_
; }
31 // Registers methods with JNI and returns true if succeeded.
32 static bool RegisterJavaBitmap(JNIEnv
* env
);
41 DISALLOW_COPY_AND_ASSIGN(JavaBitmap
);
44 UI_EXPORT
base::android::ScopedJavaLocalRef
<jobject
> CreateJavaBitmap(
45 const gfx::Size
& size
);
47 UI_EXPORT
base::android::ScopedJavaLocalRef
<jobject
> ConvertToJavaBitmap(
48 const SkBitmap
* skbitmap
);
50 SkBitmap
CreateSkBitmapFromResource(const char* name
);
54 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_