local function t(t,n)local a=n.Data local E=t.BitDepth local I=t.ColorType E=2^E-1 if I==3 then local n=t.Palette local E={}for t=1,#n,1 do local n=a:ReadByte()if not n then n=255 end E[t]=n end t.AlphaData=E elseif I==0 then local n=a:ReadUInt16()t.Alpha=n/E elseif I==2 then local n=a:ReadUInt16()/E local I=a:ReadUInt16()/E local O=a:ReadUInt16()/E t.Alpha=Color3.new(n,I,O)else error("\080\078\071 - \073\110\118\097\108\105\100 \116\082\078\083 \099\104\117\110\107")end end return t
local function tRNS(file, chunk)
	local data = chunk.Data
	
	local bitDepth = file.BitDepth
	local colorType = file.ColorType
	
	bitDepth = (2 ^ bitDepth) - 1
	
	if colorType == 3 then
		local palette = file.Palette
		local alphaMap = {}
		
		for i = 1, #palette do
			local alpha = data:ReadByte()
			
			if not alpha then
				alpha = 255
			end
			
			alphaMap[i] = alpha
		end
		
		file.AlphaData = alphaMap
	elseif colorType == 0 then
		local grayAlpha = data:ReadUInt16()
		file.Alpha = grayAlpha / bitDepth
	elseif colorType == 2 then
		-- TODO: This seems incorrect...
		local r = data:ReadUInt16() / bitDepth
		local g = data:ReadUInt16() / bitDepth
		local b = data:ReadUInt16() / bitDepth
		file.Alpha = Color3.new(r, g, b)
	else
		error("PNG - Invalid tRNS chunk")
	end	
end

return tRNS