/** * Reads Graphics Control Extension values */ private void readGraphicControlExt() { read(); // block size int packed = read(); // packed fields dispose = (packed & 0x1c) >> 1; transparency = (packed & 1) != 0; delay = readShort() * 10; // delay in milliseconds transIndex = read(); // transparent color index read(); // block terminator }
/** * Reads GIF file header information. */ private void readHeader() { String id = ""; for (int i = 0; i < 6; i++) id += (char) read(); if (!id.startsWith("GIF")) { status = STATUS_FORMAT_ERROR; return; } readLSD(); if (gctFlag && !err()) { gct = readColorTable(gctSize); bgColor = gct[bgIndex]; } }
ih = readShort(); int packed = read(); lctFlag = (packed & 0x80) != 0; // 1 - local color table flag interlace = (packed & 0x40) != 0; // 2 - interlace flag
data_size = read(); clear = 1 << data_size; end_of_information = clear + 1;
/** * Reads GIF file header information. */ private void readHeader() { String id = ""; for (int i = 0; i < 6; i++) id += (char) read(); if (!id.startsWith("GIF")) { status = STATUS_FORMAT_ERROR; return; } readLSD(); if (gctFlag && !err()) { gct = readColorTable(gctSize); bgColor = gct[bgIndex]; } }
ih = readShort(); int packed = read(); lctFlag = (packed & 0x80) != 0; // 1 - local color table flag interlace = (packed & 0x40) != 0; // 2 - interlace flag
/** * Reads Graphics Control Extension values */ private void readGraphicControlExt() { read(); // block size int packed = read(); // packed fields dispose = (packed & 0x1c) >> 1; transparency = (packed & 1) != 0; delay = readShort() * 10; // delay in milliseconds transIndex = read(); // transparent color index read(); // block terminator }
data_size = read(); clear = 1 << data_size; end_of_information = clear + 1;
/** * Reads Logical Screen Descriptor */ private void readLSD() { // logical screen size width = readShort(); height = readShort(); // packed fields int packed = read(); gctFlag = (packed & 0x80) != 0; // 1 : global color table flag // 2-4 : color resolution // 5 : gct sort flag gctSize = 2 << (packed & 7); // 6-8 : gct size bgIndex = read(); // background color index pixelAspect = read(); // pixel aspect ratio }
/** * Reads next variable length block from input. * * @return int number of bytes stored in "buffer" */ private int readBlock() { blockSize = read(); int n = 0; int count; if (blockSize > 0) { try { while (n<blockSize) { count = in.read(block, n, blockSize-n); if (count==-1) break; n += count; } } catch (IOException e) {} if (n < blockSize) status = STATUS_FORMAT_ERROR; } return n; }
/** * Reads Logical Screen Descriptor */ private void readLSD() { // logical screen size width = readShort(); height = readShort(); // packed fields int packed = read(); gctFlag = (packed & 0x80) != 0; // 1 : global color table flag // 2-4 : color resolution // 5 : gct sort flag gctSize = 2 << (packed & 7); // 6-8 : gct size bgIndex = read(); // background color index pixelAspect = read(); // pixel aspect ratio }
/** * Reads next variable length block from input. * * @return int number of bytes stored in "buffer" */ private int readBlock() { blockSize = read(); int n = 0; int count; if (blockSize > 0) { try { while (n<blockSize) { count = in.read(block, n, blockSize-n); if (count==-1) break; n += count; } } catch (IOException e) {} if (n < blockSize) status = STATUS_FORMAT_ERROR; } return n; }
/** * Reads GIF file from specified source (file or URL string) * * @param name File source string * @return int read status code */ public int read(String name) { status = STATUS_OK; try { name = name.trim(); if (name.indexOf("://") > 0) { URL url = new URL(name); in = new BufferedInputStream(url.openStream()); } else { in = new BufferedInputStream(new FileInputStream(name)); } status = read(in); } catch (IOException e) { status = STATUS_OPEN_ERROR; } return status; }
/** * Reads GIF file from specified source (file or URL string) * * @param name File source string * @return int read status code */ public int read(String name) { status = STATUS_OK; try { name = name.trim(); if (name.indexOf("://") > 0) { URL url = new URL(name); in = new BufferedInputStream(url.openStream()); } else { in = new BufferedInputStream(new FileInputStream(name)); } status = read(in); } catch (IOException e) { status = STATUS_OPEN_ERROR; } return status; }
String dir = od.getDirectory(); GifDecoder d = new GifDecoder(); int status = d.read(dir+name); int n = d.getFrameCount(); ImageStack stack = null;
String dir = od.getDirectory(); GifDecoder d = new GifDecoder(); int status = d.read(dir+name); int n = d.getFrameCount(); ImageStack stack = null;