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.
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.
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.
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
I would also recommend not to use this module due to performance issues.
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