Beatmup
internal_bitmap.h
Go to the documentation of this file.
1
/*
2
Beatmup image and signal processing library
3
Copyright (C) 2019, 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 "../basic_types.h"
22
#include "../context.h"
23
#include "../memory.h"
24
#include "
abstract_bitmap.h
"
25
#include <vector>
26
27
namespace
Beatmup
{
28
29
/**
30
Bitmap whose memory is managed by the Beatmup engine.
31
Main pixel data container used internally by Beatmup. Applications would typically use a different incarnation
32
of AbstractBitmap implementing I/O operations, and InternalBitmap instances are used to exchange data between
33
different processing entities (AbstractTask instances) within the application.
34
*/
35
class
InternalBitmap
:
public
AbstractBitmap
{
36
private
:
37
PixelFormat
pixelFormat
;
38
int
width
,
height
;
39
AlignedMemory
memory
;
40
41
void
lockPixelData
();
42
inline
void
unlockPixelData
() {}
43
44
public
:
45
/**
46
Creates a bitmap.
47
The new bitmap created this way is "dirty" (contains random content). It is up to the application to fill
48
it with a content (e.g., set to zero).
49
\param ctx A Beatmup context instance
50
\param pixelFormat Pixel format
51
\param width Bitmap width in pixels
52
\param height Bitmap height in pixels
53
\param allocate If `true`, a storage is allocated in RAM. Otherwise the allocation is deferred
54
till the first use of the bitmap data by CPU. It is convenient to not allocate
55
if the bitmap is only used as a texture handler to store intremediate data when
56
processing on GPU.
57
*/
58
InternalBitmap
(
Context
&
ctx
,
PixelFormat
pixelFormat
,
int
width
,
int
height
,
bool
allocate =
true
);
59
60
/**
61
Loads image from a BMP file.
62
\param ctx A Beatmup context instance
63
\param bmpFilename Name of the .bmp file to be loaded
64
Raises exceptions if the input file is not readable or not a valid BMP image.
65
*/
66
InternalBitmap
(
Context
&
ctx
,
const
char
* bmpFilename);
67
68
/**
69
Changes bitmap size. Reallocates the memory if necessary.
70
Bitmap becomes "dirty" (contains no valid content).
71
\param[in] width New width in pixels
72
\param[in] height New height in pixels
73
*/
74
void
reshape
(
int
width
,
int
height
);
75
76
const
PixelFormat
getPixelFormat
()
const
;
77
const
int
getWidth
()
const
;
78
const
int
getHeight
()
const
;
79
const
msize
getMemorySize
()
const
;
80
const
pixbyte
*
getData
(
int
x
,
int
y
)
const
;
81
pixbyte
*
getData
(
int
x
,
int
y
);
82
};
83
84
}
abstract_bitmap.h
Beatmup::AbstractBitmap
A very basic class for any image.
Definition:
abstract_bitmap.h:87
Beatmup::AbstractBitmap::ctx
Context & ctx
context managing this bitmap
Definition:
abstract_bitmap.h:102
Beatmup::AlignedMemory
Aligned memory buffer.
Definition:
memory.h:27
Beatmup::Context
Basic class: task and memory management, any kind of static data.
Definition:
context.h:59
Beatmup::InternalBitmap
Bitmap whose memory is managed by the Beatmup engine.
Definition:
internal_bitmap.h:35
Beatmup::InternalBitmap::unlockPixelData
void unlockPixelData()
Unlocks access to the CPU memory buffer containing pixel data.
Definition:
internal_bitmap.h:42
Beatmup::InternalBitmap::getData
const pixbyte * getData(int x, int y) const
Returns a pointer to given pixel.
Definition:
internal_bitmap.cpp:114
Beatmup::InternalBitmap::getHeight
const int getHeight() const
Height of the texture in pixels.
Definition:
internal_bitmap.cpp:103
Beatmup::InternalBitmap::pixelFormat
PixelFormat pixelFormat
Definition:
internal_bitmap.h:37
Beatmup::InternalBitmap::getMemorySize
const msize getMemorySize() const
Bitmap size in bytes.
Definition:
internal_bitmap.cpp:108
Beatmup::InternalBitmap::getWidth
const int getWidth() const
Width of the texture in pixels.
Definition:
internal_bitmap.cpp:98
Beatmup::InternalBitmap::getPixelFormat
const PixelFormat getPixelFormat() const
Pixel format of the bitmap.
Definition:
internal_bitmap.cpp:93
Beatmup::InternalBitmap::InternalBitmap
InternalBitmap(Context &ctx, PixelFormat pixelFormat, int width, int height, bool allocate=true)
Creates a bitmap.
Definition:
internal_bitmap.cpp:27
Beatmup::InternalBitmap::height
int height
Definition:
internal_bitmap.h:38
Beatmup::InternalBitmap::memory
AlignedMemory memory
Definition:
internal_bitmap.h:39
Beatmup::InternalBitmap::width
int width
Definition:
internal_bitmap.h:38
Beatmup::InternalBitmap::lockPixelData
void lockPixelData()
Locks access to the CPU memory buffer containing pixel data.
Definition:
internal_bitmap.cpp:123
Beatmup::InternalBitmap::reshape
void reshape(int width, int height)
Changes bitmap size.
Definition:
internal_bitmap.cpp:74
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
y
jobject jlong jint jint y
Definition:
wrapper_core.cpp:253
x
jobject jlong jint x
Definition:
wrapper_core.cpp:253
core
bitmap
internal_bitmap.h
Generated on Tue Nov 21 2023 13:54:26 for Beatmup by
1.9.1