Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
clim-tos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alastair Bridgewater
clim-tos
Commits
65bbe7bb
Commit
65bbe7bb
authored
33 years ago
by
cer
Browse files
Options
Downloads
Patches
Plain Diff
Initial revision
parent
278bab44
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tk-silica/image.lisp
+99
-0
99 additions, 0 deletions
tk-silica/image.lisp
with
99 additions
and
0 deletions
tk-silica/image.lisp
0 → 100644
+
99
−
0
View file @
65bbe7bb
(
in-package
:xm-silica
)
(
defun
correct-case
(
x
)
x
)
(
defun
kintern
(
x
)
(
intern
x
:keyword
))
(
defun
make-pattern-from-file
(
file
designs
)
(
multiple-value-bind
(
array
width
height
depth
)
(
read-bitmap-file
file
)
(
make-pattern
array
designs
)))
(
defun
read-bitmap-file
(
pathname
)
;; Creates an image from a C include file in standard X11 format
(
declare
(
type
(
or
pathname
string
stream
)
pathname
))
(
declare
(
values
image
))
(
with-open-file
(
fstream
pathname
:direction
:input
)
(
let
((
line
""
)
(
properties
nil
)
(
name
nil
)
(
name-end
nil
))
(
declare
(
type
string
line
)
(
type
stringable
name
)
(
type
list
properties
))
;; Get properties
(
loop
(
setq
line
(
read-line
fstream
))
(
when
(
>
(
length
line
)
0
)
(
unless
(
char=
(
aref
line
0
)
#\#
)
(
return
))
(
flet
((
read-keyword
(
line
start
end
)
(
kintern
(
substitute
#\-
#\_
(
#-
excl
string-upcase
#+
excl
correct-case
(
subseq
line
start
end
))
:test
#'
char=
))))
(
when
(
null
name
)
(
setq
name-end
(
position
#\_
line
:test
#'
char=
:from-end
t
)
name
(
read-keyword
line
8
name-end
))
(
unless
(
eq
name
:image
)
(
setf
(
getf
properties
:name
)
name
)))
(
let*
((
ind-start
(
1+
name-end
))
(
ind-end
(
position
#\Space
line
:test
#'
char=
:start
ind-start
))
(
ind
(
read-keyword
line
ind-start
ind-end
))
(
val-start
(
1+
ind-end
))
(
val
(
parse-integer
line
:start
val-start
)))
(
setf
(
getf
properties
ind
)
val
)))))
(
multiple-value-bind
(
width
height
depth
left-pad
)
(
flet
((
extract-property
(
ind
&rest
default
)
(
prog1
(
apply
#'
getf
properties
ind
default
)
(
remf
properties
ind
))))
(
values
(
extract-property
:width
)
(
extract-property
:height
)
(
extract-property
:depth
1
)
(
extract-property
:left-pad
0
)))
(
unless
(
and
width
height
)
(
error
"Not a BITMAP file"
))
(
let*
((
bits-per-pixel
(
cond
((
>
depth
24
)
32
)
((
>
depth
16
)
24
)
((
>
depth
8
)
16
)
((
>
depth
4
)
8
)
((
>
depth
2
)
4
)
((
>
depth
1
)
2
)
(
t
1
)))
(
data
(
make-array
(
list
height
width
)))
(
w
0
)
(
h
0
))
(
labels
((
read-a-byte
()
(
peek-char
#\x
fstream
)
(
read-char
fstream
)
(
+
(
*
16
(
digit-char-p
(
read-char
fstream
)
16
))
(
digit-char-p
(
read-char
fstream
)
16
)))
(
store-byte
(
x
)
(
setf
(
aref
data
h
w
)
x
)
(
incf
w
)
(
when
(
=
w
width
)
(
setq
w
0
)
(
incf
h
))
(
when
(
=
h
height
)
(
return-from
read-bitmap-file
(
values
data
width
height
depth
)))))
(
loop
(
let
((
x
0
))
(
dotimes
(
i
(
ceiling
bits-per-pixel
8
))
(
setf
x
(
ash
x
8
))
(
incf
x
(
read-a-byte
)))
(
if
(
>=
bits-per-pixel
8
)
(
store-byte
x
)
(
dotimes
(
j
(
/
8
bits-per-pixel
))
(
store-byte
(
ldb
(
byte
bits-per-pixel
(
*
j
bits-per-pixel
))
x
))))))))))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment