Skip to content
Browse files

Add SetPixel method

  • Loading branch information...
1 parent df49aa6 commit de859daa09367a73ef2621f818c7f2e6bfc1e4cd taggon committed May 26, 2011
Showing with 23 additions and 8 deletions.
  1. +1 −1 README
  2. +5 −5 gd.js
  3. +17 −2 gd_bindings.cc
View
2 README
@@ -2,4 +2,4 @@ GD bindings for Node.js
==================================
GD graphic library bindings for Node.js supporting asynchronous I/O.
-Tested with Node v0.1.91
+Tested with Node v0.4.6
View
10 gd.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2009, Taegon Kim <gonom9@gmail.com>
+Copyright (c) 2009-2011, Taegon Kim <gonom9@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -15,8 +15,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
var sys = require('sys');
-var fs = require("fs");
-var bind = require("./gd_bindings");
+var fs = require('fs');
+var bind = require('./gd_bindings');
for(var p in bind) {
if (bind[p] !== undefined) exports[p] = bind[p];
@@ -52,7 +52,7 @@ function open_func(format, len) {
args.pop();
- fs.readFile(filename, "binary", function(err, data) {
+ fs.readFile(filename, 'binary', function(err, data) {
if(err) throw err;
callback(bind['createFrom'+format+'Ptr'](data));
});
@@ -72,7 +72,7 @@ function save_func(format, len) {
}
var data = this[format+'Ptr'].apply(this, args);
- sys.debug(filename);
+
fs.writeFile(filename, data, "binary", function(err) {
if (err) throw err;
callback();
View
19 gd_bindings.cc
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2009, Taegon Kim <gonom9@gmail.com>
+Copyright (c) 2009-2011, Taegon Kim <gonom9@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -270,6 +270,7 @@ class Gd
/**
* Drawing Functions
*/
+ NODE_SET_PROTOTYPE_METHOD(t, "setPixcel", SetPixel);
NODE_SET_PROTOTYPE_METHOD(t, "line", Line);
NODE_SET_PROTOTYPE_METHOD(t, "dashedLine", DashedLine);
NODE_SET_PROTOTYPE_METHOD(t, "polygon", Polygon);
@@ -401,7 +402,6 @@ class Gd
char *data = (char*)gdImageJpegPtr(*im, &size, quality);
RETURN_DATA()
-
}
static Handle<Value> Gif (const Arguments &args)
@@ -536,6 +536,21 @@ class Gd
/**
* Drawing Functions
*/
+ static Handle<Value> SetPixel (const Arguments &args)
+ {
+ HandleScope scope;
+ Image *im = ObjectWrap::Unwrap<Image>(args.This());
+
+ REQ_ARGS(3);
+ REQ_INT_ARG(0, x);
+ REQ_INT_ARG(1, y);
+ REQ_INT_ARG(2, color);
+
+ gdImageSetPixel(*im, x, y, color);
+
+ return args.This();
+ }
+
static Handle<Value> Line (const Arguments &args)
{
Image *im = ObjectWrap::Unwrap<Image>(args.This());

0 comments on commit de859da

Please sign in to comment.
Something went wrong with that request. Please try again.