GreyScale Converter
Author |
Message |
DIIST
|
Posted: Sun Dec 18, 2005 5:24 pm Post subject: GreyScale Converter |
|
|
This program converts colour images to black and white! Something i did over the weekend! code: | /*****
Name: Thuvarrakan Ruban
Date: December 18 2005
Purpose: To convert colour images to black and white!
*****/
proc convert (fname, save : string)
var temp : int := Pic.FileNew (fname)
var res : string := "graphics:" + intstr (Pic.Width (temp)) + ";" + intstr (Pic.Height (temp))
View.Set (res)
Pic.Draw (temp, 0, 0, picCopy)
for x : 0 .. maxcolor /*Sets all the standard colors to shades of black for the purpose of the conversion!*/
RGB.SetColor (x, x / maxcolor, x / maxcolor, x / maxcolor)
end for
for x : 0 .. maxx
for y : 0 .. maxy
drawdot (x, y, whatdotcolor (x, y))
end for
end for
Pic.ScreenSave (0, 0, maxx - 1, maxy - 1, save)
Pic.Free (temp)
end convert
/******************Main Program!!!*******************/
var op : int := Window.Open ("graphics:640;480,nobuttonbar,title:Black and White Conversions") /*Opens Window!*/
var fname, filesavename : string
put "Enter the name of picture file(eg,sample.jpg)"
get fname
put "Enter the name you wish to save it as (eg,thuvs.bmp)"
get filesavename
convert (fname, filesavename) /*Function Call*/
Window.Close (op)
/**************End of Main Program!!!****************/
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cervantes
|
Posted: Sun Dec 18, 2005 7:49 pm Post subject: (No subject) |
|
|
I see you've modified the colour pallete. Good work!
Just a note:
code: |
var pix : int:=0
for x : 0 .. maxx
for y : 0 .. maxy
pix := whatdotcolor (x, y)
drawdot (x, y, pix)
end for
end for |
could be changed to:
code: |
for x : 0 .. maxx
for y : 0 .. maxy
drawdot (x, y, whatdotcolor (x, y))
end for
end for |
|
|
|
|
|
|
DIIST
|
Posted: Sun Dec 18, 2005 9:26 pm Post subject: (No subject) |
|
|
Thanks, i updated the file! |
|
|
|
|
|
Shyfire
|
Posted: Sun Dec 18, 2005 11:02 pm Post subject: (No subject) |
|
|
thats awsome thanks man it will come in handy |
|
|
|
|
|
ecliptical
|
Posted: Mon Dec 19, 2005 2:29 pm Post subject: (No subject) |
|
|
Ya good work... I would also probably remove the get statements so that you just input the files directly
code: |
convert ("sample.jpg", "bwd.bmp")
|
|
|
|
|
|
|
|
|