Hi Georg,
I've just made a test and Image.apply() seems to work correctly. This is the test script (a slightly modified version of your initial snippet):
#include <pjsr/SampleType.jsh>
#include <pjsr/ImageOp.jsh>
var valuesToAdd = [ -0.1, +0.1, +0.2 ];
function main(){
var window = ImageWindow.activeWindow;
var targetView=window.currentView;
var targetImage=targetView.image;
targetView.beginProcess();
var resultImage=new Image( targetImage.width, targetImage.height,
targetImage.numberOfChannels, targetImage.colorSpace,
(targetImage.bitsPerSample < 32) ? 32 : 64, SampleType_Real );
targetImage.resetSelections();
resultImage.resetSelections();
resultImage.assign(targetImage);
var iResultHeight=resultImage.height;
var lineRect=new Rect(resultImage.width,1);
resultImage.resetSelections();
// for each channel
for (var chan=0; chan<resultImage.numberOfChannels;++chan){
resultImage.selectedChannel=chan;
// and each row
for (var row=0; row<iResultHeight;++row) {
lineRect.moveTo(0,row);
resultImage.selectedRect=lineRect;
resultImage.apply( valuesToAdd[chan], ImageOp_Add ); /* ### */
} //for row
} //for channel
resultImage.resetSelections();
targetImage.resetSelections();
targetImage.assign( resultImage );
// end transaction
targetView.endProcess();
}
main();
See the attached screenshot. The image to the left (test1) has been generated with NewImage as a RGB image with initial values R=0.25, G=0.5, B=0.75. The test2 image is a copy of test1 after applying the above script. The final values are R=0.15, G=0.6, B=0.95, as expected (see the valuesToAdd array).
(To further help you, I'd need to see your code)TM