Skip to content

Image.getRawData method - #907

Closed
basvanmeurs wants to merge 4 commits into
Automattic:masterfrom
basvanmeurs:master
Closed

Image.getRawData method#907
basvanmeurs wants to merge 4 commits into
Automattic:masterfrom
basvanmeurs:master

Conversation

@basvanmeurs

@basvanmeurs basvanmeurs commented Apr 24, 2017

Copy link
Copy Markdown

Background info: WPE UI Framework depends on node-canvas for creating text bitmaps, rounded edges and image parsing.

When you need to read parsed raw ARGB image data, you need to load the image, then draw it on a canvas and convert it to a buffer:

        var img = new Canvas.Image();
        img.src = data;
        var canvas = new Canvas(img.width, img.height);
        var ctx = canvas.getContext('2d');
        ctx.drawImage(img, 0, 0, img.width, img.height);
        var buffer = canvas.toBuffer('raw');

This is an unnecessary double copy of the data. This pull request contains a new method: Image.getRawData, which returns the buffer directly:

        var img = new Canvas.Image();
        img.src = data;
        var buffer = img.getRawData();

This allows for a more efficient usage of Canvas.Image.

We'd appreciate it if you'd merge this into the node-canvas module!

basvanmeurs added a commit to rdkcentral/Lightning that referenced this pull request Apr 24, 2017
- texture process: prevent having to pre-process data
- use image data directly (awaiting node-canvas pull request Automattic/node-canvas#907)
Comment thread lib/context2d.js
, CanvasPattern = canvas.CanvasPattern
, ImageData = canvas.ImageData;

var parseCssFont = require('parse-css-font');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of this should be it's own PR, it also should remove the dependencies from the package.json...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realise that it would be part of the pull request.. that was not intentional.

@zbjornson

Copy link
Copy Markdown
Collaborator

@basvanmeurs if you still want this to be merged, can you clean up the branch so it contains only the relevant changes please per @LinusU's feedback?

@zbjornson

Copy link
Copy Markdown
Collaborator

(I guess this is replaced by #1256)

@zbjornson zbjornson closed this Sep 25, 2018
@basvanmeurs

Copy link
Copy Markdown
Author

Correct, it can be closed ;-) Thanks zbjornson!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants