Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
0da136b0
Commit
0da136b0
authored
Dec 11, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an overload of draw_image() that's useful for drawing images
and doing interpolation at the same time.
parent
6643cbb8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
canvas_drawing.h
dlib/gui_widgets/canvas_drawing.h
+31
-0
canvas_drawing_abstract.h
dlib/gui_widgets/canvas_drawing_abstract.h
+27
-0
No files found.
dlib/gui_widgets/canvas_drawing.h
View file @
0da136b0
...
@@ -695,6 +695,37 @@ namespace dlib
...
@@ -695,6 +695,37 @@ namespace dlib
}
}
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
draw_image
(
const
canvas
&
c
,
const
rectangle
&
rect
,
const
image_type
&
img
,
const
rectangle
&
area_
=
rectangle
(
std
::
numeric_limits
<
long
>::
min
(),
std
::
numeric_limits
<
long
>::
min
(),
std
::
numeric_limits
<
long
>::
max
(),
std
::
numeric_limits
<
long
>::
max
())
)
{
const
rectangle
area
=
c
.
intersect
(
rect
).
intersect
(
area_
);
if
(
area
.
is_empty
()
||
img
.
size
()
==
0
)
return
;
const
matrix
<
long
,
1
>
x
=
matrix_cast
<
long
>
(
round
(
linspace
(
0
,
img
.
nc
()
-
1
,
rect
.
width
())));
const
matrix
<
long
,
1
>
y
=
matrix_cast
<
long
>
(
round
(
linspace
(
0
,
img
.
nr
()
-
1
,
rect
.
height
())));
for
(
long
row
=
area
.
top
();
row
<=
area
.
bottom
();
++
row
)
{
const
long
r
=
y
(
row
-
rect
.
top
());
long
cc
=
area
.
left
()
-
rect
.
left
();
for
(
long
col
=
area
.
left
();
col
<=
area
.
right
();
++
col
)
{
assign_pixel
(
c
[
row
-
c
.
top
()][
col
-
c
.
left
()],
img
[
r
][
x
(
cc
++
)]);
}
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
pixel_type
>
template
<
typename
pixel_type
>
...
...
dlib/gui_widgets/canvas_drawing_abstract.h
View file @
0da136b0
...
@@ -240,6 +240,33 @@ namespace dlib
...
@@ -240,6 +240,33 @@ namespace dlib
- only draws the part of the image that overlaps with the area rectangle
- only draws the part of the image that overlaps with the area rectangle
!*/
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
draw_image
(
const
canvas
&
c
,
const
rectangle
&
rect
,
const
image_type
&
img
,
const
rectangle
&
area
=
rectangle
(
-
infinity
,
-
infinity
,
infinity
,
infinity
)
);
/*!
requires
- image_type == an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<typename image_type::type> is defined
ensures
- draws the given image object onto the canvas such that the upper left corner
of the image will appear at the point rect.tl_corner() in the canvas's window
and the lower right corner of the image will appear at rect.br_corner() in
the canvas's window. (note that the upper left corner of the image is
assumed to be the pixel image[0][0] and the lower right corner of the image
is assumed to be image[image.nr()-1][image.nc()-1])
- only draws the part of the image that overlaps with the area rectangle
- Uses nearest neighbor interpolation when the given rect isn't the same size
as the input image.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment