Ensure dimensions of final output image are provided (#399)

Add a failing test for vips::VError exception
* fix buffer size mismatch
* Loosen error message assertion
* Update image
This commit is contained in:
Samy Al Zahrani
2016-04-08 10:58:51 +03:00
committed by Lovell Fuller
parent f214269aa1
commit ef61da3051
4 changed files with 44 additions and 8 deletions

View File

@@ -103,14 +103,19 @@ class PipelineWorker : public AsyncWorker {
// From buffer
if (baton->rawWidth > 0 && baton->rawHeight > 0 && baton->rawChannels > 0) {
// Raw, uncompressed pixel data
image = VImage::new_from_memory(baton->bufferIn, baton->bufferInLength,
baton->rawWidth, baton->rawHeight, baton->rawChannels, VIPS_FORMAT_UCHAR);
if (baton->rawChannels < 3) {
image.get_image()->Type = VIPS_INTERPRETATION_B_W;
} else {
image.get_image()->Type = VIPS_INTERPRETATION_sRGB;
try {
image = VImage::new_from_memory(baton->bufferIn, baton->bufferInLength,
baton->rawWidth, baton->rawHeight, baton->rawChannels, VIPS_FORMAT_UCHAR);
if (baton->rawChannels < 3) {
image.get_image()->Type = VIPS_INTERPRETATION_B_W;
} else {
image.get_image()->Type = VIPS_INTERPRETATION_sRGB;
}
inputImageType = ImageType::RAW;
} catch(VError const &err) {
(baton->err).append(err.what());
inputImageType = ImageType::UNKNOWN;
}
inputImageType = ImageType::RAW;
} else {
// Compressed data
inputImageType = DetermineImageType(baton->bufferIn, baton->bufferInLength);
@@ -656,7 +661,8 @@ class PipelineWorker : public AsyncWorker {
// Number of channels used in output image
baton->channels = image.bands();
baton->width = image.width();
baton->height = image.height();
// Output
if (baton->fileOut == "") {
// Buffer output