EditableImage help

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.


it should be

Are you trying to make the colors inverted?

Another test:


Also tried changing

			pixels[i0 + 3] = 1 -- alpha was 0 before

nothing changed

No, I want it to be the same as the PNG.

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.

You can check how Roblox does it:

If this was the issue the same issue will happen for the transparency and random strikes could be seen in the image.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.