ImageData.h 771 B

123456789101112131415161718192021222324252627
  1. // Copyright (c) 2010 LearnBoost <tj@learnboost.com>
  2. #pragma once
  3. #include <nan.h>
  4. #include <stdint.h> // node < 7 uses libstdc++ on macOS which lacks complete c++11
  5. #include <v8.h>
  6. class ImageData: public Nan::ObjectWrap {
  7. public:
  8. static Nan::Persistent<v8::FunctionTemplate> constructor;
  9. static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
  10. static NAN_METHOD(New);
  11. static NAN_GETTER(GetWidth);
  12. static NAN_GETTER(GetHeight);
  13. inline int width() { return _width; }
  14. inline int height() { return _height; }
  15. inline uint8_t *data() { return _data; }
  16. ImageData(uint8_t *data, int width, int height) : _width(width), _height(height), _data(data) {}
  17. private:
  18. int _width;
  19. int _height;
  20. uint8_t *_data;
  21. };