1 /*
2                                     __
3                                    / _|
4   __ _ _   _ _ __ ___  _ __ __ _  | |_ ___  ___ ___
5  / _` | | | | '__/ _ \| '__/ _` | |  _/ _ \/ __/ __|
6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \
7  \__,_|\__,_|_|  \___/|_|  \__,_| |_| \___/|___/___/
8 
9 Copyright (C) 2009 The Android Open Source Project.
10 Copyright (C) 2018-2019 Aurora Free Open Source Software.
11 
12 This file is part of the Aurora Free Open Source Software. This
13 organization promote free and open source software that you can
14 redistribute and/or modify under the terms of the GNU Lesser General
15 Public License Version 3 as published by the Free Software Foundation or
16 (at your option) any later version approved by the Aurora Free Open Source
17 Software Organization. The license is available in the package root path
18 as 'LICENSE' file. Please review the following information to ensure the
19 GNU Lesser General Public License version 3 requirements will be met:
20 https://www.gnu.org/licenses/lgpl.html .
21 
22 Alternatively, this file may be used under the terms of the GNU General
23 Public License version 3 or later as published by the Free Software
24 Foundation. Please review the following information to ensure the GNU
25 General Public License requirements will be met:
26 https://www.gnu.org/licenses/gpl-3.0.html.
27 
28 NOTE: All products, services or anything associated to trademarks and
29 service marks used or referenced on this file are the property of their
30 respective companies/owners or its subsidiaries. Other names and brands
31 may be claimed as the property of others.
32 
33 For more info about intellectual property visit: aurorafoss.org or
34 directly send an email to: contact (at) aurorafoss.org .
35 
36 This file has bindings for an existing code, part of The Android Open Source
37 Project implementation. Check it out at android.googlesource.com .
38 */
39 
40 module aurorafw.android.platform.bitmap;
41 
42 /**
43  * @addtogroup Bitmap
44  * @{
45  */
46 
47 /**
48  * @file aurorafw/android/platform/bitmap.d
49  */
50 
51 version (Android):
52 extern (C):
53 @system:
54 nothrow:
55 @nogc:
56 
57 /** AndroidBitmap functions result code. */
58 enum
59 {
60     /** Operation was successful. */
61     ANDROID_BITMAP_RESULT_SUCCESS = 0,
62     /** Bad parameter. */
63     ANDROID_BITMAP_RESULT_BAD_PARAMETER = -1,
64     /** JNI exception occured. */
65     ANDROID_BITMAP_RESULT_JNI_EXCEPTION = -2,
66     /** Allocation failed. */
67     ANDROID_BITMAP_RESULT_ALLOCATION_FAILED = -3
68 }
69 
70 /** Backward compatibility: this macro used to be misspelled. */
71 enum ANDROID_BITMAP_RESUT_SUCCESS = ANDROID_BITMAP_RESULT_SUCCESS;
72 
73 /** Bitmap pixel format. */
74 enum AndroidBitmapFormat
75 {
76     /** No format. */
77     ANDROID_BITMAP_FORMAT_NONE = 0,
78     /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/
79     ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
80     /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/
81     ANDROID_BITMAP_FORMAT_RGB_565 = 4,
82     /** Deprecated in API level 13. Because of the poor quality of this configuration, it is advised to use ARGB_8888 instead. **/
83     ANDROID_BITMAP_FORMAT_RGBA_4444 = 7,
84     /** Alpha: 8 bits. */
85     ANDROID_BITMAP_FORMAT_A_8 = 8
86 }
87 
88 /** Bitmap info, see AndroidBitmap_getInfo(). */
89 struct AndroidBitmapInfo
90 {
91     /** The bitmap width in pixels. */
92     uint width;
93     /** The bitmap height in pixels. */
94     uint height;
95     /** The number of byte per row. */
96     uint stride;
97     /** The bitmap pixel format. See {@link AndroidBitmapFormat} */
98     int format;
99     /** Unused. */
100     uint flags; // 0 for now
101 }
102 
103 /**
104  * Given a java bitmap object, fill out the AndroidBitmapInfo struct for it.
105  * If the call fails, the info parameter will be ignored.
106  */
107 int AndroidBitmap_getInfo (
108     JNIEnv* env,
109     jobject jbitmap,
110     AndroidBitmapInfo* info);
111 
112 /**
113  * Given a java bitmap object, attempt to lock the pixel address.
114  * Locking will ensure that the memory for the pixels will not move
115  * until the unlockPixels call, and ensure that, if the pixels had been
116  * previously purged, they will have been restored.
117  *
118  * If this call succeeds, it must be balanced by a call to
119  * AndroidBitmap_unlockPixels, after which time the address of the pixels should
120  * no longer be used.
121  *
122  * If this succeeds, *addrPtr will be set to the pixel address. If the call
123  * fails, addrPtr will be ignored.
124  */
125 int AndroidBitmap_lockPixels (JNIEnv* env, jobject jbitmap, void** addrPtr);
126 
127 /**
128  * Call this to balance a successful call to AndroidBitmap_lockPixels.
129  */
130 int AndroidBitmap_unlockPixels (JNIEnv* env, jobject jbitmap);
131 
132 /** @} */