FileDocCategorySizeDatePackage
PNGImageWriter.javaAPI DocJava SE 5 API37366Fri Aug 26 14:54:42 BST 2005com.sun.imageio.plugins.png

CRC

public class CRC extends Object

Fields Summary
private static int[]
crcTable
private int
crc
Constructors Summary
public CRC()


     
        // Initialize CRC table
        for (int n = 0; n < 256; n++) {
            int c = n;
            for (int k = 0; k < 8; k++) {
                if ((c & 1) == 1) {
                    c = 0xedb88320 ^ (c >>> 1);
                } else {
                    c >>>= 1;
                }

                crcTable[n] = c;
            }
        }
    
Methods Summary
public intgetValue()

        return crc ^ 0xffffffff;
    
public voidreset()

        crc = 0xffffffff;
    
public voidupdate(byte[] data, int off, int len)

        for (int n = 0; n < len; n++) {
            crc = crcTable[(crc ^ data[off + n]) & 0xff] ^ (crc >>> 8);
        }
    
public voidupdate(int data)

        crc = crcTable[(crc ^ data) & 0xff] ^ (crc >>> 8);