Skip to content

Commit

Permalink
added a load from data buffer w*h*4 unsigned char
Browse files Browse the repository at this point in the history
  • Loading branch information
victusfate committed May 30, 2012
1 parent 1da0a5b commit 817a750
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,19 @@ Image::loadFromBuffer(uint8_t *buf, unsigned len) {
return CAIRO_STATUS_READ_ERROR;
}

/*
* load from data buffer width*height*4 bytes
*/
cairo_status_t
Image::loadFromDataBuffer(unsigned char *buf, int width, int height) {
clearData();
int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width); // 4*width + ?
_surface = cairo_image_surface_create_for_data(buf,CAIRO_FORMAT_ARGB32,width,height,stride);
loaded();
return cairo_surface_status(_surface);
}


/*
* Load PNG data from `buf`.
*/
Expand Down
1 change: 1 addition & 0 deletions src/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Image: public node::ObjectWrap {
inline int isComplete(){ return COMPLETE == state; }
cairo_status_t loadSurface();
cairo_status_t loadFromBuffer(uint8_t *buf, unsigned len);
cairo_status_t loadFromDataBuffer(unsigned char *buf, int width, int height);
cairo_status_t loadPNGFromBuffer(uint8_t *buf);
cairo_status_t loadPNG();
void clearData();
Expand Down

0 comments on commit 817a750

Please sign in to comment.