I am trying to make a PNG Renderer, this is my code.
function lib.new(channel)
local img = Instance.new("EditableImage")
local pngData = png.new(game.HttpService:GetAsync(channel))
-- scale
local x, y = pngData.Width, pngData.Height
img:Resize(Vector2.new(x,y))
-- draw
local pixels = img:ReadPixels(Vector2.zero, img.Size)
local i = 0
for cx = 0, x-1 do
for cy = 0, y-1 do
local i0 = cy * x + cx + 1;
local c = pngData:GetPixel(cx, cy)
pixels[i0 + 0] = c.R
pixels[i0 + 1] = c.G
pixels[i0 + 2] = c.B
pixels[i0 + 3] = 0
end
end
img:WritePixels(Vector2.zero, img.Size, pixels)
return img
end
The PNG parser works, the renderer doesnt. It made this which is really odd.
I could be horribly wrong so I apologize in advance, but I believe you’re overwriting your colors because you aren’t accounting for the 4 extra indexes you have to skip.