示例#1
0
DecodeBufferWorker::DecodeBufferWorker(
    NanCallback * callback,
    Local<Object> & buff,
    buf_dec_f_t decoder
): NanAsyncWorker(callback), _decoder(decoder), _pixbuf(NULL), _width(0),
    _height(0), _channels(0), _trans(false), _metadata("") {
    SaveToPersistent("buff", buff); // make sure buff isn't GC'ed
    _buffer = Buffer::Data(buff);
    _buffsize = Buffer::Length(buff);
}
示例#2
0
  BufferWorker(
          NanCallback *callback
        , int milliseconds
        , v8::Local<v8::Object> &bufferHandle
      )
    : NanAsyncWorker(callback), milliseconds(milliseconds) {

      NanScope();

      SaveToPersistent("buffer", bufferHandle);
    }
示例#3
0
PasteWorker::PasteWorker(
    size_t left,
    size_t top,
    Local<Object> & pixbuf,
    size_t width,
    size_t height,
    CImg<unsigned char> * cimg,
    NanCallback * callback
): NanAsyncWorker(callback), _left(left), _top(top), _width(width),
   _height(height), _cimg(cimg) {
    SaveToPersistent("pixbuf", pixbuf);
    _pixels = (unsigned char *) Buffer::Data(pixbuf);
}
EncodeToGifBufferWorker::EncodeToGifBufferWorker(
    Local<Object> & buff,
    size_t width,
    size_t height,
    int cmapSize,
    int colors,
    bool interlaced,
    bool trans,
    int threshold,
    Nan::Callback * callback
): Nan::AsyncWorker(callback), _width(width), _height(height),
    _cmapSize(cmapSize), _colors(colors), _interlaced(interlaced), _trans(trans),
    _threshold(threshold), _gifbuf(NULL), _gifbufsize(0) {
    SaveToPersistent("buff", buff); // make sure buff isn't GC'ed
    _pixbuf = (unsigned char *) Buffer::Data(buff);
    if (_trans){
        // make room in the color table for a transparent color
        if (_cmapSize == 256){
            if (_colors == 256) _colors--;
        } else if (_cmapSize == _colors){
            _cmapSize *= 2;
        }
    }
}