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

Paint 2.0

Started by Cruor, 12 October 2012 - 04:29 PM
Cruor #1
Posted 12 October 2012 - 06:29 PM
As this isn't updated at all, and got even less features than the default paint program, i'm not pretty much wiping the whole post.

This will someday(when i got time) be updated to the official release of 1.45, with the features promised in the "old" post. These include, layers, your basic tools(lines, flood, etc), brushes, picture scrolling, and a sane way to just display your pictures. Support with nPaintPro will still be something i wish to keep.

So i'll see you guys when its updated.
billysback #2
Posted 12 October 2012 - 06:38 PM
where do you get the pre-release for CC 1.45?
jag #3
Posted 12 October 2012 - 06:49 PM
Wow! Cool!
Do you use the mouse to paint? Like in MSPaint?
Cruor #4
Posted 12 October 2012 - 07:00 PM
Wow! Cool!
Do you use the mouse to paint? Like in MSPaint?

yes you use the mouse




Additional info added to post
nitrogenfingers #5
Posted 14 October 2012 - 12:07 PM
It's likely this application is not only the most important piece of programming on these forums but is be of such defining genius that it will rocket humanity into a new age of peace and harmony.
billysback #6
Posted 14 October 2012 - 12:15 PM
I could add support for this in to CTR if anyone would appriciate it; it would be a simple matter of adding a few more buttons and a marginally different write and read methods.

(CTR; warning, kind of an advertisment…)
SpoilerScreenshots:
Spoiler

Download:
Spoilerv1.0:
http://www.mediafire...n9cf52gvzmdaws5
v1.1:
http://www.mediafire...8ibzchhoboh0f2b

How to use:
SpoilerOpen up and you will see a window looking like the first picture;
Either enter the directory of the file you wish to create/open in the longer text box or click the button to the right of the longer text box to open a file browser.
If you are opening a file; ignore the WIDTH and HEIGHT boxes
If you are creating a file; set the WIDTH and HEIGHT of the picture in those fields.

click the Create or Open button depending on what you want to do, if nothing happens something went wrong.

If it went right, the original window should disappear and two more should appear, one is called "Tools" the other is your picture,
in your tools window you can set the color you are painting with and save the picture
To draw on the image just move your mouse around the screen and a box the color of you selected color in Tools should appear around the selected cell, click to color it in that color.

Thats it! press save to save, the box above the save button has the original directory in it but you can change it if you wish.
Cruor #7
Posted 14 October 2012 - 12:21 PM
I could add support for this in to CTR if anyone would appriciate it; it would be a simple matter of adding a few more buttons and a marginally different write and read methods.

(CTR; warning, kind of an advertisment…)
SpoilerScreenshots:
Spoiler

Download:
Spoilerv1.0:
http://www.mediafire...n9cf52gvzmdaws5
v1.1:
http://www.mediafire...8ibzchhoboh0f2b

How to use:
SpoilerOpen up and you will see a window looking like the first picture;
Either enter the directory of the file you wish to create/open in the longer text box or click the button to the right of the longer text box to open a file browser.
If you are opening a file; ignore the WIDTH and HEIGHT boxes
If you are creating a file; set the WIDTH and HEIGHT of the picture in those fields.

click the Create or Open button depending on what you want to do, if nothing happens something went wrong.

If it went right, the original window should disappear and two more should appear, one is called "Tools" the other is your picture,
in your tools window you can set the color you are painting with and save the picture
To draw on the image just move your mouse around the screen and a box the color of you selected color in Tools should appear around the selected cell, click to color it in that color.

Thats it! press save to save, the box above the save button has the original directory in it but you can change it if you wish.

Go ahead if you want to, or pastebin me an example of your format for me to include it in the converter
matejdro #8
Posted 14 October 2012 - 12:35 PM
Wow there are like nine million paint programs now :)/>/>
billysback #9
Posted 14 October 2012 - 05:57 PM
The format is:
Spoiler

function getColor ( mctag )

		if mctag == "&0" then
				return 32768
		elseif mctag == "&f" then
				return 1
		elseif mctag == "&e" then
				return 16
		elseif mctag == "&a" then
				return colors.lime
		elseif mctag == "&b" then
				return colors.lightBlue
		elseif mctag == "&c" then
				return colors.red
		elseif mctag == "&d" then
				return colors.pink
		elseif mctag == "&1" then
				return colors.blue
		elseif mctag == "&2" then
				return colors.green
		elseif mctag == "&3" then
				return colors.cyan
		elseif mctag == "&4" then
				return colors.red
		elseif mctag == "&5" then
				return colors.purple
		elseif mctag == "&6" then
				return colors.orange
		elseif mctag == "&7" then
				return colors.lightGray
		elseif mctag == "&8" then
				return colors.gray
		elseif mctag == "&9" then
				return colors.cyan
		else
				return 1
		end
end

Note; this is copied of marumaru's pastebin as the converter I wrote is for Java, and thus would be rather unhelpful to you…
If your format follows a similar pattern just with no '&' in front of it then it would be easy for either of us to make a converter for this.
Cruor #10
Posted 14 October 2012 - 06:01 PM
The format is:
Spoiler

function getColor ( mctag )

		if mctag == "&0" then
				return 32768
		elseif mctag == "&f" then
				return 1
		elseif mctag == "&e" then
				return 16
		elseif mctag == "&a" then
				return colors.lime
		elseif mctag == "&b" then
				return colors.lightBlue
		elseif mctag == "&c" then
				return colors.red
		elseif mctag == "&d" then
				return colors.pink
		elseif mctag == "&1" then
				return colors.blue
		elseif mctag == "&2" then
				return colors.green
		elseif mctag == "&3" then
				return colors.cyan
		elseif mctag == "&4" then
				return colors.red
		elseif mctag == "&5" then
				return colors.purple
		elseif mctag == "&6" then
				return colors.orange
		elseif mctag == "&7" then
				return colors.lightGray
		elseif mctag == "&8" then
				return colors.gray
		elseif mctag == "&9" then
				return colors.cyan
		else
				return 1
		end
end

Note; this is copied of marumaru's pastebin as the converter I wrote is for Java, and thus would be rather unhelpful to you…
If your format follows a similar pattern just with no '&' in front of it then it would be easy for either of us to make a converter for this.

i meant you should link me to a picture saved in it :)/>/>
billysback #11
Posted 14 October 2012 - 07:11 PM
Oh, well here marumaru's example (its outputs the picture seen on the screen in the screenshots)
Spoiler

&f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &f &c &0 &1 &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &c &b &f &e &b &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &5 &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &b &f &f &f &f &f &f &0 &0 &0 &f &f &c &0 &f &c &0 &f &f &f &f &c &0 &f &c &0 &f &f &f &1 &f &f &6 &f &6 &0 &0 &f &f &f &0 &0 &f &f &f &f &f &f
&f &f &b &f &f &f &f &f &1 &f &f &7 &f &5 &f &f &5 &f &f &4 &f &f &5 &f &f &5 &f &f &4 &f &f &1 &f &f &6 &f &f &5 &f &f &f &1 &f &f &6 &f &f &f &f &f
&f &f &b &f &f &f &f &f &b &f &f &7 &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &6 &f &f &5 &f &f &f &0 &0 &0 &0 &f &f &f &f &f
&f &f &c &b &f &e &b &f &1 &f &f &7 &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &4 &f &f &4 &f &f &f &1 &f &f &f &f &f &f &f &f
&f &f &f &c &0 &1 &f &f &f &0 &0 &0 &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &d &f &f &6 &f &f &f &0 &0 &8 &f &f &f &0 &f &f &f &0 &0 &0 &f &f &f &f &f
&f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
Cruor #12
Posted 14 October 2012 - 07:17 PM
Oh, well here marumaru's example (its outputs the picture seen on the screen in the screenshots)
Spoiler

&f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &f &c &0 &1 &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &c &b &f &e &b &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &5 &f &f &f &f &f &f &f &f &f &f &f &f
&f &f &b &f &f &f &f &f &f &0 &0 &0 &f &f &c &0 &f &c &0 &f &f &f &f &c &0 &f &c &0 &f &f &f &1 &f &f &6 &f &6 &0 &0 &f &f &f &0 &0 &f &f &f &f &f &f
&f &f &b &f &f &f &f &f &1 &f &f &7 &f &5 &f &f &5 &f &f &4 &f &f &5 &f &f &5 &f &f &4 &f &f &1 &f &f &6 &f &f &5 &f &f &f &1 &f &f &6 &f &f &f &f &f
&f &f &b &f &f &f &f &f &b &f &f &7 &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &6 &f &f &5 &f &f &f &0 &0 &0 &0 &f &f &f &f &f
&f &f &c &b &f &e &b &f &1 &f &f &7 &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &4 &f &f &4 &f &f &f &1 &f &f &f &f &f &f &f &f
&f &f &f &c &0 &1 &f &f &f &0 &0 &0 &f &1 &f &f &d &f &f &6 &f &f &1 &f &f &d &f &f &6 &f &f &f &0 &0 &8 &f &f &f &0 &f &f &f &0 &0 &0 &f &f &f &f &f
&f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f &f

Looks almost the same as mine, adding it to the ToDo :)/>/>
lukeplechaty #13
Posted 17 October 2012 - 07:19 PM
it be good if you can get it to read bmp as well i have been trying but i have no luck hear have a look for you shef
Spoiler

byte=string.byte
insert=table.insert
function WORD(str,offset)
lo=byte(str,offset)
hi=byte(str,offset+1)
return hi*256+lo
end
function DWORD(str,offset)
lo=WORD(str,offset)
hi=WORD(str,offset+2)
return hi*65536+lo
end
function DrawBitmap(bytecode)
print(bytecode)
offset=1
Type = WORD(bytecode, offset)
if(Type ~= 0x4D42) then
print("Not a bitmap file (Invalid BMP magic value)")
return
end
OffBits = WORD(bytecode, offset+11)
offset = 15
Width = DWORD(bytecode, offset+4)
Height = DWORD(bytecode, offset+8)
BitCount = WORD(bytecode, offset+14)
Compression = DWORD(bytecode, offset+16)
print(OffBits.."n"..Width.."n"..Height.."n"..BitCount.."n"..Compression)
if(width >= 82) then
print("Only 82 Width/Y supported (It's "..Width..")")
return
end
if(Height >= 40) then
print("Only 40 Height/X supported (It's "..Height..")")
return
end
if(BitCount ~= 4) then
print("Only 4-bit bitmaps supported (It's "..BitCount.."bpp)")
return
end
if(Compression ~= 0) then
print("Only uncompressed bitmaps supported (Compression type is " .. Compression .. ")")
return
end
for y = Height-1, 0, -1 do
offset = OffBits + (Width*BitCount/8)*y + 1
for x = 0, Width-1 do
rgb = byte(bytecode,offset)
offset = offset + 1
DrawPoint(x, Height-y-1,rgb)
end
end
end
function locator(acton,looking)
line=0
this=string.byte(looking)
endline=string.len(acton)
while true do
if string.byte(acton,line)==this then
return line
end
if line==endline then return end
line=line+1
end
end
function Drawpoint(x,y,rgb)
y="0123456789ABCDEF"
x=locator(y,rgb)
mon = peripheral.wrap("right")
mon.setBackgroundColor(2^x)
mon.setCursorPos(x,y)
mon.write(" ")
end
function testBmp(args)
file=io.open(args,"r")
text=file:read("*a")
file:close()
DrawBitmap(text)
end
z={...}
testBmp(z[1])

ps. i have made you code work with pre3
Cruor #14
Posted 17 October 2012 - 08:30 PM
it be good if you can get it to read bmp as well i have been trying but i have no luck hear have a look for you shef
Spoiler

byte=string.byte
insert=table.insert
function WORD(str,offset)
lo=byte(str,offset)
hi=byte(str,offset+1)
return hi*256+lo
end
function DWORD(str,offset)
lo=WORD(str,offset)
hi=WORD(str,offset+2)
return hi*65536+lo
end
function DrawBitmap(bytecode)
print(bytecode)
offset=1
Type = WORD(bytecode, offset)
if(Type ~= 0x4D42) then
print("Not a bitmap file (Invalid BMP magic value)")
return
end
OffBits = WORD(bytecode, offset+11)
offset = 15
Width = DWORD(bytecode, offset+4)
Height = DWORD(bytecode, offset+8)
BitCount = WORD(bytecode, offset+14)
Compression = DWORD(bytecode, offset+16)
print(OffBits.."n"..Width.."n"..Height.."n"..BitCount.."n"..Compression)
if(width >= 82) then
print("Only 82 Width/Y supported (It's "..Width..")")
return
end
if(Height >= 40) then
print("Only 40 Height/X supported (It's "..Height..")")
return
end
if(BitCount ~= 4) then
print("Only 4-bit bitmaps supported (It's "..BitCount.."bpp)")
return
end
if(Compression ~= 0) then
print("Only uncompressed bitmaps supported (Compression type is " .. Compression .. ")")
return
end
for y = Height-1, 0, -1 do
offset = OffBits + (Width*BitCount/8)*y + 1
for x = 0, Width-1 do
rgb = byte(bytecode,offset)
offset = offset + 1
DrawPoint(x, Height-y-1,rgb)
end
end
end
function locator(acton,looking)
line=0
this=string.byte(looking)
endline=string.len(acton)
while true do
if string.byte(acton,line)==this then
return line
end
if line==endline then return end
line=line+1
end
end
function Drawpoint(x,y,rgb)
y="0123456789ABCDEF"
x=locator(y,rgb)
mon = peripheral.wrap("right")
mon.setBackgroundColor(2^x)
mon.setCursorPos(x,y)
mon.write(" ")
end
function testBmp(args)
file=io.open(args,"r")
text=file:read("*a")
file:close()
DrawBitmap(text)
end
z={...}
testBmp(z[1])

ps. i have made you code work with pre3

im sorry but i have no idea what you are even trying to say :P/>/> as for making it work with pre3 is silly easy, its just that i dont have time to update it. got to love school
matejdro #15
Posted 17 October 2012 - 08:32 PM
I think he wants you to make it work with actual bmp file if you upload it to in-game computer.
faubiguy #16
Posted 17 October 2012 - 08:46 PM
I've been making some code for writing ComputerCraft images to bmp files. Reading can't be too different.