
-----------------------------------
DIIST
Sun Dec 18, 2005 5:24 pm

GreyScale Converter
-----------------------------------
This program converts colour images to black and white! Something i did over the weekend! 8-)/*****
 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!!!****************/


-----------------------------------
Cervantes
Sun Dec 18, 2005 7:49 pm


-----------------------------------
I see you've modified the colour pallete.  Good work! :)

Just a note:

    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:

    for x : 0 .. maxx
	for y : 0 .. maxy
	    drawdot (x, y, whatdotcolor (x, y))
	end for
    end for

-----------------------------------
DIIST
Sun Dec 18, 2005 9:26 pm


-----------------------------------
:D Thanks, i updated the file!

-----------------------------------
Shyfire
Sun Dec 18, 2005 11:02 pm


-----------------------------------
thats awsome thanks man it will come in handy

-----------------------------------
ecliptical
Mon Dec 19, 2005 2:29 pm


-----------------------------------
Ya good work... I would also probably remove the get statements so that you just input the files directly

convert ("sample.jpg", "bwd.bmp") 

