File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+
3+ text = open ("text.txt" )
4+ if os .path .isfile ("textimage.bmp" )== True :
5+ os .remove ("textimage.bmp" )
6+
7+ textimage = open ("textimage.bmp" ,'ab' )
8+ text .seek (0 ,0 )
9+
10+ headerbytes = b'BM\x8a \xc0 \x12 \x00 \x00 \x00 \x00 \x00 \x8a \x00 \x00 \x00 |\x00 \x00 \x00 \x80 \x02 \x00 \x00 \xe0 \x01 \x00 \x00 \x01 \x00 \x00 \x03 \x00 \x00 \x00 \x00 \xc0 \x12 \x00 #.\x00 \x00 #.\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \xff \x00 \x00 \xff \x00 \x00 \xff \x00 \x00 \x00 \x00 \x00 \x00 \xff BGRs\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 '
11+ textimage .write (headerbytes )
12+
13+
14+ for pixels in range (1 ,1600000 ):
15+ char = text .read (1 )
16+ if char == '' :
17+ text .seek (0 ,0 )
18+ else :
19+ asciicode = ord (char )
20+ pixarray = asciicode .to_bytes (2 ,'big' )
21+ textimage .write (pixarray )
22+
23+ text .close ()
24+ textimage .close ()
25+
26+
You can’t perform that action at this time.
0 commit comments