diff --git a/components/formats-bsd/matlab/bfsave.m b/components/formats-bsd/matlab/bfsave.m index 7a9fd18344a..f7ce958bc2a 100644 --- a/components/formats-bsd/matlab/bfsave.m +++ b/components/formats-bsd/matlab/bfsave.m @@ -109,17 +109,18 @@ function bfsave(varargin) writer.setId(ip.Results.outputPath); % Load conversion tools for saving planes +isLittleEndian = ~metadata.getPixelsBigEndian(0).booleanValue; switch class(ip.Results.I) case {'int8', 'uint8'} getBytes = @(x) x(:); case {'uint16','int16'} - getBytes = @(x) javaMethod('shortsToBytes', 'loci.common.DataTools', x(:), 0); + getBytes = @(x) javaMethod('shortsToBytes', 'loci.common.DataTools', x(:), isLittleEndian); case {'uint32','int32'} - getBytes = @(x) javaMethod('intsToBytes', 'loci.common.DataTools', x(:), 0); + getBytes = @(x) javaMethod('intsToBytes', 'loci.common.DataTools', x(:), isLittleEndian); case {'single'} - getBytes = @(x) javaMethod('floatsToBytes', 'loci.common.DataTools', x(:), 0); + getBytes = @(x) javaMethod('floatsToBytes', 'loci.common.DataTools', x(:), isLittleEndian); case 'double' - getBytes = @(x) javaMethod('doublesToBytes', 'loci.common.DataTools', x(:), 0); + getBytes = @(x) javaMethod('doublesToBytes', 'loci.common.DataTools', x(:), isLittleEndian); end % Save planes to the writer