Beatmup
Static Public Member Functions
|
List of all members
Kernels::Cropping< in_t, out_t > Class Template Reference
Static Public Member Functions
static void
process
(
AbstractBitmap
&input,
AbstractBitmap
&output, const
IntRectangle
&
rect
, const
IntPoint
&
outOrigin
)
Detailed Description
template<class in_t, class out_t>
class Kernels::Cropping< in_t, out_t >
Definition at line
31
of file
crop.cpp
.
Member Function Documentation
◆
process()
template<class in_t , class out_t >
static void
Kernels::Cropping
< in_t, out_t >::process
(
AbstractBitmap
&
input
,
AbstractBitmap
&
output
,
const
IntRectangle
&
rect
,
const
IntPoint
&
outOrigin
)
inline
static
Definition at line
33
of file
crop.cpp
.
33
{
34
const
unsigned
char
35
bpp = AbstractBitmap::BITS_PER_PIXEL[input.
getPixelFormat
()],
36
ppb = 8 / bpp;
// pixels per byte
37
38
// test if output origin and clip rect horizontal borders are byte-aligned and the pixel formats are identical
39
const
bool
mayCopy = (input.
getPixelFormat
() == output.
getPixelFormat
()) &&
40
(bpp >= 8 || (
outOrigin
.
x
% ppb == 0 &&
rect
.
a
.
x
% ppb == 0 &&
rect
.
b
.
x
% ppb == 0));
41
42
in_t in(input);
43
out_t
out
(output);
44
45
if
(mayCopy) {
46
// direct copying
47
const
msize
lineSizeBytes = bpp >= 8 ?
rect
.
width
() * bpp / 8 :
rect
.
width
() / ppb;
48
for
(
int
y
=
rect
.
a
.
y
;
y
<
rect
.
b
.
y
; ++
y
) {
49
out
.goTo(
outOrigin
.
x
,
outOrigin
.
y
+
y
-
rect
.
a
.
y
);
50
in.goTo(
rect
.
a
.
x
,
y
);
51
memcpy(*
out
, *in, lineSizeBytes);
52
}
53
}
54
else
55
// projecting
56
for
(
int
y
=
rect
.
a
.
y
;
y
<
rect
.
b
.
y
; ++
y
) {
57
out
.goTo(
outOrigin
.
x
,
outOrigin
.
y
+
y
-
rect
.
a
.
y
);
58
in.goTo(
rect
.
a
.
x
,
y
);
59
for
(
int
x
=
rect
.
a
.
x
;
x
<
rect
.
b
.
x
; ++
x
, in++,
out
++)
60
out
= in();
61
}
62
}
Beatmup::AbstractBitmap::getPixelFormat
virtual const PixelFormat getPixelFormat() const =0
Pixel format of the bitmap.
Beatmup::CustomPoint::x
numeric x
Definition:
geometry.h:40
Beatmup::CustomPoint::y
numeric y
Definition:
geometry.h:40
Beatmup::CustomRectangle::b
CustomPoint< numeric > b
Definition:
geometry.h:131
Beatmup::CustomRectangle::width
numeric width() const
Definition:
geometry.h:174
Beatmup::CustomRectangle::a
CustomPoint< numeric > a
Definition:
geometry.h:131
Beatmup::msize
uint32_t msize
memory size
Definition:
basic_types.h:30
y
jobject jlong jint jint y
Definition:
wrapper_core.cpp:253
x
jobject jlong jint x
Definition:
wrapper_core.cpp:253
out
JNIEnv jlong jint out
Definition:
wrapper_imag.cpp:962
outOrigin
Beatmup::IntPoint outOrigin(left, top)
rect
Beatmup::IntRectangle rect(x1, y1, x2, y2)
The documentation for this class was generated from the following file:
core/bitmap/
crop.cpp
Kernels
Cropping
Generated on Tue Nov 21 2023 13:54:28 for Beatmup by
1.9.1