{"action":"created","issue":{"url":"https://api.github.com/repos/vispy/vispy/issues/1478","repository_url":"https://api.github.com/repos/vispy/vispy","labels_url":"https://api.github.com/repos/vispy/vispy/issues/1478/labels{/name}","comments_url":"https://api.github.com/repos/vispy/vispy/issues/1478/comments","events_url":"https://api.github.com/repos/vispy/vispy/issues/1478/events","html_url":"https://github.com/vispy/vispy/issues/1478","id":319598135,"number":1478,"title":"Rendering issue when exporting to image","user":{"login":"JPFrancoia","id":2399090,"avatar_url":"https://avatars1.githubusercontent.com/u/2399090?v=4","gravatar_id":"","url":"https://api.github.com/users/JPFrancoia","html_url":"https://github.com/JPFrancoia","followers_url":"https://api.github.com/users/JPFrancoia/followers","following_url":"https://api.github.com/users/JPFrancoia/following{/other_user}","gists_url":"https://api.github.com/users/JPFrancoia/gists{/gist_id}","starred_url":"https://api.github.com/users/JPFrancoia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JPFrancoia/subscriptions","organizations_url":"https://api.github.com/users/JPFrancoia/orgs","repos_url":"https://api.github.com/users/JPFrancoia/repos","events_url":"https://api.github.com/users/JPFrancoia/events{/privacy}","received_events_url":"https://api.github.com/users/JPFrancoia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-02T15:19:44Z","updated_at":"2018-05-02T15:31:32Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi,\r\n\r\nI'm developing some sort of stl viewer. STL are simple meshes, so it's quite straightfoward to build such an app. Here is my code:\r\n\r\n```python\r\n#!/usr/bin/python\r\n# coding: utf-8\r\n\r\nimport os\r\nfrom vispy import app, geometry, gloo\r\nimport vispy.scene\r\nfrom vispy.scene import visuals\r\nfrom vispy.app import use_app\r\nfrom typing import Tuple, Union\r\nfrom vispy.visuals.filters import Alpha\r\nimport vispy.io\r\n\r\n\r\n# TODO: remove trimesh, vispy should soon be able to load STL files\r\nimport trimesh\r\n\r\nuse_app('PyQt5')\r\n\r\n\r\nclass STLViewer(vispy.scene.SceneCanvas):\r\n\r\n    def __init__(self, size: Tuple[int, int]=(800, 500)):\r\n\r\n        \"\"\"\r\n        size is the size in pixels (x, y).\r\n        \"\"\"\r\n\r\n        vispy.scene.SceneCanvas.__init__(self, keys='interactive',\r\n                                         size=size, bgcolor='white')\r\n\r\n        # Unfreeze the class, so adding attributes is possible\r\n        self.unfreeze()\r\n\r\n        # Create a dict to store several meshes\r\n        # Meshes are stored with their names so they can be reloaded/reviewed\r\n        # namely\r\n        self.meshes = dict()\r\n\r\n        # Add an 'arcball' camera\r\n        self.view = self.central_widget.add_view()\r\n        self.view.camera = 'arcball'\r\n\r\n        # Freeze the class again. Might not be necessary\r\n        self.freeze()\r\n\r\n\r\n    def viewMesh(self, file_name: str):\r\n\r\n        \"\"\"\r\n        Will load the file file_name in the STL viewer. If the mesh didn't\r\n        exist before, it will be created. Else, it will be updated\r\n        \"\"\"\r\n\r\n        # file_name is passed wo extension, so add .stl\r\n        file_name = file_name + \".stl\"\r\n\r\n        file_to_view = os.path.join(file_name)\r\n\r\n        try:\r\n            # Load the stl file. Works with binary or ascii stl files\r\n            mesh = trimesh.load(file_to_view)\r\n            mdata = geometry.MeshData(mesh.vertices, mesh.faces)\r\n\r\n        except Exception as e:\r\n            return\r\n\r\n        # Try to update the mesh, if it doesn't exist, create it\r\n        try:\r\n            self.meshes[file_name].set_data(meshdata=mdata)\r\n        except KeyError:\r\n            # Create a Mesh visual, with the view as parent\r\n            self.meshes[file_name] = visuals.Mesh(meshdata=mdata,\r\n                                                  shading='flat',\r\n                                                  parent=self.view.scene)\r\n\r\n\r\n    def screenshot(self):\r\n\r\n        img = self.render()\r\n\r\n        vispy.io.write_png(\"wonderful.png\", img)\r\n\r\n        pass\r\n\r\n\r\n    def on_mouse_release(self, event):\r\n\r\n        self.screenshot()\r\n\r\n\r\nif __name__ == '__main__':\r\n    win = STLViewer()\r\n    win.viewMesh(\"beaker\")\r\n    win.show()\r\n\r\n    import sys\r\n    if sys.flags.interactive != 1:\r\n        app.run()\r\n        print(app)\r\n```\r\n\r\nI subclassed on_mouse_release to take a screenshot. I simply render the canvas to an image. The problem is that there is some sort of rendering/transparency glitch in the image:\r\n\r\nMy canvas:\r\n\r\n![screen](https://user-images.githubusercontent.com/2399090/39532283-7869d028-4e24-11e8-96a0-365ffa106a89.png)\r\n\r\nThe outputed image:\r\n\r\n![wonderful](https://user-images.githubusercontent.com/2399090/39532311-86e64cd0-4e24-11e8-88f3-a57974c3ab34.png)\r\n\r\nI have the latest version of vispy, cloned from master. Is it a known issue, is it possible to fix it ?\r\n\r\nCheers"},"comment":{"url":"https://api.github.com/repos/vispy/vispy/issues/comments/386019681","html_url":"https://github.com/vispy/vispy/issues/1478#issuecomment-386019681","issue_url":"https://api.github.com/repos/vispy/vispy/issues/1478","id":386019681,"user":{"login":"JPFrancoia","id":2399090,"avatar_url":"https://avatars1.githubusercontent.com/u/2399090?v=4","gravatar_id":"","url":"https://api.github.com/users/JPFrancoia","html_url":"https://github.com/JPFrancoia","followers_url":"https://api.github.com/users/JPFrancoia/followers","following_url":"https://api.github.com/users/JPFrancoia/following{/other_user}","gists_url":"https://api.github.com/users/JPFrancoia/gists{/gist_id}","starred_url":"https://api.github.com/users/JPFrancoia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JPFrancoia/subscriptions","organizations_url":"https://api.github.com/users/JPFrancoia/orgs","repos_url":"https://api.github.com/users/JPFrancoia/repos","events_url":"https://api.github.com/users/JPFrancoia/events{/privacy}","received_events_url":"https://api.github.com/users/JPFrancoia/received_events","type":"User","site_admin":false},"created_at":"2018-05-02T15:31:32Z","updated_at":"2018-05-02T15:31:32Z","author_association":"CONTRIBUTOR","body":"I tried with PyQt4 and pyglet, same problem."}}
{"actor":{"display_login":"JPFrancoia"}}