Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Return raw image buffer instead of an object #2262

Merged
merged 2 commits into from
Sep 4, 2015
Merged

Return raw image buffer instead of an object #2262

merged 2 commits into from
Sep 4, 2015

Conversation

bsudekum
Copy link

@bsudekum bsudekum commented Sep 4, 2015

continuation of #2258

Currently we're returning an object from the map.render function:

{
  "height": 60,
  "width": 60,
  "pixels": "<SlowBuffer 34 43 45 ...>"
}

This is overkill since the height and width are already know because they are necessary to render an image in the first place. Although this is a small change, the system needs to allocate memory to do these processes which can add up. This change would no longer return an object but rather just the raw image buffer.

/cc @mikemorris @springmeyer @jfirebaugh

t.ok(data.pixels);
t.equal(data.width, 512);
t.equal(data.height, 512);
t.ok(pixels);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a t.ok(pixels instanceof Buffer) assertion here? I've been meaning to add that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also t.equal(pixels.length, 512 * 512 * 4).

bsudekum pushed a commit that referenced this pull request Sep 4, 2015
Return raw image buffer instead of an object
@bsudekum bsudekum merged commit 7789324 into master Sep 4, 2015
@bsudekum bsudekum deleted the no-object branch September 4, 2015 20:17
@mikemorris mikemorris added the Node.js node-mapbox-gl-native label Sep 10, 2015
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this pull request Nov 6, 2015
Return raw image buffer instead of an object
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Node.js node-mapbox-gl-native
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants