This is almost the same code I pasted in the "Unable to copy and resample image" message:
#include <pjsr/Interpolation.jsh>
#include <pjsr/SampleType.jsh>
#include <pjsr/UndoFlag.jsh>
var w = ImageWindow.activeWindow;
if (w.isNull)
throw Error ("No image window.");
var v = w.mainView;
var copy_img = new ImageWindow (
v.image.width, v.image.height,
v.image.numberOfChannels, v.image.bitsPerSample,
v.image.sampleType == SampleType_Real,
true, "foobar23204"
);
copy_img.show();
with (copy_img.mainView) {
beginProcess (UndoFlag_NoSwapFile);
//image.apply (v.image); // crash
//image.assign (v.image); // crash
//image.clonePixelData (v.image); // err
//var ap = new Array; v.image.getPixels (ap); image.setPixels (ap); // crash
//image.transfer (v.image); // err
image.resample (640, 480, Interpolation_BicubicBSpline);
endProcess();
}
//copy_img = null;
gc();
The important difference is that I moved the "image.resample" line before the endProcess one. When uncommenting one of the five previous lines, the behaviour of the application is as noted: crash in 3 of the cases and error in the other 2. If no line is uncommented, the application crashes too.
The main PixInsight window disappears and the console from which I run the application says:
terminate called after throwing an instance of 'pcl::EUnixSegmentationViolation'
/usr/bin/PixInsight: line 5: 6389 Aborted /usr/lib/pixinsight/PixInsight32 $*