//// //// LOAD_PHOTO.DBN //// //// Warren Sack //// February 2003 //// //// Load a DBN encoded photo file and it will be //// output to the paper. //// To create a DBN encoded photo, run the Java //// application JPG2DBN // Example DBN encoded photo load C:\Backup\UCSC\170A\Software\einstein.dbn set NumberOfRows 25 set NumberOfColumns 25 set SquareWidth 4 set SquareHeight 4 number row Square { value ((Square - 1) / NumberOfColumns) } number column Square { value ((Square - 1) % NumberOfColumns) } command paintSquare Square Color { set RedPortion (Color / 10000) set GreenPortion ((Color - (RedPortion*10000)) / 100) set BluePortion (Color - (RedPortion*10000) - (GreenPortion*100)) set Row set Column set LeftPixel (SquareWidth * Column) set BottomPixel (SquareHeight * Row) repeat X 0 (SquareWidth - 1) { repeat Y 0 (SquareHeight - 1) { set [(LeftPixel + X) (BottomPixel + Y) red] RedPortion set [(LeftPixel + X) (BottomPixel + Y) green] GreenPortion set [(LeftPixel + X) (BottomPixel + Y) blue] BluePortion } } } command repaint { repeat Square 1 (NumberOfRows * NumberOfColumns) { paintSquare Square } } paper 0 repaint