1 {*
2 * Copyright (C) 2009 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 unit bitmap;
17
18 {$mode delphi}
19 {$packrecords c}
20
21 interface
22
23 uses
24 ctypes, jni;
25
26 {#include <stdint.h>
27 #include <jni.h>}
28
29 {$linklib jnigraphics}
30
31 const
32 libname='libjnigraphics.so';
33
34 ANDROID_BITMAP_RESUT_SUCCESS = 0;
35 ANDROID_BITMAP_RESULT_BAD_PARAMETER =-1;
36 ANDROID_BITMAP_RESULT_JNI_EXCEPTION =-2;
37 ANDROID_BITMAP_RESULT_ALLOCATION_FAILED =-3;
38
39 type
40 AndroidBitmapFormat = (
41 ANDROID_BITMAP_FORMAT_NONE = 0,
42 ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
43 ANDROID_BITMAP_FORMAT_RGB_565 = 4,
44 ANDROID_BITMAP_FORMAT_RGBA_4444 = 7,
45 ANDROID_BITMAP_FORMAT_A_8 = 8
46 );
47
48 AndroidBitmapInfo = record
49 width: Cardinal;//uint32_t;
50 height: Cardinal;//uint32_t
51 stride: Cardinal;//uint32_t
52 format: Integer;//int32_t
53 flags: Cardinal;//uint32_t // 0 for now
54 end;
55 PAndroidBitmapInfo = ^AndroidBitmapInfo;
56
57 {**
58 * Given a java bitmap object, fill out the AndroidBitmap struct for it.
59 * If the call fails, the info parameter will be ignored
60 *}
AndroidBitmap_getInfonull61 function AndroidBitmap_getInfo(env: PJNIEnv;
62 jbitmap: jobject; info: PAndroidBitmapInfo): cint;
63 cdecl; external libname name 'AndroidBitmap_getInfo';
64
65 {**
66 * Given a java bitmap object, attempt to lock the pixel address.
67 * Locking will ensure that the memory for the pixels will not move
68 * until the unlockPixels call, and ensure that, if the pixels had been
69 * previously purged, they will have been restored.
70 *
71 * If this call succeeds, it must be balanced by a call to
72 * AndroidBitmap_unlockPixels, after which time the address of the pixels should
73 * no longer be used.
74 *
75 * If this succeeds, *addrPtr will be set to the pixel address. If the call
76 * fails, addrPtr will be ignored.
77 *}
AndroidBitmap_lockPixelsnull78 function AndroidBitmap_lockPixels(env: PJNIEnv; jbitmap: jobject;
79 addrPtr: PPointer {void**}): cint; cdecl; external libname name 'AndroidBitmap_lockPixels';
80
81 {**
82 * Call this to balanace a successful call to AndroidBitmap_lockPixels
83 *}
AndroidBitmap_unlockPixelsnull84 function AndroidBitmap_unlockPixels(env: PJNIEnv;
85 jbitmap: jobject): cint; cdecl; external libname name 'AndroidBitmap_unlockPixels';
86
87 implementation
88
89 end.
90
91