Add raw pixel data support to boolean and withOverlay ops

The previously-scattered image opening logic has been refactored to a
single ImageDescriptor struct/Object available to both JS and C++ code

This removed about 150 LOC but more importantly reduces the complexity
of adding/exposing new operations that require an input image.
This commit is contained in:
Lovell Fuller
2016-07-26 22:26:55 +01:00
parent 36bfbdee0d
commit e6bfa52b0b
11 changed files with 589 additions and 696 deletions

View File

@@ -6,6 +6,7 @@
#include <vips/vips8>
#include "nan.h"
#include "common.h"
NAN_METHOD(pipeline);
@@ -18,30 +19,19 @@ enum class Canvas {
};
struct PipelineBaton {
std::string fileIn;
char *bufferIn;
size_t bufferInLength;
sharp::InputDescriptor *input;
std::string iccProfilePath;
int limitInputPixels;
int density;
int rawWidth;
int rawHeight;
int rawChannels;
std::string formatOut;
std::string fileOut;
void *bufferOut;
size_t bufferOutLength;
std::string overlayFileIn;
char *overlayBufferIn;
size_t overlayBufferInLength;
sharp::InputDescriptor *overlay;
int overlayGravity;
int overlayXOffset;
int overlayYOffset;
bool overlayTile;
bool overlayCutout;
std::string booleanFileIn;
char *booleanBufferIn;
size_t booleanBufferInLength;
int topOffsetPre;
int leftOffsetPre;
int widthPre;
@@ -96,8 +86,9 @@ struct PipelineBaton {
int convKernelHeight;
double convKernelScale;
double convKernelOffset;
VipsOperationBoolean bandBoolOp;
sharp::InputDescriptor *boolean;
VipsOperationBoolean booleanOp;
VipsOperationBoolean bandBoolOp;
int extractChannel;
int tileSize;
int tileOverlap;
@@ -105,22 +96,15 @@ struct PipelineBaton {
VipsForeignDzLayout tileLayout;
PipelineBaton():
bufferInLength(0),
input(nullptr),
limitInputPixels(0),
density(72),
rawWidth(0),
rawHeight(0),
rawChannels(0),
formatOut(""),
fileOut(""),
bufferOutLength(0),
overlayBufferInLength(0),
overlay(nullptr),
overlayGravity(0),
overlayXOffset(-1),
overlayYOffset(-1),
overlayTile(false),
overlayCutout(false),
booleanBufferInLength(0),
topOffsetPre(-1),
topOffsetPost(-1),
channels(0),
@@ -160,8 +144,9 @@ struct PipelineBaton {
convKernelHeight(0),
convKernelScale(0.0),
convKernelOffset(0.0),
bandBoolOp(VIPS_OPERATION_BOOLEAN_LAST),
boolean(nullptr),
booleanOp(VIPS_OPERATION_BOOLEAN_LAST),
bandBoolOp(VIPS_OPERATION_BOOLEAN_LAST),
extractChannel(-1),
tileSize(256),
tileOverlap(0),