Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
07b69eaf
Commit
07b69eaf
authored
Sep 11, 2014
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gfx: rotate bitmaps by angle, or by given _sin_ and _cos_ of angle
parent
ed89fd5b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
gfx.c
sw/common/gfx/gfx.c
+48
-0
gfx.h
sw/common/gfx/gfx.h
+3
-0
No files found.
sw/common/gfx/gfx.c
View file @
07b69eaf
...
...
@@ -2,6 +2,7 @@
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Matthieu Cattin <matthieu.cattin@cern.ch>
* &author Grzegorz Daniluk <grzegorz.daniluk@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -27,6 +28,7 @@
#include <stdlib.h>
#include "gfx.h"
#include "sincos.h"
#define GFX_POOL_SIZE 4096
...
...
@@ -258,3 +260,49 @@ void gfx_draw_bitmap(struct surface *surf, int x0, int y0, const struct rle_bitm
}
}
static
void
gfx_rotate
(
int
x0
,
int
y0
,
int
xr
,
int
yr
,
float
sina
,
float
cosa
,
int
*
x1
,
int
*
y1
)
{
int
xt
,
yt
;
/* 1. transform to (0, 0) */
xt
=
x0
-
xr
;
yt
=
y0
-
yr
;
/* 2. rotate */
*
x1
=
xt
*
cosa
-
yt
*
sina
;
*
y1
=
yt
*
cosa
+
xt
*
sina
;
/* 3. transofrm back to desired position */
*
x1
=
*
x1
+
xr
;
*
y1
=
*
y1
+
yr
;
}
void
gfx_draw_bitmap_rotate
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
const
struct
rle_bitmap
*
b
,
int
xr
,
int
yr
,
int
angle
,
float
sina
,
float
cosa
)
{
int
x
=
0
,
y
=
0
,
xt
,
yt
;
uint8_t
*
d
=
b
->
data
;
/*calculate sin/cos of angle only once*/
if
(
sina
>
1
||
sina
<-
1
)
sina
=
small_sin
(
angle
);
if
(
cosa
>
1
||
cosa
<-
1
)
cosa
=
small_cos
(
angle
);
while
(
y
!=
b
->
h
)
{
int
pix
=
(
*
d
)
&
0x80
?
1
:
0
;
int
rep
=
((
*
d
)
&
0x7f
)
+
1
;
d
++
;
while
(
rep
--
)
{
if
(
pix
)
{
gfx_rotate
(
x0
+
x
,
y0
+
y
,
xr
,
yr
,
sina
,
cosa
,
&
xt
,
&
yt
);
gfx_set_pixel
(
surf
,
xt
,
yt
,
COLOR_BLACK
);
}
x
++
;
if
(
x
==
b
->
w
)
{
x
=
0
;
y
++
;
}
}
}
}
sw/common/gfx/gfx.h
View file @
07b69eaf
...
...
@@ -2,6 +2,7 @@
* Copyright (C) 2014 Julian Lewis
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Matthieu Cattin <matthieu.cattin@cern.ch>
* &author Grzegorz Daniluk <grzegorz.daniluk@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -78,6 +79,8 @@ void gfx_reset_clip (struct surface *surf);
void
gfx_fill_circle
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
radius
,
int
value
);
void
gfx_round_box
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
x1
,
int
y1
,
int
radius
,
int
value
);
void
gfx_draw_bitmap
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
const
struct
rle_bitmap
*
b
);
void
gfx_draw_bitmap_rotate
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
const
struct
rle_bitmap
*
b
,
int
xr
,
int
yr
,
int
angle
,
float
sina
,
float
cosa
);
#endif
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