Beatmup
tools.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
#include "
abstract_bitmap.h
"
21
#include "
internal_bitmap.h
"
22
#include "../geometry.h"
23
#include "
pixel_arithmetic.h
"
24
25
namespace
Beatmup
{
26
/**
27
Set of handy operations with images
28
*/
29
namespace
BitmapTools {
30
/**
31
Makes a copy of a bitmap.
32
The copy is done in an AbstractTask run in the default thread pool of the context the bitmap is attached to.
33
\param[in] bitmap The bitmap to copy
34
*/
35
InternalBitmap
*
makeCopy
(
AbstractBitmap
&
bitmap
);
36
37
/**
38
Makes a copy of a bitmap converting the data to a given pixel format.
39
The copy is done in an AbstractTask run in the default thread pool of the context the bitmap is attached to.
40
\param[in] bitmap The bitmap to copy
41
\param[in] pixelFormat Pixel format of the copy
42
*/
43
InternalBitmap
*
makeCopy
(
AbstractBitmap
&
bitmap
,
PixelFormat
pixelFormat
);
44
45
/**
46
Makes a copy of a bitmap for a given Context converting the data to a given pixel format.
47
Can be used to exchange image content between different instances of Context.
48
The copy is done in an AbstractTask run in the default thread pool of the source bitmap context.
49
\param[in] bitmap The bitmap to copy
50
\param[in] context The Context instance the copy is associated with
51
\param[in] pixelFormat Pixel format of the copy
52
*/
53
InternalBitmap
*
makeCopy
(
AbstractBitmap
&
bitmap
,
Context
& context,
PixelFormat
pixelFormat
);
54
55
/**
56
Renders a chessboard image.
57
\param[in] context A Context instance
58
\param[in] width Width in pixels of the resulting bitmap
59
\param[in] height Height in pixels of the resulting bitmap
60
\param[in] cellSize Size of a single chessboard cell in pixels
61
\param[in] pixelFormat Pixel format of the resulting bitmap
62
*/
63
InternalBitmap
*
chessboard
(
Context
& context,
int
width
,
int
height
,
int
cellSize,
PixelFormat
pixelFormat
=
BinaryMask
);
64
65
/**
66
Replaces a rectangular area in a bitmap by random noise.
67
\param[in] bitmap The bitmap
68
\param[in] area The area in pixels to process
69
*/
70
void
noise
(
AbstractBitmap
&
bitmap
,
IntRectangle
area);
71
72
/**
73
Fills a given bitmap with random noise.
74
\param[in] bitmap The bitmap to fill
75
*/
76
void
noise
(
AbstractBitmap
&
bitmap
);
77
78
/**
79
Makes a bitmap area opaque.
80
Applies for bitmaps having the alpha channel (of QuadByte and QuadFloat pixel formats). Bitmaps of other
81
pixel formats remain unchanged.
82
\param[in] bitmap The bitmap
83
\param[in] area The area in pixels to process
84
*/
85
void
makeOpaque
(
AbstractBitmap
&
bitmap
,
IntRectangle
area);
86
87
/**
88
Inverses colors of an image in a pixelwise fashion.
89
\param[in] input The input image. Its content unchanged.
90
\param[in] output The output image.
91
*/
92
void
invert
(
AbstractBitmap
& input,
AbstractBitmap
& output);
93
94
/**
95
Goes through a bitmap in scanline order (left to right, top to bottom) until a pixel of a given color is met.
96
\param[in] source The bitmap to scan
97
\param[in] val The color value to look for
98
\param[in] startFrom Starting pixel position
99
\return the next closest position of the searched value (in scanline order) or (-1,-1) if not found.
100
*/
101
IntPoint
scanlineSearch
(
AbstractBitmap
& source,
pixint4
val
,
const
IntPoint
& startFrom);
102
IntPoint
scanlineSearch
(
AbstractBitmap
& source,
pixfloat4
val
,
const
IntPoint
& startFrom);
103
}
104
}
abstract_bitmap.h
Beatmup::AbstractBitmap
A very basic class for any image.
Definition:
abstract_bitmap.h:87
Beatmup::Context
Basic class: task and memory management, any kind of static data.
Definition:
context.h:59
Beatmup::CustomPoint< int >
Beatmup::CustomRectangle< int >
Beatmup::InternalBitmap
Bitmap whose memory is managed by the Beatmup engine.
Definition:
internal_bitmap.h:35
internal_bitmap.h
Beatmup::BitmapTools::scanlineSearch
IntPoint scanlineSearch(AbstractBitmap &source, pixint4 val, const IntPoint &startFrom)
Goes through a bitmap in scanline order (left to right, top to bottom) until a pixel of a given color...
Definition:
tools.cpp:195
Beatmup::BitmapTools::invert
void invert(AbstractBitmap &input, AbstractBitmap &output)
Inverses colors of an image in a pixelwise fashion.
Definition:
tools.cpp:155
Beatmup::BitmapTools::makeCopy
InternalBitmap * makeCopy(AbstractBitmap &bitmap)
Makes a copy of a bitmap.
Definition:
tools.cpp:72
Beatmup::BitmapTools::noise
void noise(AbstractBitmap &bitmap, IntRectangle area)
Replaces a rectangular area in a bitmap by random noise.
Definition:
tools.cpp:100
Beatmup::BitmapTools::chessboard
InternalBitmap * chessboard(Context &context, int width, int height, int cellSize, PixelFormat pixelFormat=BinaryMask)
Renders a chessboard image.
Definition:
tools.cpp:91
Beatmup::BitmapTools::makeOpaque
void makeOpaque(AbstractBitmap &bitmap, IntRectangle area)
Makes a bitmap area opaque.
Definition:
tools.cpp:131
Beatmup
Definition:
basic_types.h:22
Beatmup::PixelFormat
PixelFormat
Definition:
abstract_bitmap.h:70
Beatmup::BinaryMask
@ BinaryMask
1 bit per pixel
Definition:
abstract_bitmap.h:77
pixel_arithmetic.h
Beatmup::pixfloat4
4-channel floating point arithmetic
Definition:
pixel_arithmetic.h:319
Beatmup::pixint4
4-channel integer arithmetic
Definition:
pixel_arithmetic.h:252
pixelFormat
jlong jint jint jint jint pixelFormat
Definition:
wrapper_core.cpp:236
width
jlong jint width
Definition:
wrapper_core.cpp:235
height
jlong jint jint height
Definition:
wrapper_core.cpp:235
val
return(jlong) new Beatmup jlong jstring jint val
Definition:
wrapper_core.cpp:331
bitmap
Beatmup::InternalBitmap * bitmap
Definition:
wrapper_imag.cpp:602
core
bitmap
tools.h
Generated on Tue Nov 21 2023 13:54:26 for Beatmup by
1.9.1