/** Returns an ImageProcessor for the specified slice of this virtual stack (if it is one) * where 1<=n<=nslices. Returns null if no virtual stack or no slices or error reading the frame. */ public synchronized ImageProcessor getProcessor(int n) { if (frameInfos==null || frameInfos.size()==0 || raFilePath==null) return null; if (n<1 || n>frameInfos.size()) throw new IllegalArgumentException("Argument out of range: "+n); Object pixels = null; RandomAccessFile rFile = null; try { rFile = new RandomAccessFile(new File(raFilePath), "r"); long[] frameInfo = (long[])(frameInfos.get(n-1)); pixels = readFrame(rFile, frameInfo[0], (int)frameInfo[1]); } catch (Exception e) { error(exceptionMessage(e)); return null; } finally { closeFile(rFile); } if (pixels == null) return null; //failed if (pixels instanceof byte[]) return new ByteProcessor(dwWidth, biHeight, (byte[])pixels, cm); else if (pixels instanceof short[]) return new ShortProcessor(dwWidth, biHeight, (short[])pixels, cm); else return new ColorProcessor(dwWidth, biHeight, (int[])pixels); }
/** Returns an ImageProcessor for the specified slice of this virtual stack (if it is one) * where 1<=n<=nslices. Returns null if no virtual stack or no slices or error reading the frame. */ public synchronized ImageProcessor getProcessor(int n) { if (frameInfos==null || frameInfos.size()==0 || raFilePath==null) return null; if (n<1 || n>frameInfos.size()) throw new IllegalArgumentException("Argument out of range: "+n); Object pixels = null; RandomAccessFile rFile = null; try { rFile = new RandomAccessFile(new File(raFilePath), "r"); long[] frameInfo = (long[])(frameInfos.get(n-1)); pixels = readFrame(rFile, frameInfo[0], (int)frameInfo[1]); } catch (Exception e) { error(exceptionMessage(e)); return null; } finally { closeFile(rFile); } if (pixels == null) return null; //failed if (pixels instanceof byte[]) return new ByteProcessor(dwWidth, biHeight, (byte[])pixels, cm); else if (pixels instanceof short[]) return new ShortProcessor(dwWidth, biHeight, (short[])pixels, cm); else return new ColorProcessor(dwWidth, biHeight, (int[])pixels); }
frameInfos.add(new long[]{pos, size, frameNumber*dwMicroSecPerFrame}); else { //read the frame Object pixels = readFrame(raFile, pos, (int)size); String label = frameLabel(frameNumber*dwMicroSecPerFrame); stack.addSlice(label, pixels);
frameInfos.add(new long[]{pos, size, frameNumber*dwMicroSecPerFrame}); else { //read the frame Object pixels = readFrame(raFile, pos, (int)size); String label = frameLabel(frameNumber*dwMicroSecPerFrame); stack.addSlice(label, pixels);