Sorry if this might be a bother, but I’m still very confused on how to make a working videoplayer without causing a huge amount of lag everytime it loads an image, my code is currently a sample, however everytime I load the image, it causes alot of lag, I can’t imagine loading those images every 0.1 seconds. Is there anyway to make it so it doesn’t create a whole bunch of lag when loading in the pixels? I’m not really familiar with the module as I just started using it a couple days ago. (Also yes im aware this code will only load one image.)
heres the code:
local Gui = script.Parent
local Frame = Gui.Frame
local CanvasDraw = require(Gui.CanvasDraw)
local Canvas = CanvasDraw.new(Frame)
-- Load our image
local ImageData = CanvasDraw.GetImageDataFromSaveObject(script.Parent.ImageTest) -- Our Image
local Canvas = CanvasDraw.new(Frame, ImageData.ImageResolution)
-- Main
local CompressionAmount = 10 -- From 0 to 256 (The lower, more colours, the higher, less colours)
local NewColours = {}
for i, OldColour in pairs(ImageData.ImageColours) do -- Loop through the raw image Color3 values
-- Compress the RGB channels
local CompressedR = math.floor((OldColour.R * 255) / CompressionAmount) * CompressionAmount
local CompressedG = math.floor((OldColour.G * 255) / CompressionAmount) * CompressionAmount
local CompressedB = math.floor((OldColour.B * 255) / CompressionAmount) * CompressionAmount
CompressedColour = Color3.fromRGB(CompressedR, CompressedG, CompressedB)
NewColours[i] = CompressedColour
end
ImageData.ImageColours = NewColours
Canvas:DrawImageXY(ImageData, 1, 1)