Code Monkey home page Code Monkey logo

Comments (6)

matiasmicheletto avatar matiasmicheletto commented on August 27, 2024

Happened the same to me. Using the android emulator (Nexus 5 API 22) the canvas is visible, but not in my smartphone (android 6.0.1).

from cordova-screenshot.

jjosef avatar jjosef commented on August 27, 2024

Same problem

from cordova-screenshot.

matiasmicheletto avatar matiasmicheletto commented on August 27, 2024

A way to overcome this is using a img element instead of a canvas, and put a canvas capture as the src attribute of the image.

from cordova-screenshot.

satheeq avatar satheeq commented on August 27, 2024

@matiasmicheletto is that supported by the plugin?

from cordova-screenshot.

matiasmicheletto avatar matiasmicheletto commented on August 27, 2024

@satheeq The plugin works well with different html elements but somehow it fails when capturing canvas drawings. Because there is no problem on capturing img images you can use one of these instead of a canvas.
Depending on whether the canvas has dinamic or static content, the img element can be visible and the canvas an auxiliary hide element or the img be an auxiliary element that turns visible only at the time of taking the capture.
For example:

html file:
...
<img id="auximg"/>
...

js file:
...
var cvs = document.createElement('canvas'); // Create a canvas or use existing
...
// Draw on the canvas
...
var auximg = document.getElementById('auximg'); // Get the img element
// Set the image dimensions (not sure if required)
auximg.width = cvs.width;
auximg.height = cvs.height;
auximg.src = cvs.toDataURL(); // Pass the canvas content to the img element
...

If the img is an auxiliary element that turns visible only during the screen capture, it is necessary to give a few milliseconds before perfoming the screenshot. Use setTimeout.
Hope this help.

from cordova-screenshot.

satheeq avatar satheeq commented on August 27, 2024

That worked well.
Thanks alot @matiasmicheletto

from cordova-screenshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.