cappuccino/cappuccino — Issue #1462: CALayer and canvas
Author: tuxedout
Created: 2012-02-23 12:10:56+00:00
State: open

I can't grab content of CALayer to send to server. CALayer's canvas returns empty image, when I'm trying to use something like this:

var dataURL = canvas.toDataURL("image/png");

Also CALayer has problem with setContents and getContents methods. More about it described here: https://github.com/cappuccino/cappuccino/issues/1419

I'm working on a project which requires small thumbnails of document pages (like thumbnails of layers in Photoshop), it has a main work area which is represented as CALayer. Implementation is done usinghttp://cappuccino.org/learn/documentation/interface_c_a_layer.html for reference. As declared in this doc "CALayer" has "setContents" and "contents" methods, but when I try to use them I get these problems:setContents - does nothingcontents returns nullBut I do not see any errors or warnings in js-console.

Also I tried to use html2canvas but all I get is an empty image again. I used this code:

$('body').html2canvas();
var canvas = $('canvas')[0];
var data = canvas.toDataURL('image/png').replace(/data:image\/png;base64,/, '');