PngLibary - Working way to load images over 1024x1024

:stop_sign: This module was rushed so bad. Please dont use it in production, only use it for testing/fun

PngLibrary lets you process images by storing image data in a readable matrix and providing basic functions such as pixel read & pixel write. You can convert images to data roblox EditableImages use to display them or use a premade function for that (RenderOnEI or EIDrawInFrame for resolution over 1024x1024).

PngLibrary is a predecessor of PngLibrary2 (Private optimized module), its rushed and horrible. Once again, please dont use it for production.

Methods

PNG functions

png:GetPixel(x, y): Color3, Alpha
png:SetPixel(x, y, color, alpha) -- alpha defaults to 1
png:CropToPng(startX, startY, endX, endY)
png:ConvertToRaw(): EditableImage data format
png:RenderOnEI(EditableImage, startPos OR true) -- true will fill it
png:EIDrawInFrame(frame, splitRes) -- splitRes defaults to 1024
^ This function is very unoptimized, since it creates new png instances for every split frame
png:Dispose() -- Useless function since roblox gc already does that.

Module functions

module.fromBuffer(buffer)
module.fromMatrix(matrix)
^ Both functions are self explanatory

Code Example
local buffer = game:GetService('HttpService'):GetAsync('https://thedauser.github.io/test.png')

local pngLibrary = require(PATH_TO_MODULE)

local png = pngLibrary.fromBuffer(buffer)

png:RenderOnEI(PATH.EditableImage, true)
--use EIDrawInFrame for high resolution images (over 1024x1024)

Please, don’t suggest any improvements or fixes. This module is not maintained.

PngLibrary.rbxm (15.2 KB)

Wouldnt be possible without:

12 Likes

Ok, what’s the twist absent?

We all know a dauser post that you shouldn’t use in production DEFINETLY has a twist

2 Likes

I just remade it and published the old source code for people to learn.

2 Likes

Oh, nice module, amazing! What’s wrong with using this in production?

3 Likes

This allows for any image to be loaded from the internet - specifically excessive gore, NSFW, or other content that goes against the Community Guidelines and will certainly lead to a ban if detected and/or abused.

4 Likes

Whoever abused it is their fault. Plus there’s no way Roblox could moderate this straight off. There’s no record of image it’s purely how you use it and what others see - after all it’s just a bunch of colorful squares on a grid.

1 Like

yeah i realized

dunno what you expected with a (real) absentdenik post, pretty sure editableimages require fflags to see in game though so ehh

You dont really need any knowledge to do that without this module. It’s just unoptimized and editable images are not even out yet.

does anyone know why the pixels the module returns are black? it has the correct resolution of the image im loading, but its just black.

It’s a bug with PNG decoding library itself, I also had a similar bug with black and white png images, resave the image or try another one. If you need to work with that format, you can try fixing the module, look for Chunks folder
image
I would also recommend not to use this module due to performance issues.

1 Like

I found a way of fixing it, replace the png:ConvertToRaw() function to this:

function png:ConvertToRaw()
	local rawData = {}
	self.matrix:ForEach(function(x, y, val)
		local col, trans = unpack(val)
		local t = trans > 1 and trans / 255 or trans
		
		pushAll(rawData, col.R, col.G, col.B, t)
	end)
	
	return rawData
end
2 Likes