1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef BITMAP_H_
17 #define BITMAP_H_
18 
19 #include <jni.h>
20 #include <android/bitmap.h>
21 
22 struct SkImageInfo;
23 
24 namespace android {
25 
26 class Bitmap;
27 
28 namespace bitmap {
29 
30 enum BitmapCreateFlags {
31     kBitmapCreateFlag_None = 0x0,
32     kBitmapCreateFlag_Mutable = 0x1,
33     kBitmapCreateFlag_Premultiplied = 0x2,
34 };
35 
36 jobject createBitmap(JNIEnv* env, Bitmap* bitmap,
37             int bitmapCreateFlags, jbyteArray ninePatchChunk = nullptr,
38             jobject ninePatchInsets = nullptr, int density = -1);
39 
40 Bitmap& toBitmap(jlong bitmapHandle);
41 
42 /** Reinitialize a bitmap. bitmap must already have its SkAlphaType set in
43     sync with isPremultiplied
44 */
45 void reinitBitmap(JNIEnv* env, jobject javaBitmap, const SkImageInfo& info,
46         bool isPremultiplied);
47 
48 } // namespace bitmap
49 
50 } // namespace android
51 
52 #endif /* BITMAP_H_ */
53