Beatmup
bitmap.h
Go to the documentation of this file.
1
/*
2
Beatmup image and signal processing library
3
Copyright (C) 2020, lnstadrum
4
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#pragma once
20
21
#include <pybind11/numpy.h>
22
23
#include "
bitmap/abstract_bitmap.h
"
24
#include "context.h"
25
26
namespace
Beatmup
{
27
/**
28
%Python binding utilities
29
*/
30
namespace
Python {
31
32
/**
33
Wrapper of Android.Graphics.Bitmap object
34
*/
35
class
Bitmap
:
public
AbstractBitmap
{
36
private
:
37
pybind11::buffer_info
data
;
38
PixelFormat
format
;
39
int
strideBytes
;
40
41
void
lockPixelData
() {}
42
void
unlockPixelData
() {}
43
44
public
:
45
/**
46
Creates the bitmap from Android Bitmap java object
47
*/
48
Bitmap
(
Beatmup::Context
& context, pybind11::buffer& buffer);
49
50
inline
const
PixelFormat
getPixelFormat
()
const
{
return
format
; };
51
52
inline
const
int
getWidth
()
const
{
return
(
int
)
data
.shape[
data
.ndim - 2]; }
53
54
inline
const
int
getHeight
()
const
{
return
(
int
)
data
.shape[
data
.ndim - 3]; }
55
56
const
pixbyte
*
getData
(
int
x
,
int
y
)
const
;
57
pixbyte
*
getData
(
int
x
,
int
y
);
58
59
const
msize
getMemorySize
()
const
;
60
61
/**
62
Returns a mutable python buffer containing bitmap data.
63
*/
64
inline
pybind11::buffer_info
getPythonBuffer
() {
65
#ifdef BEATMUP_DEBUG
66
DebugAssertion::check(
isUpToDate
(
ProcessingTarget::CPU
),
"Returning a buffer for outdated Python bitmap"
);
67
#endif
68
return
pybind11::buffer_info(
data
.ptr,
data
.itemsize,
data
.format,
data
.ndim,
data
.shape,
data
.strides,
false
);
69
}
70
};
71
72
}
73
}
abstract_bitmap.h
Beatmup::AbstractBitmap
A very basic class for any image.
Definition:
abstract_bitmap.h:87
Beatmup::AbstractBitmap::isUpToDate
bool isUpToDate(ProcessingTarget) const
Definition:
abstract_bitmap.cpp:106
Beatmup::Context
Basic class: task and memory management, any kind of static data.
Definition:
context.h:59
Beatmup::Python::Bitmap
Wrapper of Android.Graphics.Bitmap object.
Definition:
bitmap.h:35
Beatmup::Python::Bitmap::unlockPixelData
void unlockPixelData()
Unlocks access to the CPU memory buffer containing pixel data.
Definition:
bitmap.h:42
Beatmup::Python::Bitmap::getPixelFormat
const PixelFormat getPixelFormat() const
Pixel format of the bitmap.
Definition:
bitmap.h:50
Beatmup::Python::Bitmap::getHeight
const int getHeight() const
Height of the texture in pixels.
Definition:
bitmap.h:54
Beatmup::Python::Bitmap::getMemorySize
const msize getMemorySize() const
Bitmap size in bytes.
Definition:
bitmap.cpp:87
Beatmup::Python::Bitmap::lockPixelData
void lockPixelData()
Locks access to the CPU memory buffer containing pixel data.
Definition:
bitmap.h:41
Beatmup::Python::Bitmap::getPythonBuffer
pybind11::buffer_info getPythonBuffer()
Returns a mutable python buffer containing bitmap data.
Definition:
bitmap.h:64
Beatmup::Python::Bitmap::getWidth
const int getWidth() const
Width of the texture in pixels.
Definition:
bitmap.h:52
Beatmup::Python::Bitmap::data
pybind11::buffer_info data
Definition:
bitmap.h:37
Beatmup::Python::Bitmap::strideBytes
int strideBytes
Definition:
bitmap.h:39
Beatmup::Python::Bitmap::Bitmap
Bitmap(Beatmup::Context &context, pybind11::buffer &buffer)
Creates the bitmap from Android Bitmap java object.
Definition:
bitmap.cpp:25
Beatmup::Python::Bitmap::format
PixelFormat format
Definition:
bitmap.h:38
Beatmup::Python::Bitmap::getData
const pixbyte * getData(int x, int y) const
Returns a pointer to given pixel.
Definition:
bitmap.cpp:77
Beatmup
Definition:
basic_types.h:22
Beatmup::msize
uint32_t msize
memory size
Definition:
basic_types.h:30
Beatmup::pixbyte
uint8_t pixbyte
Definition:
basic_types.h:34
Beatmup::PixelFormat
PixelFormat
Definition:
abstract_bitmap.h:70
Beatmup::CPU
@ CPU
Definition:
basic_types.h:55
y
jobject jlong jint jint y
Definition:
wrapper_core.cpp:253
x
jobject jlong jint x
Definition:
wrapper_core.cpp:253
python
src
bitmap.h
Generated on Tue Nov 21 2023 13:54:27 for Beatmup by
1.9.1