Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chaotikum-logo-20px
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
malte
chaotikum-logo-20px
Commits
19332acf
Commit
19332acf
authored
Aug 31, 2020
by
Malte Schmitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Organise script
parent
6462ee48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
foo.py
foo.py
+16
-6
No files found.
foo.py
View file @
19332acf
from
PIL
import
Image
import
sys
def
p
(
a
):
def
mapColors
(
rgb
):
return
tuple
(
round
(
v
/
255.0
)
for
v
in
rgb
)
def
encode
(
a
):
result
=
0
for
i
,
rgb
in
enumerate
(
a
):
r
,
g
,
b
=
[
round
(
v
/
255.0
)
for
v
in
rgb
]
r
,
g
,
b
=
rgb
result
|=
r
<<
i
*
3
result
|=
g
<<
i
*
3
+
1
result
|=
b
<<
i
*
3
+
2
return
result
return
hex
(
result
)
if
len
(
sys
.
argv
)
!=
2
:
print
(
"Missing file name argument"
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
img
=
Image
.
open
(
"20px-color.bmp"
).
convert
(
'RGB'
)
filename
=
sys
.
argv
[
1
]
img
=
Image
.
open
(
filename
).
convert
(
'RGB'
)
width
,
height
=
img
.
size
pixels
=
[
p
([
img
.
getpixel
((
x
,
y
))
for
y
in
range
(
height
)])
for
x
in
range
(
width
)]
pixels
=
[[
mapColors
(
img
.
getpixel
((
x
,
y
)))
for
y
in
range
(
height
)]
for
x
in
range
(
width
)]
array
=
"{"
+
","
.
join
([
hex
(
p
)
for
p
in
pixels
])
+
"}"
array
=
"{"
+
","
.
join
([
encode
(
p
)
for
p
in
pixels
])
+
"}"
code
=
"""uint64_t[{width}] pixels = {array};
...
...
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