Skip to main content

Create a Bitmap

Create a bitmap and write to it

The following code demonstrates how to create a new Bitmap and then write to it's individual pixels.

Note: This attempts to save the bitmap to the C:\Temp folder, if you don't have that folder change the path to one that exists on your workstation.

-- Creates a 128x128 PNG file with a green background
local bitmap = factory.Bitmap(128, 128)

-- Lua is a 1 index language but the underlying C# objects
-- are 0 index objects.
for x = 0, 127 do
    for y = 0, 127 do
        bitmap.SetPixel(x, y, "green")
    end
end

bitmap.SavePng("C:\\Temp\\test.png")
bitmap.Dispose()