OUTPUT BUFFER:
#!/usr/local/bin/wish # Conversion xbm <----> string proc strimj2xbm {strimj {tag "i"}} { set width [string length [lindex $strimj 0]] set height [llength $strimj] set bytes {} foreach line [string map {. 0} $strimj] { regsub -all {[^0]} $line 1 line ;# black pixel foreach bin [split [binary format b* $line] ""] { lappend bytes [scan $bin %c] } } set res "#define ${tag}_width $width\n#define ${tag}_height $height\n" append res "#define ${tag}_x_hot 7\n#define ${tag}_y_hot 7\n" append res "static unsigned char ${tag}_bits\[\] = {" foreach b $bytes { lappend Lb "0x[format %02x $b]" } append res "\n[join $Lb ", "]\n};\n" } proc strimj2image {strimj {fg black}} { image create bitmap -data [strimj2xbm $strimj] -foreground $fg } proc xbm2strimj Lxbm { set xbm [join $Lxbm "\n"] regexp {width +(\d+).+\{(.+)\}} $xbm tmp width data set res "" set line "" foreach byte [string map {, " "} $data] { if {[string length $line] > $width-7} { append res [string range $line 0 [expr {$width-1}]]\n set line "" } binary scan [format %c $byte] b* bits append line $bits } if {$line ne ""} { append res [string range $line 0 [expr {$width-1}]]\n } string map {0 . 1 @} $res } if {! [llength $argv]} { puts "\nUSAGE :" puts "\t xbmc