From 4b37c7c8cacad50fa71bbdbc88789f235fa3d836 Mon Sep 17 00:00:00 2001
From: ubq323 <ubq323@ubq323.website>
Date: Thu, 4 Aug 2022 22:28:06 +0100
Subject: img

---
 img/load_pnm.lua | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'img')

diff --git a/img/load_pnm.lua b/img/load_pnm.lua
index ce1853a..0c89662 100644
--- a/img/load_pnm.lua
+++ b/img/load_pnm.lua
@@ -2,7 +2,7 @@
 -- because the textual ones are annoying
 
 -- types:
--- P1	ascii	pbm	
+-- P1	ascii	pbm
 -- P2	ascii	pgm
 -- P3	ascii	ppm
 -- P4	binary	pbm
@@ -17,7 +17,7 @@ local function np_p1(imgf,cur,depth)
 	local val,ncur = imgf:match("[01]%s*()",cur)
 	val = tonumber(val)
 	assert(val,"bad image format at "..cur)
-	local p = (1-v) -- 1 is black (0), 0 is white (1)
+	local p = (1-val) -- 1 is black (0), 0 is white (1)
 	local pixel = {p,p,p}
 	return pixel,ncur
 end
@@ -51,7 +51,7 @@ local function np_p5(imgf,cur,depth)
 	return pixel,cur+1
 end
 local function np_p6(imgf,cur,depth)
-	local vr,vg,vb = img:byte(cur,cur+3)
+	local vr,vg,vb = imgf:byte(cur,cur+3)
 	for _,v in ipairs{vr,vg,vb} do
 		assert(0<=v and v<=depth, "image value out of range at "..cur)
 	end
@@ -100,7 +100,7 @@ local function parse(imgf)
 
 	local x,y=1,1
 	local nextpixel = nextpixel_fns[typech]
-	
+
 	while cur <= #imgf do
 		local npixel,ncur = nextpixel(imgf,cur,depth)
 		img[y][x] = npixel
@@ -113,7 +113,7 @@ local function parse(imgf)
 			break
 		end
 	end
-	
+
 	img.width = width
 	img.height = height
 	return img
-- 
cgit v1.2.3