DEV Community

loading...
Cover image for Drawing a lövely image

Drawing a lövely image

Talles L
A Brazilian software developer 🇧🇷 that loves to play video-games 🎮, tries it best to be active on GitHub 💻, and sometimes writes here on DEV 📄
・1 min read

Drawing an image file:

function love.load()
    mario = love.graphics.newImage("mario.png")
end

function love.draw()
    love.graphics.draw(mario)
end
Enter fullscreen mode Exit fullscreen mode

Drawing an image from base64 on source code:

mario64 = "iVBORw0KGgoAAAANSUhEUgAAAQQAAAEEBAMAAAA8Jlc5AAAAElBMVEUAAAAAAACIcADYKAD8mDj///9LiYtiAAAAAXRSTlMAQObYZgAAAAFiS0dEBfhv6ccAAAEsSURBVHja7d3BDYUgEAVAWqCF34It2H9N/+RlEwIiUcF5R4zuHDdhwZTyw0mpnbA1BgEBAQEBAeF7hG1QEBAQEBAQENYl/ArZQ+L6wJYFAQEBAQEB4aWE+MlS6dbnCAgICAgICN8hDKYgICAgICAgLECofbJEjLnQsiAgICAgICC8lBCzd2bg1CcCAgICAgLCSwmx9ThGKE+2JggICAgICAgLEkolSoROGgICAgICAsKEhNrWRu3o5smtEQQEBAQEBIQJCaXRiKPEsR5Lx/XS6AUCAgICAgLCeoRSyVouHNFAQEBAQEBAmIxw9WpJBAQEBAQEhPUIMa1XTHf+0gIBAQEBAQFhYkLvEYwbpj4REBAQEBAQHiZ0Xv3U+z4CAgICAgLChISbg5BzzukP4FDNAIC3HvUAAAAASUVORK5CYII="

byte_data = love.data.decode('data', 'base64', mario64)
image_data = love.image.newImageData(byte_data)
image = love.graphics.newImage(image_data)

function love.draw()
    love.graphics.draw(image)
end
Enter fullscreen mode Exit fullscreen mode

Discussion (0)