Use 0 for black in pbm images
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 27 Jan 2018 13:08:36 -0500 |
parents |
1320162a9ed0
|
children |
e73c4713b159
|
branches/tags |
(none) |
files |
src/main.lisp test/data/1x1-black.ascii.pbm test/data/4x3-rgb.ascii.ppm |
Changes
--- a/src/main.lisp Thu Jan 25 23:14:41 2018 -0500
+++ b/src/main.lisp Sat Jan 27 13:08:36 2018 -0500
@@ -78,7 +78,7 @@
(dotimes (x width)
(setf (aref data x y)
(ecase format
- (:pbm (funcall reader stream))
+ (:pbm (- 1 (funcall reader stream)))
(:pgm (funcall reader stream))
(:ppm (make-array 3
:initial-contents (list (funcall reader stream)
@@ -98,7 +98,7 @@
(dotimes (x width)
(let ((pixel (aref data x y)))
(ecase format
- (:pbm (funcall writer pixel stream))
+ (:pbm (funcall writer (- 1 pixel) stream))
(:pgm (funcall writer pixel stream))
(:ppm (progn (funcall writer (aref pixel 0) stream)
(funcall writer (aref pixel 1) stream)
--- a/test/data/1x1-black.ascii.pbm Thu Jan 25 23:14:41 2018 -0500
+++ b/test/data/1x1-black.ascii.pbm Sat Jan 27 13:08:36 2018 -0500
@@ -1,3 +1,3 @@
P1
1 1
-0
+1
--- a/test/data/4x3-rgb.ascii.ppm Thu Jan 25 23:14:41 2018 -0500
+++ b/test/data/4x3-rgb.ascii.ppm Sat Jan 27 13:08:36 2018 -0500
@@ -1,6 +1,6 @@
P3
4 3
255
-255 0 0 255 100 0 255 0 0 255 0 0
+255 0 0 255 0 0 255 0 0 255 0 0
0 255 0 0 255 0 0 255 0 0 255 0
0 0 255 0 0 255 0 0 255 0 0 255