/** 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); }
errorText = "Out of memory. " + stack.getSize() + " of " + dwTotalFrames + " frames will be opened."; } catch (Exception e) { errorText = exceptionMessage(e); if (isVirtual || stack==null || stack.getSize()==0) //return null only if we have really nothing return null;
errorText = "Out of memory. " + stack.getSize() + " of " + dwTotalFrames + " frames will be opened."; } catch (Exception e) { errorText = exceptionMessage(e); if (isVirtual || stack==null || stack.getSize()==0) //return null only if we have really nothing return null;
error(exceptionMessage(e)); return; } finally {
error(exceptionMessage(e)); return; } finally {