Package gif

Examples of gif.GifInfo


         
         
 
 
          int numLoops=ChunkacTL.INFINITE_LOOP;
          GifInfo readgifinfo=new GifInfo(readGif);
        numLoops=readgifinfo.getLoops();
 
        theApng=new APNG(smd.logicalScreenWidth,smd.logicalScreenHeight,mode, numLoops,
                       (mode==Emodes.PALETTE)? smd.globalColorTable : null, iTransparency);
         
          //now add frames (by using BufferedImage)
         
          //tell callback how many frame there are
          if(callback!=null){
            callback.updatemax(numImages);
          }
         
          // Disposal-Methods:
          // method name(gif-method-number -> apng-method-number):
          //  unknown(0->0(ignored)), no disposal(1->0)
          //  restore to background(2->1), restore to previous(3->2)
          for(int i=0;i<numImages;i++){
           
            //if stop-button is clicked
        if(Thread.currentThread().isInterrupted()){
          //close reader & stream
                reader.dispose();
                fis.close();
                throw new CancellationException("stop-button was pushed");
        }
       
            //callback current frame:
              if(callback!=null){
                callback.updatecur(i+1);
              }   
           
            md=(GIFImageMetadata) reader.getImageMetadata(i);
            int idismet=md.disposalMethod;
            if(idismet>0 && idismet<=3){
              idismet=idismet-1;
            }
           
           
           
            if(i==0 && (md.imageLeftPosition>0 || md.imageTopPosition>0
                  || md.imageHeight!=smd.logicalScreenHeight
                  || md.imageWidth!=smd.logicalScreenWidth)){
              // first frame must have no offset!
              BufferedImage tmp=new BufferedImage(smd.logicalScreenWidth,
                        smd.logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
 
              Graphics tmpg=tmp.getGraphics();
              tmpg.setColor(new Color(0,0,0,0));
              tmpg.fillRect(0, 0, smd.logicalScreenWidth, smd.logicalScreenHeight);
              tmpg.drawImage(reader.read(i), md.imageLeftPosition, md.imageTopPosition, null);
             
              theApng.addFrame(tmp, 0, 0, md.delayTime, idismet);
            } else {
                theApng.addFrame(reader.read(i), md.imageLeftPosition, md.imageTopPosition,
                         md.delayTime, idismet)
            }
           
        
          } // add all frames
         

         
          //add tEXt-chunk here
          theApng.maChunks.add(new ChunktEXt()); //software-note
          //and all comments from the gif:
          theApng.maChunks.add(new ChunktEXt("Comment",readgifinfo.getComment()));
 
          //close reader & stream
          reader.dispose();
          fis.close();
         
View Full Code Here


         
         
 
 
          int numLoops=ChunkacTL.INFINITE_LOOP;
          GifInfo readgifinfo=new GifInfo(readGif);
        numLoops=readgifinfo.getLoops();
 
        theApng=new APNG(smd.logicalScreenWidth,smd.logicalScreenHeight,mode, numLoops,
                       (mode==Emodes.PALETTE)? smd.globalColorTable : null, iTransparency);
         
          //now add frames (by using BufferedImage)
         
          //tell callback how many frame there are
          if(callback!=null){
            callback.updatemax(numImages);
          }
         
          // prepare our workers
          ExecutorService threadExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
         
          // Disposal-Methods:
          // method name(gif-method-number -> apng-method-number):
          //  unknown(0->0(ignored)), no disposal(1->0)
          //  restore to background(2->1), restore to previous(3->2)
          int seqNr = 0;
          for(int i=0;i<numImages;i++){
           
            //if stop-button is clicked
        if(Thread.currentThread().isInterrupted()){
          //close reader & stream
                reader.dispose();
                fis.close();
                throw new CancellationException("stop-button was pushed");
        }
       
            //callback current frame:
              if(callback!=null){
                callback.updatecur(i+1);
              }   
           
            md=(GIFImageMetadata) reader.getImageMetadata(i);
            int idismet=md.disposalMethod;
            if(idismet>0 && idismet<=3){
              idismet=idismet-1;
            }
           
           
           
            if(i==0 && (md.imageLeftPosition>0 || md.imageTopPosition>0
                  || md.imageHeight!=smd.logicalScreenHeight
                  || md.imageWidth!=smd.logicalScreenWidth)){
              // first frame must have no offset!
              BufferedImage tmp=new BufferedImage(smd.logicalScreenWidth,
                        smd.logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
 
              Graphics tmpg=tmp.getGraphics();
              tmpg.setColor(new Color(0,0,0,0));
              tmpg.fillRect(0, 0, smd.logicalScreenWidth, smd.logicalScreenHeight);
              tmpg.drawImage(reader.read(i), md.imageLeftPosition, md.imageTopPosition, null);
             
              //theApng.addFrame(tmp, 0, 0, md.delayTime, idismet);
              FrameThread ft = new FrameThread(theApng,tmp, 0, 0, md.delayTime, idismet,seqNr);
              threadExecutor.execute(ft);
            } else {
              FrameThread ft = new FrameThread(theApng,reader.read(i), md.imageLeftPosition, md.imageTopPosition,md.delayTime, idismet,seqNr);
              threadExecutor.execute(ft);
            }
           
            // incr seqnr
            if (i == 0)
            {
              seqNr++;  // first idat has no seqnr
            }
            else
            {
              seqNr+=2;
            }
        
          } // add all frames
         
          // all threads should come to an end now
          threadExecutor.shutdown(); // shutdown worker threads
          while (!threadExecutor.isTerminated())
          {
            try
        {
          threadExecutor.awaitTermination(60,TimeUnit.SECONDS);
        }
        catch (InterruptedException e)
        {
          e.printStackTrace();
        }
          }
          // seperate chunk list has to be now integrated
          // this has to happen because of the parallel working threads
          theApng.integrateChunks();
         
          //add tEXt-chunk here
          theApng.maChunks.add(new ChunktEXt()); //software-note
          //and all comments from the gif:
          theApng.maChunks.add(new ChunktEXt("Comment",readgifinfo.getComment()));
 
          //close reader & stream
          reader.dispose();
          fis.close();
         
View Full Code Here

         
         
 
 
          int numLoops=ChunkacTL.INFINITE_LOOP;
          GifInfo readgifinfo=new GifInfo(readGif);
        numLoops=readgifinfo.getLoops();
 
        theApng=new APNG(smd.logicalScreenWidth,smd.logicalScreenHeight,mode, numLoops,
                       (mode==Emodes.PALETTE)? smd.globalColorTable : null, iTransparency);
         
          //now add frames (by using BufferedImage)
         
          //tell callback how many frame there are
          if(callback!=null){
            callback.updatemax(numImages);
          }
         
          // Disposal-Methods:
          // method name(gif-method-number -> apng-method-number):
          //  unknown(0->0(ignored)), no disposal(1->0)
          //  restore to background(2->1), restore to previous(3->2)
          for(int i=0;i<numImages;i++){
           
            //if stop-button is clicked
        if(Thread.currentThread().isInterrupted()){
          //close reader & stream
                reader.dispose();
                fis.close();
                throw new CancellationException("stop-button was pushed");
        }
       
            //callback current frame:
              if(callback!=null){
                callback.updatecur(i+1);
              }   
           
            md=(GIFImageMetadata) reader.getImageMetadata(i);
            int idismet=md.disposalMethod;
            if(idismet>0 && idismet<=3){
              idismet=idismet-1;
            }
           
           
           
            if(i==0 && (md.imageLeftPosition>0 || md.imageTopPosition>0
                  || md.imageHeight!=smd.logicalScreenHeight
                  || md.imageWidth!=smd.logicalScreenWidth)){
              // first frame must have no offset!
              BufferedImage tmp=new BufferedImage(smd.logicalScreenWidth,
                        smd.logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
 
              Graphics tmpg=tmp.getGraphics();
              tmpg.setColor(new Color(0,0,0,0));
              tmpg.fillRect(0, 0, smd.logicalScreenWidth, smd.logicalScreenHeight);
              tmpg.drawImage(reader.read(i), md.imageLeftPosition, md.imageTopPosition, null);
             
              theApng.addFrame(tmp, 0, 0, md.delayTime, idismet);
            } else {
                theApng.addFrame(reader.read(i), md.imageLeftPosition, md.imageTopPosition,
                         md.delayTime, idismet)
            }
           
        
          } // add all frames
         

         
          //add tEXt-chunk here
          theApng.maChunks.add(new ChunktEXt()); //software-note
          //and all comments from the gif:
          theApng.maChunks.add(new ChunktEXt("Comment",readgifinfo.getComment()));
 
          //close reader & stream
          reader.dispose();
          fis.close();
         
View Full Code Here

TOP

Related Classes of gif.GifInfo

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.