Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Bitmap-Write-a-PPM-file/Tcl/bitmap-write-a-ppm-file.tcl
Normal file
19
Task/Bitmap-Write-a-PPM-file/Tcl/bitmap-write-a-ppm-file.tcl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package require Tk
|
||||
|
||||
proc output_ppm {image filename} {
|
||||
$image write $filename -format ppm
|
||||
}
|
||||
|
||||
set img [newImage 150 150]
|
||||
fill $img red
|
||||
setPixel $img green 40 40
|
||||
output_ppm $img filename.ppm
|
||||
|
||||
# check the file format:
|
||||
set fh [open filename.ppm]
|
||||
puts [gets $fh] ;# ==> P6
|
||||
puts [gets $fh] ;# ==> 150 150
|
||||
puts [gets $fh] ;# ==> 255
|
||||
binary scan [read $fh 3] c3 pixel
|
||||
foreach colour $pixel {puts [expr {$colour & 0xff}]} ;# ==> 255 \n 0 \n 0 \n
|
||||
close $fh
|
||||
Loading…
Add table
Add a link
Reference in a new issue