This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Tag365's profile picture

Bitmap API (View Microsoft Bitmap files in ComputerCraft)

Started by Tag365, 29 September 2015 - 11:17 PM
Tag365 #1
Posted 30 September 2015 - 01:17 AM
Using this program you are able to view, edit, and convert Microsoft Windows Bitmap files into ComputerCraft Paint files.
It is an API as well as a command line program, meaning it can function from the Command line.

To use it as an API run the program and the API will be loaded.
It introduces two classes, and they are Color3 and the expected Bitmap class.

Here are functions included in the Color3 class:

Color3.new(red, green, blue)
Color3:GetHue()
Color3:ToComputerCraftColor()
Color3:ToComputerCraftDither()

Here are all functions included in the Bitmap class:

Bitmap.new(width, height, backgroundColor3)
Bitmap.load(path)
Bitmap:Save(path)
Bitmap:SaveAsPaintFile(path)
Bitmap:DrawToTerm(x, y, [scale], [dithered])
Bitmap:GetPixel(x, y)
Bitmap:SetPixel(color, x, y)

To use it as a command line function run the file with additional arguments.
Use bitmap view <path> from the command line to view files.
Use bitmap convert <path> <destination> to convert a bitmap file to the ComputerCraft Paint format.

To download the API program use pastebin get B2NgcUsp.
Edited on 30 September 2015 - 02:44 PM
Bomb Bloke #2
Posted 30 September 2015 - 03:11 AM
CrazedProgrammer wrote a colour conversion API here; if you're wanting to replace your code, you might find it easiest to have your script automatically download his (if it's missing) then load it as an API.

The basics of the technique used are to stick the RGB values of CC's colours into a table, then when converting some other colour over, iterating through and adding up the differences between the three intensities. Whichever palette index has the lowest total difference is the better match (see lines 21-33).
Tag365 #3
Posted 30 September 2015 - 03:49 PM
Nice to know that. In the update I just made to the API I have added a portion of the API into my Color3 API to replace my faulty Color3 to ComputerCraft color function. I also made it able to read 16 bit Bitmaps.
Luca_S #4
Posted 30 September 2015 - 08:07 PM
Good job :D/> It is just a little weird that it turned my Image by 90° :unsure:/>

But i will vote this up :D/>