mirror of
https://github.com/jtgans/g13gui.git
synced 2025-06-20 08:23:50 -04:00
Merge 7584222746
into a6462488dc
This commit is contained in:
commit
89f32ef800
45
g13gui.geany
Normal file
45
g13gui.geany
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
[editor]
|
||||||
|
line_wrapping=false
|
||||||
|
line_break_column=72
|
||||||
|
auto_continue_multiline=true
|
||||||
|
|
||||||
|
[file_prefs]
|
||||||
|
final_new_line=true
|
||||||
|
ensure_convert_new_lines=false
|
||||||
|
strip_trailing_spaces=false
|
||||||
|
replace_tabs=false
|
||||||
|
|
||||||
|
[indentation]
|
||||||
|
indent_width=4
|
||||||
|
indent_type=0
|
||||||
|
indent_hard_tab_width=8
|
||||||
|
detect_indent=false
|
||||||
|
detect_indent_width=true
|
||||||
|
indent_mode=2
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name=g13gui
|
||||||
|
base_path=/home/duncan/projects/g13gui
|
||||||
|
description=
|
||||||
|
file_patterns=
|
||||||
|
|
||||||
|
[long line marker]
|
||||||
|
long_line_behaviour=1
|
||||||
|
long_line_column=72
|
||||||
|
|
||||||
|
[files]
|
||||||
|
current_page=0
|
||||||
|
FILE_NAME_0=1386;Python;0;EUTF-8;1;1;0;%2Fhome%2Fduncan%2Fprojects%2Fg13gui%2Fg13gui%2Fg13%2Fdisplaydevice.py;0;4
|
||||||
|
|
||||||
|
[VTE]
|
||||||
|
last_dir=/home/duncan
|
||||||
|
|
||||||
|
[prjorg]
|
||||||
|
expanded_paths=/home/duncan/projects/g13gui/g13gui/g13;
|
||||||
|
source_patterns=*.c;*.C;*.cpp;*.cxx;*.c++;*.cc;*.m;
|
||||||
|
header_patterns=*.h;*.H;*.hpp;*.hxx;*.h++;*.hh;
|
||||||
|
ignored_dirs_patterns=.*;CVS;
|
||||||
|
ignored_file_patterns=*.o;*.obj;*.a;*.lib;*.so;*.dll;*.lo;*.la;*.class;*.jar;*.pyc;*.mo;*.gmo;
|
||||||
|
generate_tag_prefs=0
|
||||||
|
show_empty_dirs=true
|
||||||
|
external_dirs=
|
@ -11,31 +11,36 @@ class DisplayMetrics(object):
|
|||||||
|
|
||||||
|
|
||||||
def ImageToLPBM(image):
|
def ImageToLPBM(image):
|
||||||
"""Simple function to convert a PIL Image into LPBM format."""
|
"""Simple function to convert a PIL Image into LPBM format"""
|
||||||
|
|
||||||
i = PIL.PyAccess.new(image, readonly=True)
|
# Ensure the image is in grayscale ('L') or monochrome ('1') mode
|
||||||
|
image = image.convert('1') # Convert to monochrome (1-bit) if not already
|
||||||
|
pixels = image.load() # Access the pixel data directly
|
||||||
bio = BytesIO()
|
bio = BytesIO()
|
||||||
|
|
||||||
maxBytes = (DisplayMetrics.WIDTH_PIXELS *
|
# Assuming DisplayMetrics with fixed width and height
|
||||||
DisplayMetrics.HEIGHT_PIXELS // 8)
|
maxBytes = (DisplayMetrics.WIDTH_PIXELS * DisplayMetrics.HEIGHT_PIXELS) // 8
|
||||||
|
|
||||||
row = 0
|
row = 0
|
||||||
col = 0
|
col = 0
|
||||||
|
|
||||||
for byteNum in range(0, maxBytes):
|
for byteNum in range(0, maxBytes):
|
||||||
b = int()
|
b = 0
|
||||||
|
|
||||||
if row == 40:
|
# Adjust the number of rows processed in a byte based on row position
|
||||||
maxSubrow = 3
|
maxSubrow = 3 if row == 40 else 8
|
||||||
else:
|
|
||||||
maxSubrow = 8
|
|
||||||
|
|
||||||
for subrow in range(0, maxSubrow):
|
for subrow in range(maxSubrow):
|
||||||
b |= i[col, row + subrow] << subrow
|
# Get pixel value at (col, row + subrow) and shift into position
|
||||||
|
pixel_value = pixels[col, row + subrow]
|
||||||
|
b |= (1 if pixel_value == 0 else 0) << subrow # 0 = black, 1 = white in '1' mode
|
||||||
|
|
||||||
|
# Write the byte to the output buffer
|
||||||
bio.write(struct.pack('<B', b))
|
bio.write(struct.pack('<B', b))
|
||||||
|
|
||||||
|
# Update column and row positions
|
||||||
col += 1
|
col += 1
|
||||||
if (col % 160) == 0:
|
if col % DisplayMetrics.WIDTH_PIXELS == 0:
|
||||||
col = 0
|
col = 0
|
||||||
row += 8
|
row += 8
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user