Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix export of multiple files #470

Merged
merged 3 commits into from
Apr 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions components/loci-plugins/src/loci/plugins/out/Exporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ else if (store.getImageCount() > 1) {
store.setPixelsSizeT(new PositiveInteger(1), 0);
}

w.setMetadataRetrieve(store);

Object info = imp.getProperty("Info");
if (info != null) {
String imageInfo = info.toString();
Expand Down Expand Up @@ -459,6 +457,20 @@ else if (cal.frameInterval != 0.0 && cal.getTimeUnit().equals("sec")) {
}
}

if (!w.getFormat().startsWith("OME")) {
if (splitZ) {
store.setPixelsSizeZ(new PositiveInteger(1), 0);
}
if (splitC) {
store.setPixelsSizeC(new PositiveInteger(1), 0);
}
if (splitT) {
store.setPixelsSizeT(new PositiveInteger(1), 0);
}
}

w.setMetadataRetrieve(store);

// prompt for options

String[] codecs = w.getCompressionTypes();
Expand Down Expand Up @@ -503,7 +515,7 @@ else if (cal.frameInterval != 0.0 && cal.getTimeUnit().equals("sec")) {
byte[] plane = null;
w.setInterleaved(false);

int no = 0;
int[] no = new int[outputFiles.length];
for (int i=start; i<end; i++) {
if (doStack) {
BF.status(false, "Saving plane " + (i + 1) + "/" + size);
Expand Down Expand Up @@ -568,7 +580,7 @@ else if (proc instanceof ColorProcessor) {
}
else {
w.changeOutputFile(outputFiles[fileIndex]);
w.saveBytes(no++, plane);
w.saveBytes(no[fileIndex]++, plane);
}
}
w.close();
Expand Down
3 changes: 3 additions & 0 deletions components/scifio/src/loci/formats/FormatWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ public void savePlane(Object plane, int series, boolean lastInSeries,
public void setId(String id) throws FormatException, IOException {
if (id.equals(currentId)) return;
currentId = id;
if (out != null) {
out.close();
}
out = new RandomAccessOutputStream(currentId);

MetadataRetrieve r = getMetadataRetrieve();
Expand Down
8 changes: 5 additions & 3 deletions components/scifio/src/loci/formats/out/APNGWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public void saveBytes(int no, byte[] buf, int x, int y, int w, int h)

writePixels(numFrames == 0 ? "IDAT" : "fdAT", buf, x, y, w, h);
numFrames++;
if (numFrames == getPlaneCount()) {
writeFooter();
}
}

/* @see loci.formats.IFormatWriter#canDoStacks() */
Expand All @@ -121,6 +124,8 @@ public void setId(String id) throws FormatException, IOException {
super.setId(id);

if (out.length() == 0) {
numFrames = 0;

MetadataRetrieve r = getMetadataRetrieve();
int width = r.getPixelsSizeX(series).getValue().intValue();
int height = r.getPixelsSizeY(series).getValue().intValue();
Expand Down Expand Up @@ -172,9 +177,6 @@ public void setId(String id) throws FormatException, IOException {

/* @see loci.formats.IFormatHandler#close() */
public void close() throws IOException {
if (out != null) {
writeFooter();
}
super.close();
numFrames = 0;
numFramesPointer = 0;
Expand Down
3 changes: 3 additions & 0 deletions components/scifio/src/loci/formats/out/AVIWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ public void setId(String id) throws FormatException, IOException {
in.close();
out.seek(idx1Pos);
}
else {
planesWritten = 0;
}

out.order(true);

Expand Down
11 changes: 7 additions & 4 deletions components/scifio/src/loci/formats/out/ICSWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public void saveBytes(int no, byte[] buf, int x, int y, int w, int h)
{
checkParams(no, buf, x, y, w, h);

if (pixels == null) {
pixels = new RandomAccessOutputStream(currentId);
}

MetadataRetrieve meta = getMetadataRetrieve();

int rgbChannels = getSamplesPerPixel();
Expand Down Expand Up @@ -157,6 +161,9 @@ public void saveBytes(int no, byte[] buf, int x, int y, int w, int h)
}
}
lastPlane = realIndex;

pixels.close();
pixels = null;
}

/* @see loci.formats.IFormatWriter#canDoStacks() */
Expand Down Expand Up @@ -274,10 +281,6 @@ else if (checkSuffix(currentId, "ics")) {
if (checkSuffix(currentId, "ids")) {
pixelOffset = 0;
}

if (pixels == null) {
pixels = new RandomAccessOutputStream(currentId);
}
}

/* @see loci.formats.IFormatHandler#close() */
Expand Down
6 changes: 5 additions & 1 deletion components/scifio/src/loci/formats/out/OMETiffWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ public void saveBytes(int no, byte[] buf, IFD ifd, int x, int y, int w, int h)

super.saveBytes(no, buf, ifd, x, y, w, h);

imageLocations[series][no] = currentId;
int index = no;
while (imageLocations[series][index] != null) {
index++;
}
imageLocations[series][index] = currentId;
}

// -- IFormatHandler API methods --
Expand Down
3 changes: 3 additions & 0 deletions components/scifio/src/loci/formats/out/QTWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public void saveBytes(int no, byte[] buf, int x, int y, int w, int h)
}
}
numWritten++;
writeFooter();
}

/* @see loci.formats.IFormatWriter#canDoStacks() */
Expand Down Expand Up @@ -305,13 +306,15 @@ public void setId(String id) throws FormatException, IOException {

writeAtom(8, "wide");
writeAtom(numBytes + 8, "mdat");
numWritten = 0;
}
else {
out.seek(BYTE_COUNT_OFFSET);

RandomAccessInputStream in = new RandomAccessInputStream(currentId);
in.seek(BYTE_COUNT_OFFSET);
numBytes = in.readInt() - 8;
numWritten = numBytes / (planeSize + pad * height);
in.close();
}

Expand Down