Ocean
Loading...
Searching...
No Matches
android/Bitmap.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_PLATFORM_ANDROID_BITMAP_H
9#define META_OCEAN_PLATFORM_ANDROID_BITMAP_H
10
13
14#include "ocean/base/Frame.h"
15
16#include <android/bitmap.h>
17
18namespace Ocean
19{
20
21namespace Platform
22{
23
24namespace Android
25{
26
27/**
28 * This class implements bitmap functions.
29 * @ingroup platformandroid
30 */
31class OCEAN_PLATFORM_ANDROID_EXPORT Bitmap
32{
33 public:
34
35 /**
36 * Converts an Android bitmap to an Ocean frame.
37 * The Android bitmap must have format ANDROID_BITMAP_FORMAT_RGBA_8888.
38 * @param env The JNI environment, must be valid
39 * @param bitmap The Android bitmap to convert, must be valid
40 * @param copyData True, to copy the bitmap data; False, to use the bitmap data directly
41 * @return The resulting Ocean frame, an invalid frame if the conversion failed
42 */
43 static Frame toFrame(JNIEnv* env, jobject bitmap, const bool copyData = true);
44
45 /**
46 * Converts a frame with pixel format FORMAT_RGBA32 to an Android bitmap.
47 * @param env The JNI environment, must be valid
48 * @param rgbaFrame The frame to convert, with pixel format FORMAT_RGBA32, must be valid
49 * @return The resulting Android bitmap, nullptr if the conversion failed
50 */
51 static ScopedJObject toBitmap(JNIEnv* env, const Frame& rgbaFrame);
52
53 /**
54 * Translates an Android bitmap format to an Ocean pixel format.
55 * @param format The Android bitmap format to translate
56 * @return The corresponding Ocean pixel format, FORMAT_UNDEFINED if unknown
57 */
58 static FrameType::PixelFormat translateFormat(const AndroidBitmapFormat format);
59
60 /**
61 * Translates an Ocean pixel format to an Android bitmap format.
62 * @param pixelFormat The Ocean pixel format to translate
63 * @return The corresponding Android bitmap format, ANDROID_BITMAP_FORMAT_NONE if unknown
64 */
65 static AndroidBitmapFormat translateFormat(const FrameType::PixelFormat pixelFormat);
66};
67
68}
69
70}
71
72}
73
74#endif // META_OCEAN_PLATFORM_ANDROID_BITMAP_H
This class implements Ocean's image class.
Definition Frame.h:1808
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
This class implements bitmap functions.
Definition android/Bitmap.h:32
static Frame toFrame(JNIEnv *env, jobject bitmap, const bool copyData=true)
Converts an Android bitmap to an Ocean frame.
static AndroidBitmapFormat translateFormat(const FrameType::PixelFormat pixelFormat)
Translates an Ocean pixel format to an Android bitmap format.
static FrameType::PixelFormat translateFormat(const AndroidBitmapFormat format)
Translates an Android bitmap format to an Ocean pixel format.
static ScopedJObject toBitmap(JNIEnv *env, const Frame &rgbaFrame)
Converts a frame with pixel format FORMAT_RGBA32 to an Android bitmap.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15