Revert "Roll NDK to r11c and extract it into its own repository."
[android_tools.git] / ndk / platforms / android-18 / arch-arm / usr / include / android / bitmap.h
blob6e18763bf57663b9e15a48d5ef40a34334e3c307
1 /*
2 * Copyright (C) 2009 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_BITMAP_H
18 #define ANDROID_BITMAP_H
20 #include <stdint.h>
21 #include <jni.h>
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
27 #define ANDROID_BITMAP_RESULT_SUCCESS 0
28 #define ANDROID_BITMAP_RESULT_BAD_PARAMETER -1
29 #define ANDROID_BITMAP_RESULT_JNI_EXCEPTION -2
30 #define ANDROID_BITMAP_RESULT_ALLOCATION_FAILED -3
32 /* Backward compatibility: this macro used to be misspelled. */
33 #define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS
35 enum AndroidBitmapFormat {
36 ANDROID_BITMAP_FORMAT_NONE = 0,
37 ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
38 ANDROID_BITMAP_FORMAT_RGB_565 = 4,
39 ANDROID_BITMAP_FORMAT_RGBA_4444 = 7,
40 ANDROID_BITMAP_FORMAT_A_8 = 8,
43 typedef struct {
44 uint32_t width;
45 uint32_t height;
46 uint32_t stride;
47 int32_t format;
48 uint32_t flags; // 0 for now
49 } AndroidBitmapInfo;
51 /**
52 * Given a java bitmap object, fill out the AndroidBitmap struct for it.
53 * If the call fails, the info parameter will be ignored
55 int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap,
56 AndroidBitmapInfo* info);
58 /**
59 * Given a java bitmap object, attempt to lock the pixel address.
60 * Locking will ensure that the memory for the pixels will not move
61 * until the unlockPixels call, and ensure that, if the pixels had been
62 * previously purged, they will have been restored.
64 * If this call succeeds, it must be balanced by a call to
65 * AndroidBitmap_unlockPixels, after which time the address of the pixels should
66 * no longer be used.
68 * If this succeeds, *addrPtr will be set to the pixel address. If the call
69 * fails, addrPtr will be ignored.
71 int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr);
73 /**
74 * Call this to balanace a successful call to AndroidBitmap_lockPixels
76 int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap);
78 #ifdef __cplusplus
80 #endif
82 #endif