Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
73 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
""" | ||
|
||
from pi3d.constants import * | ||
from pi3d.constants import __version__ | ||
|
||
from pi3d import Display | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ void main(void) { | |
} | ||
} | ||
gl_FragColor = texc * 0.04; | ||
gl_FragColor.a = 1.0; | ||
gl_FragColor.a = unif[5][2]; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
import ctypes | ||
import numpy as np | ||
from PIL import Image | ||
|
||
from pi3d.constants import * | ||
from pi3d.util import Log | ||
|
||
LOGGER = Log.logger(__name__) | ||
|
||
def screenshot(filestring): | ||
def screenshot(filestring=None): | ||
""" | ||
Save whatever's in the display to a file. | ||
Will save whatever has been rendered since the last call to Display.clear(). | ||
The file will be saved in the top-level directory if you don't add a path | ||
The file will be saved in the same directory as the app if you don't add a path | ||
to it! | ||
If this function is called without any argument then it will not save to | ||
file and will return a numpy array of the screen. The array and file, if | ||
saved, will have the alpha values removed. | ||
""" | ||
|
||
from pi3d.Display import Display | ||
LOGGER.info('Taking screenshot of "%s"', filestring) | ||
|
||
w, h = Display.INSTANCE.width, Display.INSTANCE.height | ||
size = h * w * 4 | ||
img = (ctypes.c_char * size)() | ||
opengles.glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ctypes.byref(img)) | ||
|
||
im = Image.frombuffer('RGBA', (w, h), img, 'raw', 'RGBA', 0, 1) | ||
im = im.transpose(Image.FLIP_TOP_BOTTOM) | ||
im.save(filestring) | ||
img = np.zeros((h, w, 4), dtype=np.uint8) | ||
opengles.glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.ctypes.data_as(ctypes.POINTER(ctypes.c_ubyte))) | ||
img = img[::-1,:,:3].copy() | ||
if filestring is None: | ||
return img | ||
|
||
im = Image.frombuffer('RGB', (w, h), img, 'raw', 'RGB', 0, 1) | ||
im.save(filestring, quality=90) | ||
|