So I recently came back to love after quite some time and decided to look at my old project. For some reason it didn't work and the culprit is imageData:getPixel() returning numbers from 0-1 instead of 0-255. This is a big deal because I created maps from reading image files and it depended on the color of the pixel to create tiles as you can see in these files: https://github.com/stefankoxd/overly-en ... verter.lua and https://github.com/stefankoxd/overly-en ... ainter.lua
Is there any way to fix this?
Converting imageData:getPixel() numbers to the 0-255 range
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Converting imageData:getPixel() numbers to the 0-255 range
Code: Select all
math.floor(c * 255 +.5)
Or use cindy. Either call require('cindy').applyPatch() to have the old behavior restored in all relevant functions, or use the provided *Bytes alternatives.
Code: Select all
function converter:imagetomap(img)
local pixelData = {}
local function map(x, y, r, g, b, a)
pixelData[#pixelData + 1] = { x = x, y = y, r = r, g = g, b = b }
return r, g, b, a
end
img:mapPixelBytes(map)
return pixelData
end
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], whateverest and 4 guests