nattyfix 2

This commit is contained in:
LunarEclipse 2024-04-28 15:16:30 +02:00
parent 7c871a6387
commit 8c8a01f1f1
2 changed files with 9 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import sys
import traceback
from typing import Dict, List, Optional, Sequence, Tuple, TypeAlias
import PIL.Image
import gi
gi.require_version("Gtk", "3.0")
@ -49,13 +50,12 @@ class PdfPage(Gtk.DrawingArea):
width = widget.get_allocated_width()
height = widget.get_allocated_height()
cr.set_source_rgba(255, 255, 255)
cr.paint()
sctx = widget.get_style_context()
Gtk.render_background(sctx, cr, 0, 0, width, height)
pix = self.page.get_pixmap(dpi=96, alpha=True) # type: ignore
mv: memoryview = pix.samples_mv
pix = self.page.get_pixmap(dpi=96) # type: ignore
img = PIL.Image.frombytes("RGBA" if pix.alpha else "RGB", [pix.width, pix.height], pix.samples)
img.putalpha(1)
mv: memoryview = memoryview(bytearray(img.tobytes()))
ims = cairo.ImageSurface.create_for_data(mv, cairo.Format.RGB24, pix.width, pix.height)
cr.set_source_surface(ims, 0, 0)
cr.paint()

View File

@ -11,11 +11,14 @@ python = ">=3.11,<3.13"
pygobject = "^3.48.2"
tabula-py = "^2.9.0"
PyMuPDF = "^1.24.0"
pillow = "^10.3.0"
#pdfplumber = "^0.11.0"
#PySide6 = "^6.6.3" # qt
[tool.poetry.group.dev.dependencies]
pygobject-stubs = "^2.11.0" # this is actually broken lol
# this is actually broken lol, fix by running following in venv:
# pip uninstall pygobject-stubs && pip install pygobject-stubs --no-cache-dir --config-settings=config=Gtk3,Gdk3,Soup2
pygobject-stubs = "^2.11.0"
[build-system]
requires = ["poetry-core"]