Package flash.graphics.images

Examples of flash.graphics.images.LosslessImage


  public boolean drawImage(Image image, AffineTransform at, ImageObserver obs)
  {
    if (image != null)
    {
        LosslessImage losslessImage = new LosslessImage(image);
        int width = losslessImage.getWidth();
        int height = losslessImage.getHeight();
      DefineBitsLossless defineBits = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), width, height);
      defineTags.defineBitsLossless2(defineBits);

      DefineShape ds3 = ImageShapeBuilder.buildImage(defineBits, defineBits.width, defineBits.height);
      defineTags.defineShape3(ds3);
      applyBounds(ds3.bounds.xMin, ds3.bounds.yMin, ds3.bounds.xMax, ds3.bounds.yMax);
View Full Code Here


   */
  public void drawNamedImage(Image image, String name)
  {
    if (image != null)
    {
            LosslessImage losslessImage = new LosslessImage(image);
            int width = losslessImage.getWidth();
            int height = losslessImage.getHeight();
            DefineBitsLossless defineBits = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), width, height);
      defineTags.defineBitsLossless2(defineBits);

      DefineShape ds3 = ImageShapeBuilder.buildImage(defineBits, defineBits.width, defineBits.height);
      defineTags.defineShape3(ds3);
            applyBounds(ds3.bounds.xMin, ds3.bounds.yMin, ds3.bounds.xMax, ds3.bounds.yMax);
View Full Code Here

      else if (paint instanceof TexturePaint)
      {
        TexturePaint tp = (TexturePaint)paint;
        Image image = tp.getImage();

              LosslessImage losslessImage = new LosslessImage(image);
              int imageWidth = losslessImage.getWidth();
              int imageHeight = losslessImage.getHeight();
              DefineBitsLossless tag = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), imageWidth, imageHeight);

        //Apply Twips Scale of 20 x 20
        AffineTransform at = new AffineTransform();
        at.setToScale(SwfConstants.TWIPS_PER_PIXEL, SwfConstants.TWIPS_PER_PIXEL);
        Matrix matrix = MatrixBuilder.build(at);
View Full Code Here

  public boolean drawImage(Image image, AffineTransform at, ImageObserver obs)
  {
    if (image != null)
    {
        LosslessImage losslessImage = new LosslessImage(image);
        int width = losslessImage.getWidth();
        int height = losslessImage.getHeight();
      DefineBitsLossless defineBits = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), width, height);
      defineTags.defineBitsLossless2(defineBits);

      DefineShape ds3 = ImageShapeBuilder.buildImage(defineBits, defineBits.width, defineBits.height);
      defineTags.defineShape3(ds3);
      applyBounds(ds3.bounds.xMin, ds3.bounds.yMin, ds3.bounds.xMax, ds3.bounds.yMax);
View Full Code Here

   */
  public void drawNamedImage(Image image, String name)
  {
    if (image != null)
    {
            LosslessImage losslessImage = new LosslessImage(image);
            int width = losslessImage.getWidth();
            int height = losslessImage.getHeight();
            DefineBitsLossless defineBits = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), width, height);
      defineTags.defineBitsLossless2(defineBits);

      DefineShape ds3 = ImageShapeBuilder.buildImage(defineBits, defineBits.width, defineBits.height);
      defineTags.defineShape3(ds3);
            applyBounds(ds3.bounds.xMin, ds3.bounds.yMin, ds3.bounds.xMax, ds3.bounds.yMax);
View Full Code Here

    {
        ImageInfo info = new ImageInfo();

        try
        {
            LosslessImage image = new LosslessImage(sourceFile.getName(),
                                                    sourceFile.getInputStream(),
                                                    sourceFile.getLastModified());
       
            // If compression is true, use JPEG compression.  Otherwise, use the lossless format.
            if (args.containsKey(COMPRESSION) && Boolean.parseBoolean((String) args.get(COMPRESSION)))
            {
                // We use DefineBitsJPEG3, because it supports an alpha channel
                DefineBitsJPEG3 defineBits = new DefineBitsJPEG3();
                int imageSize = image.getWidth() * image.getHeight();
                byte[] alphaData = new byte[imageSize];
                int[] pixels = image.getPixels();
                BufferedImage bufferedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);

                bufferedImage.setRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());

                for (int i = 0; i < imageSize; ++i)
                {
                    alphaData[i] = (byte) ((pixels[i] >> 24) & 0xff);
                }

                float quality = 1.0f;

                if (args.containsKey(QUALITY))
                {
                    try
                    {
                        String qualityString = (String) args.get(QUALITY);
                        double qualityPercentage = Double.parseDouble(qualityString);

                        // quality must be a number between 0 and 100.
                        if (qualityPercentage < 0 || qualityPercentage > 100)
                        {
                            throw new InvalidQuality();
                        }

                        quality = (float)(qualityPercentage / 100.0);
                    }
                    catch (NumberFormatException numberFormatException)
                    {
                        throw new InvalidQuality();
                    }
                }

                defineBits.data = bufferedImageToJPEG(bufferedImage, quality);
                defineBits.alphaDataOffset = alphaData.length;
                defineBits.alphaData = alphaData;

                info.defineBits = defineBits;
            }
            else
            {
                // quality doesn't make sense without compression.
                if (args.containsKey(QUALITY))
                {
                    throw new QualityRequiresCompression();
                }

                DefineBitsLossless defineBits = DefineBitsLosslessBuilder.build(image.getPixels(), image.getWidth(), image.getHeight());
                info.defineBits = defineBits;
            }

            info.width = image.getWidth();
            info.height = image.getHeight();
        }
        catch (TranscoderException transcoderException)
        {
            throw transcoderException;
        }
View Full Code Here

  public boolean drawImage(Image image, AffineTransform at, ImageObserver obs)
  {
    if (image != null)
    {
        LosslessImage losslessImage = new LosslessImage(image);
        int width = losslessImage.getWidth();
        int height = losslessImage.getHeight();
      DefineBitsLossless defineBits = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), width, height);
      defineTags.defineBitsLossless2(defineBits);

      DefineShape ds3 = ImageShapeBuilder.buildImage(defineBits, defineBits.width, defineBits.height);
      defineTags.defineShape3(ds3);
      applyBounds(ds3.bounds.xMin, ds3.bounds.yMin, ds3.bounds.xMax, ds3.bounds.yMax);
View Full Code Here

   */
  public void drawNamedImage(Image image, String name)
  {
    if (image != null)
    {
            LosslessImage losslessImage = new LosslessImage(image);
            int width = losslessImage.getWidth();
            int height = losslessImage.getHeight();
            DefineBitsLossless defineBits = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), width, height);
      defineTags.defineBitsLossless2(defineBits);

      DefineShape ds3 = ImageShapeBuilder.buildImage(defineBits, defineBits.width, defineBits.height);
      defineTags.defineShape3(ds3);
            applyBounds(ds3.bounds.xMin, ds3.bounds.yMin, ds3.bounds.xMax, ds3.bounds.yMax);
View Full Code Here

      else if (paint instanceof TexturePaint)
      {
        TexturePaint tp = (TexturePaint)paint;
        Image image = tp.getImage();

              LosslessImage losslessImage = new LosslessImage(image);
              int imageWidth = losslessImage.getWidth();
              int imageHeight = losslessImage.getHeight();
              DefineBitsLossless tag = DefineBitsLosslessBuilder.build(losslessImage.getPixels(), imageWidth, imageHeight);

        //Apply Twips Scale of 20 x 20
        AffineTransform at = new AffineTransform();
        at.setToScale(SwfConstants.TWIPS_PER_PIXEL, SwfConstants.TWIPS_PER_PIXEL);
        Matrix matrix = MatrixBuilder.build(at);
View Full Code Here

TOP

Related Classes of flash.graphics.images.LosslessImage

Copyright © 2018 www.massapicom. 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.