Examples of MyLzwCompressor


Examples of org.apache.commons.imaging.common.mylzw.MyLzwCompressor

            // better
            // choice
            // here.
            bos.write(lzwMinimumCodeSize);

            final MyLzwCompressor compressor = new MyLzwCompressor(
                    lzwMinimumCodeSize, ByteOrder.LITTLE_ENDIAN, false); // GIF
            // Mode);

            final byte[] imagedata = new byte[width * height];
            for (int y = 0; y < height; y++) {
                for (int x = 0; x < width; x++) {
                    final int argb = src.getRGB(x, y);
                    final int rgb = 0xffffff & argb;
                    int index;

                    if (hasAlpha) {
                        final int alpha = 0xff & (argb >> 24);
                        final int alphaThreshold = 255;
                        if (alpha < alphaThreshold) {
                            index = palette2.length(); // is transparent
                        } else {
                            index = palette2.getPaletteIndex(rgb);
                        }
                    } else {
                        index = palette2.getPaletteIndex(rgb);
                    }

                    imagedata[y * width + x] = (byte) index;
                }
            }

            final byte[] compressed = compressor.compress(imagedata);
            writeAsSubBlocks(bos, compressed);
//            image_data_total += compressed.length;
        }

        // palette2.dump();
View Full Code Here

Examples of org.apache.commons.imaging.common.mylzw.MyLzwCompressor

            for (int i = 0; i < strips.length; i++) {
                final byte[] uncompressed = strips[i];

                final int LZW_MINIMUM_CODE_SIZE = 8;

                final MyLzwCompressor compressor = new MyLzwCompressor(
                        LZW_MINIMUM_CODE_SIZE, ByteOrder.BIG_ENDIAN, true);
                final byte[] compressed = compressor.compress(uncompressed);

                strips[i] = compressed;
            }
        } else if (compression == TIFF_COMPRESSION_UNCOMPRESSED) {
            // do nothing.
View Full Code Here

Examples of org.apache.sanselan.common.mylzw.MyLZWCompressor

            public void init(int clearCode, int eoiCode)
            {
            }
        };

        MyLZWCompressor compressor = new MyLZWCompressor(LZW_MINIMUM_CODE_SIZE,
                BYTE_ORDER_MSB, true, compressionListener);
        byte compressed[] = compressor.compress(src);

        MyLZWDecompressor.Listener decompressionListener = new MyLZWDecompressor.Listener() {

            int index = 0;
            int clearCode, eoiCode;
View Full Code Here

Examples of org.apache.sanselan.common.mylzw.MyLZWCompressor

                code(code);
            }

        };

        MyLZWCompressor compressor = new MyLZWCompressor(LZW_MINIMUM_CODE_SIZE,
                BYTE_ORDER_MSB, true, compressionListener);
        byte compressed[] = compressor.compress(decompressed);

        assertEquals(src.length, compressed.length);
        for (int i = 0; i < src.length; i++)
            assertEquals(src[i], compressed[i]);
    }
View Full Code Here

Examples of org.apache.sanselan.common.mylzw.MyLZWCompressor

                // better
                // choice
                // here.
                bos.write(LZWMinimumCodeSize);

                MyLZWCompressor compressor = new MyLZWCompressor(
                        LZWMinimumCodeSize, BYTE_ORDER_LSB, false); // GIF
                // Mode);

                byte imagedata[] = new byte[width * height];
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        int argb = src.getRGB(x, y);
                        int rgb = 0xffffff & argb;
                        int index;

                        if (hasAlpha)
                        {
                            int alpha = 0xff & (argb >> 24);
                            final int alphaThreshold = 255;
                            if (alpha < alphaThreshold)
                                index = palette2.length(); // is transparent
                            else
                                index = palette2.getPaletteIndex(rgb);
                        } else
                        {
                            index = palette2.getPaletteIndex(rgb);
                        }

                        imagedata[y * width + x] = (byte) index;
                    }
                }

                byte compressed[] = compressor.compress(imagedata);
                writeAsSubBlocks(bos, compressed);
                image_data_total += compressed.length;
            }

            // palette2.dump();
View Full Code Here

Examples of org.apache.sanselan.common.mylzw.MyLZWCompressor

            {
                byte uncompressed[] = strips[i];

                int LZW_MINIMUM_CODE_SIZE = 8;

                MyLZWCompressor compressor = new MyLZWCompressor(
                        LZW_MINIMUM_CODE_SIZE, BYTE_ORDER_MSB, true);
                byte compressed[] = compressor.compress(uncompressed);

                strips[i] = compressed;
            }
        } else if (compression == TIFF_COMPRESSION_UNCOMPRESSED)
        {
View Full Code Here

Examples of org.apache.sanselan.common.mylzw.MyLZWCompressor

      {
        byte uncompressed[] = strips[i];

        int LZWMinimumCodeSize = 8;

        MyLZWCompressor compressor = new MyLZWCompressor(
            LZWMinimumCodeSize, BYTE_ORDER_MSB, true);
        byte compressed[] = compressor.compress(uncompressed);

        strips[i] = compressed;
      }
    }
    else if (compression == TIFF_COMPRESSION_UNCOMPRESSED)
View Full Code Here

Examples of org.apache.sanselan.common.mylzw.MyLZWCompressor

        // better
        // choice
        // here.
        bos.write(LZWMinimumCodeSize);

        MyLZWCompressor compressor = new MyLZWCompressor(
            LZWMinimumCodeSize, BYTE_ORDER_LSB, false); // GIF
        // Mode);

        byte imagedata[] = new byte[width * height];
        for (int y = 0; y < height; y++)
        {
          for (int x = 0; x < width; x++)
          {
            int argb = src.getRGB(x, y);
            int rgb = 0xffffff & argb;
            int index;

            if (hasAlpha)
            {
              int alpha = 0xff & (argb >> 24);
              final int alphaThreshold = 255;
              if (alpha < alphaThreshold)
                index = palette2.length(); // is transparent
              else
                index = palette2.getPaletteIndex(rgb);
            } else
            {
              index = palette2.getPaletteIndex(rgb);
            }

            imagedata[y * width + x] = (byte) index;
          }
        }

        byte compressed[] = compressor.compress(imagedata);
        writeAsSubBlocks(bos, compressed);
        image_data_total += compressed.length;
      }

      // palette2.dump();
View Full Code Here

Examples of org.apache.sanselan.common.mylzw.MyLZWCompressor

  public byte[] compressLZW(byte src[], int LZWMinimumCodeSize,
      int byteOrder, boolean earlyLimit) throws IOException

  {
    MyLZWCompressor compressor = new MyLZWCompressor(LZWMinimumCodeSize,
        byteOrder, earlyLimit);

    byte compressed[] = compressor.compress(src);

    return compressed;
  }
View Full Code Here

Examples of org.apache.sanselan.common.mylzw.MyLZWCompressor

        // better
        // choice
        // here.
        bos.write(LZWMinimumCodeSize);

        MyLZWCompressor compressor = new MyLZWCompressor(
            LZWMinimumCodeSize, BYTE_ORDER_LSB, false); // GIF
        // Mode);

        byte imagedata[] = new byte[width * height];
        for (int y = 0; y < height; y++)
        {
          for (int x = 0; x < width; x++)
          {
            int argb = src.getRGB(x, y);
            int rgb = 0xffffff & argb;
            int index;

            if (hasAlpha)
            {
              int alpha = 0xff & (argb >> 24);
              final int alphaThreshold = 255;
              if (alpha < alphaThreshold)
                index = palette2.length(); // is transparent
              else
                index = palette2.getPaletteIndex(rgb);
            } else
            {
              index = palette2.getPaletteIndex(rgb);
            }

            imagedata[y * width + x] = (byte) index;
          }
        }

        byte compressed[] = compressor.compress(imagedata);
        writeAsSubBlocks(bos, compressed);
        image_data_total += compressed.length;
      }

      // palette2.dump();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.