{{indexmenu_n>999}} ====== Save ====== ### //BitMap.Save(b, FileName)// writes the [[documentation:language_reference:objects:bitmap:start|BitMap object]] //b// to the file //FileName// as a bmp image, which most image viewers and web browsers can open. The file keeps the transparency of the pixels. An existing file of that name is overwritten. ### ===== Input ===== * //b// : a BitMap object. * //FileName// : String, the name of the file, for example //"Picture.bmp"//. ===== Output ===== ### None; the file is written. ### ### The file has 32 bits per pixel, red, green, blue and the opacity, and a header of 138 bytes, so a bitmap of //NX// by //NY// pixels gives a file of $138 + 4\, NX\, NY$ bytes. ### ===== Example ===== ### A bitmap of 256 by 256 pixels with red increasing from left to right and blue from bottom to top, written as a bmp file. ### ==== Input ==== -- a bitmap of 256 by 256 pixels: red increases from left to right, blue from bottom to top b = BitMap.New(256, 256) for i = 1, 256 do for j = 1, 256 do BitMap.Pixel(b, i, j, 0x010000*(i-1) + 0x000001*(256-j)) end end BitMap.Save(b, "Gradient.bmp") -- the file has a header of 138 bytes and 4 bytes per pixel file = io.open("Gradient.bmp", "rb") print("Gradient.bmp has "..file:seek("end").." bytes") file:close() ==== Result ==== Gradient.bmp has 262282 bytes ### The file //Gradient.bmp//: ### {{:documentation:language_reference:objects:bitmap:functions:bitmap_save.png?nolink&256 |}} ===== Table of contents ===== {{indexmenu>../#2|tsort}}