Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/sixlegs/image/png/Chunk_hIST.java


1   // Copyright (C) 1998, 1999, 2001 Chris Nokleberg
2   // Please see included LICENSE.TXT
3   
4   package com.sixlegs.image.png;
5   import java.io.IOException;
6   
7   final class Chunk_hIST
8   extends Chunk
9   {
10      Chunk_hIST()
11      {
12          super(hIST);
13      }
14  
15      protected boolean multipleOK()
16      {
17          return false;
18      }
19  
20      protected boolean beforeIDAT()
21      {
22          return true;
23      }
24  
25      protected void readData()
26      throws IOException
27      {
28          if (img.data.palette == null)
29              throw new PngException("hIST chunk must follow PLTE chunk");
30          int num = img.data.palette.r.length;
31          if (length != num * 2) badLength(num * 2);
32          int[] values = new int[num];
33          for (int i = 0; i < num; i++) 
34              values[i] = in_data.readUnsignedShort();
35          img.data.properties.put("histogram", values);
36      }
37  }