John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 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> |
John Reck | 00799f7 | 2017-03-01 18:05:41 -0800 | [diff] [blame] | 20 | #include <android/bitmap.h> |
Derek Sollenberger | 8b99419 | 2019-07-16 13:23:29 -0400 | [diff] [blame] | 21 | |
| 22 | class SkBitmap; |
| 23 | struct SkImageInfo; |
John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
sergeyv | c1c5406 | 2016-10-19 18:47:26 -0700 | [diff] [blame] | 27 | class Bitmap; |
John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 28 | |
sergeyv | c69853c | 2016-10-07 14:14:09 -0700 | [diff] [blame] | 29 | namespace bitmap { |
| 30 | |
| 31 | enum BitmapCreateFlags { |
| 32 | kBitmapCreateFlag_None = 0x0, |
| 33 | kBitmapCreateFlag_Mutable = 0x1, |
| 34 | kBitmapCreateFlag_Premultiplied = 0x2, |
| 35 | }; |
| 36 | |
sergeyv | c1c5406 | 2016-10-19 18:47:26 -0700 | [diff] [blame] | 37 | jobject createBitmap(JNIEnv* env, Bitmap* bitmap, |
Derek Sollenberger | 8b99419 | 2019-07-16 13:23:29 -0400 | [diff] [blame] | 38 | int bitmapCreateFlags, jbyteArray ninePatchChunk = nullptr, |
| 39 | jobject ninePatchInsets = nullptr, int density = -1); |
sergeyv | c69853c | 2016-10-07 14:14:09 -0700 | [diff] [blame] | 40 | |
Leon Scroggins III | 71fae62 | 2019-03-26 16:28:41 -0400 | [diff] [blame] | 41 | Bitmap& toBitmap(jlong bitmapHandle); |
sergeyv | c69853c | 2016-10-07 14:14:09 -0700 | [diff] [blame] | 42 | |
| 43 | /** Reinitialize a bitmap. bitmap must already have its SkAlphaType set in |
| 44 | sync with isPremultiplied |
| 45 | */ |
| 46 | void reinitBitmap(JNIEnv* env, jobject javaBitmap, const SkImageInfo& info, |
| 47 | bool isPremultiplied); |
| 48 | |
sergeyv | c69853c | 2016-10-07 14:14:09 -0700 | [diff] [blame] | 49 | } // namespace bitmap |
| 50 | |
John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 51 | } // namespace android |
| 52 | |
| 53 | #endif /* BITMAP_H_ */ |