Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows fullscreen fix #19

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ __pycache__/
/media
/presentation

/.vscode
/.vscode
slides/
27 changes: 25 additions & 2 deletions manim_presentation/present.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import argparse
from enum import Enum
import platform
import ctypes



class Config:
@classmethod
Expand Down Expand Up @@ -176,7 +179,7 @@ def __init__(self, presentations, start_paused=False, fullscreen=False):
self.last_time = now()

if fullscreen:
cv2.namedWindow("Video", cv2.WND_PROP_FULLSCREEN)
cv2.namedWindow("Video", cv2.WINDOW_FREERATIO)
cv2.setWindowProperty("Video", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)

@property
Expand All @@ -203,7 +206,27 @@ def run(self):
def show_video(self):
self.lag = now() - self.last_time
self.last_time = now()
cv2.imshow("Video", self.lastframe)

frame = self.lastframe

if platform.system() == "Windows":
user32 = ctypes.windll.user32
screen_width, screen_height = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)

frame_height, frame_width, _ = frame.shape

scaleWidth = float(screen_width)/float(frame_width)
scaleHeight = float(screen_height)/float(frame_height)

if scaleHeight>scaleWidth:
imgScale = scaleWidth
else:
imgScale = scaleHeight

newX,newY = frame.shape[1]*imgScale, frame.shape[0]*imgScale
frame = cv2.resize(frame,(int(newX),int(newY)))

cv2.imshow("Video", frame)

def show_info(self):
info = np.zeros((130, 420), np.uint8)
Expand Down