EditableImage buffer not updating correctly

Im having problems with the new EditableImage API. Currently im just trying to change the entire EditableImage Canvas to black to test that this works, but for some reason the canvas is always blank white. This is the code that actually changes the color, where bufferWidth is the Width of the image (in my case 300 - as a square image), x andy are theoretical coordinates on a 300x300 grid representing the EditableImage Canvas, and imageBuffer is the buffer returned by :ReadPixelsBuffer(). The below code is the function im using to update the buffer. The prints output expected results and there are no errors from the pcall.

local function updateImageBuffer(imageBuffer, x, y, bufferWidth, bufferHeight, r, g, b)
        
    local otherIndex = (((bufferWidth * (y - 1)) + (x - 1)) * 4) -- Convert X Y coordinates to Buffer Index
    if lastNum % 4000 == 0 then
        print(otherIndex, x, y, r, g, b)
    end
    local s, e = pcall(function()
        buffer.writeu8(imageBuffer, otherIndex, 0)
        buffer.writeu8(imageBuffer, otherIndex + 1, 0)
        buffer.writeu8(imageBuffer, otherIndex + 2, 0)
        buffer.writeu8(imageBuffer, otherIndex + 3,  0)
    end)
        
    if e then print(e, otherIndex) end
end

After all operations on the buffer are complete, I check one of the values from the middle of the buffer to make sure it actually got set, and it does. Then I convert this to ImageContent and put it on a SurfaceGui in PlayerGui thats adorneed to a part in workspace.

print(buffer.readu8(imageBuffer, height * width * 4 / 2 + 1))
image:WritePixelsBuffer(Vector2.zero, image.Size, imageBuffer)

OK. Since this isn’t mentioned on the documentation anywhere, the Alpha value needs to be set to 255. Setting it to 0 or 1 (which is standard for RGBA) will make the image white since the Alpha Value is actually 8bit. Probably should have thought about that sooner since you’re still setting it as an 8bit integer.

buffer.writeu8(imageBuffer, otherIndex + 3,  255)

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