Changeset 7567
- Timestamp:
- 01/20/11 17:53:30 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/maven/projects/loci-plugins/src/test/java/Save_As_J2K.java
r7566 r7567 33 33 34 34 // get file to save 35 final SaveDialog saveDialog = new SaveDialog("Save as J2K", " out.j2k", "j2k");35 final SaveDialog saveDialog = new SaveDialog("Save as J2K", "", "j2k"); 36 36 final String fileName = saveDialog.getFileName(); 37 37 final String directory = saveDialog.getDirectory(); … … 57 57 samplesPerPixel = 4; 58 58 final int[] pix = (int[]) ip.getPixels(); 59 b = new byte[pix.length * 4];59 b = new byte[pix.length * samplesPerPixel]; 60 60 for (int i=0, j=0; i<pix.length; i++) { 61 61 final int p = pix[i]; 62 b[j++] = (byte)(p >> 24);63 62 b[j++] = (byte)((p >> 16) & 0xff); 64 63 b[j++] = (byte)((p >> 8) & 0xff); 65 64 b[j++] = (byte)(p & 0xff); 65 b[j++] = (byte)(p >> 24); 66 66 } 67 } else if (type == ImagePlus.GRAY8) {67 } else if (type == ImagePlus.GRAY8) { 68 68 samplesPerPixel = 1; 69 69 b = (byte[]) ip.getPixels(); … … 92 92 93 93 // write image plane to disk 94 System.out.println("Writing image to '" + path + "'...");94 IJ.showStatus("Writing image to '" + path + "'..."); 95 95 96 96 writer.setMetadataRetrieve(meta); 97 97 writer.setId(path); 98 writer.save Plane(0, b);98 writer.saveBytes(0, b); 99 99 } catch (Throwable t) { 100 100 t.printStackTrace();
Note: See TracChangeset
for help on using the changeset viewer.