Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image support #4

Closed
tj opened this issue Oct 1, 2010 · 12 comments
Closed

Image support #4

tj opened this issue Oct 1, 2010 · 12 comments

Comments

@tj
Copy link
Contributor

tj commented Oct 1, 2010

best to mirror the DOM api with onload etc

@ghost
Copy link

ghost commented Nov 6, 2010

+1 for supporting drawImage() and getData()

At the moment to read image data into our game server (heightmaps for generating terrain) we're delegating the canvas work out to a "worker" client but this is less than optimal and severely increases the complexity of the task.

Alternatively, if anyone knows of a simple way to sample an image (read pixel colors) in node.js, we'd appreciate the advice :)

@tj
Copy link
Contributor Author

tj commented Nov 15, 2010

added Image / drawImage()

@ghost
Copy link

ghost commented Nov 16, 2010

playing with this now ^w^

@tj
Copy link
Contributor Author

tj commented Nov 16, 2010

let me know if you come across bugs, there are likely a few :)

@ghost
Copy link

ghost commented Nov 16, 2010

is drawImage supposed to work?

here's a screenshot of the visual tests running in chrome...

http://awesomescreenshot.com/0303k2kfa

i tried webkit, firefox etc just in case (although I'm convinced the browser shouldn't make a difference)

code ran on server-side is...

function (ctx, done){
  var img = new Image;
  img.onload = function(){
    ctx.drawImage(img, 0, 0);
    done();
  };
  img.src = '/Users/pyrotechnick/node-canvas/test/public/state.png';
}

so your path-replacement seems to have worked correctly. and yes this file (state.png) definitely exists

btw this is cairo 1.8.10

@ghost
Copy link

ghost commented Nov 16, 2010

okay i've just found this...

#if CAIRO_VERSION_MINOR < 10
  return ThrowException(Exception::Error(String::New("drawImage() needs cairo >= 1.10.0")));
#else

i used homebrew to install cairo and it seems to only have a recipe to 1.8.10

installing manually now...

@tj
Copy link
Contributor Author

tj commented Nov 16, 2010

yeah, homebrew sucks lol. I would like to have a backport for older versions

@ghost
Copy link

ghost commented Nov 16, 2010

hell yeah. it's all good with cairo 1.10.0

@ghost
Copy link

ghost commented Nov 16, 2010

i'll patch homebrew if i can. the warning

#if CAIRO_VERSION_MINOR < 10
  return ThrowException(Exception::Error(String::New("drawImage() needs cairo >= 1.10.0")));
#else

isn't being triggered in my environment. best warn people another way perhaps. or make a note of it in the README

@tj
Copy link
Contributor Author

tj commented Nov 16, 2010

hm, weird... should work fine, I will have to revert my cairo version and try stuff out

@ghost
Copy link

ghost commented Nov 16, 2010

it should come up in console at compile time right? this was my output with cairo 1.8.10

node-canvas pyrotechnick$ node-waf configure build
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : ok /usr/local/lib/node 
Checking for node prefix                 : ok /usr/local 
Checking for cairo                       : yes 
'configure' finished successfully (0.573s)
Waf: Entering directory `/Users/pyrotechnick/node-canvas/build'
[1/8] cxx: src/Canvas.cc -> build/default/src/Canvas_1.o
[2/8] cxx: src/CanvasGradient.cc -> build/default/src/CanvasGradient_1.o
[3/8] cxx: src/CanvasRenderingContext2d.cc -> build/default/src/CanvasRenderingContext2d_1.o
[4/8] cxx: src/Image.cc -> build/default/src/Image_1.o
../src/Image.cc:169: warning: ‘int EIO_Load(eio_req*)’ defined but not used
../src/Image.cc:180: warning: ‘int EIO_AfterLoad(eio_req*)’ defined but not used
[6/8] cxx: src/init.cc -> build/default/src/init_1.o
[5/8] cxx: src/ImageData.cc -> build/default/src/ImageData_1.o
[7/8] cxx: src/PixelArray.cc -> build/default/src/PixelArray_1.o
[8/8] cxx_link: build/default/src/Canvas_1.o build/default/src/CanvasGradient_1.o build/default/src/CanvasRenderingContext2d_1.o build/default/src/Image_1.o build/default/src/ImageData_1.o build/default/src/init_1.o build/default/src/PixelArray_1.o -> build/default/canvas.node
Waf: Leaving directory `/Users/pyrotechnick/node-canvas/build'
'build' finished successfully (3.145s)

@tj
Copy link
Contributor Author

tj commented Nov 16, 2010

Not compile time no

This issue was closed.
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

No branches or pull requests

1 participant