Пример #1
0
 /*     */ protected Object clone() /*     */ {
   /* 112 */ MarkerSegment localMarkerSegment = null;
   /*     */ try {
     /* 114 */ localMarkerSegment = (MarkerSegment) super.clone();
   } catch (CloneNotSupportedException localCloneNotSupportedException) {
     /*     */ }
   /* 116 */ if (this.data != null) {
     /* 117 */ localMarkerSegment.data = ((byte[]) this.data.clone());
     /*     */ }
   /* 119 */ return localMarkerSegment;
   /*     */ }
Пример #2
0
  /**
   * Write out the given profile to the stream, embedded in the necessary number of APP2 segments,
   * per the ICC spec. This is the only mechanism for writing an ICC profile to a stream.
   */
  static void writeICC(ICC_Profile profile, ImageOutputStream ios) throws IOException {
    int LENGTH_LENGTH = 2;
    final String ID = "ICC_PROFILE";
    int ID_LENGTH = ID.length() + 1; // spec says it's null-terminated
    int COUNTS_LENGTH = 2;
    int MAX_ICC_CHUNK_SIZE = 65535 - LENGTH_LENGTH - ID_LENGTH - COUNTS_LENGTH;

    byte[] data = profile.getData();
    int numChunks = data.length / MAX_ICC_CHUNK_SIZE;
    if ((data.length % MAX_ICC_CHUNK_SIZE) != 0) {
      numChunks++;
    }
    int chunkNum = 1;
    int offset = 0;
    for (int i = 0; i < numChunks; i++) {
      int dataLength = Math.min(data.length - offset, MAX_ICC_CHUNK_SIZE);
      int segLength = dataLength + COUNTS_LENGTH + ID_LENGTH + LENGTH_LENGTH;
      ios.write(0xff);
      ios.write(JPEG.APP2);
      MarkerSegment.write2bytes(ios, segLength);
      byte[] id = ID.getBytes("US-ASCII");
      ios.write(id);
      ios.write(0); // Null-terminate the string
      ios.write(chunkNum++);
      ios.write(numChunks);
      ios.write(data, offset, dataLength);
      offset += dataLength;
    }
  }