Skip to content

Enhanced image rendering methods#37

Open
dhendo wants to merge 1 commit intodeanmao:masterfrom
dhendo:qt5-test-local
Open

Enhanced image rendering methods#37
dhendo wants to merge 1 commit intodeanmao:masterfrom
dhendo:qt5-test-local

Conversation

@dhendo
Copy link

@dhendo dhendo commented Jul 17, 2013

Added new methods to the native module to allow:

  • captureBytes() - alternative to capture - will return a node Buffer with image data rather than saving to file.
  • renderSnippet() - render a snippet of HTML rather than a remote URL.
  • clipToElement() - clip the rendering to a given element (by css selector). Will work with capture() and captureBytes()

perform() can now also take an option "html" instead of "url" to load the html directly.

A combination of these new methods will allow a streamlined pipeline if you wish to render the contents of a locally held snippet of html and return it directly via a webserver.
This will avoid a number of unnecessary file save/loads or converting image data to Base64.

- captureBytes() - alternative to capture - will return a node Buffer with image data rather than saving to file.
- renderSnippet() - render a snippet of HTML rather than a remote URL.
- clipToElement() - clip the rendering to a given element (by css selector). Will work with capture() and captureBytes()

A combination of these new methods will allow a streamlined pipeline if you wish to render the contents of a locally held snippet of html and return it directly via a webserver.
This will avoid a number of unnecessary file save/loads or converting image data to Base64.
@dhendo
Copy link
Author

dhendo commented Jul 17, 2013

Notes:

  • These changes were coded against the qt 4.8 version, and on the whole worked OK. I've been having issues getting qt5 built on Ubuntu 12.04, so I haven't been able to regenerate the .moc file.
  • There are a couple of example files that exercise the new methods.
  • On reflection, renderSnippet is probably badly named. loadSnippet, loadHtml or setHtml maybe?
  • I have been seeing some issues running renderSnippet multiple times in a row. I think this is a node/libuv callback related issue. I'll put a gist up with code demonstrating this.

@dhendo
Copy link
Author

dhendo commented Jul 17, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant