Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * @(#)ColorCycle.java  1.1  2010-08-03
   * 
   * Copyright (c) 2009-2010 Werner Randelshofer, Goldau, Switzerland.
   * All rights reserved.
   *
   * You may not use, copy or modify this file, except in compliance with the
   * license agreement you entered into with Werner Randelshofer.
   * For details see accompanying license terms.
  */
 package org.monte.media.ilbm;

Implements CRNG and CCRT color cycling for an IFF ILBM image.

This class supports CRNG and CCRT color cycling as published in AMIGA ROM Kernel Reference Manual: Devices, Third Edition, Addison-Wesley, Reading ISBN 0-201-56775-X

 //ILBM CRNG Color range cycling
 //--------------------------------------------

 #define RNG_NORATE  36   // Dpaint uses this rate to mean non-active
  set {
  active = 1, reverse = 2
  } crngActive;

  // A CRange is store in a CRNG chunk.
  typedef struct {
  WORD  pad1;              // reserved for future use; store 0 here *
  WORD  rate;              // 60/sec=16384, 30/sec=8192, 1/sec=16384/60=273
  WORD set crngActive flags;     // bit0 set = active, bit 1 set = reverse
  UBYTE low; UBYTE high;         // lower and upper color registers selected
  } ilbmColorRegisterRangeChunk;
 
 ILBM CCRT Color cycling range and timing
 --------------------------------------------
 /
 enum {
 dontCycle = 0, forward = 1, backwards = -1
 } ccrtDirection;
 typedef struct {
 WORD enum ccrtDirection direction;  /* 0=don't cycle, 1=forward, -1=backwards * /
 UBYTE start;      /* range lower * /
 UBYTE end;        /* range upper * /
 LONG  seconds;    /* seconds between cycling * /
 LONG  microseconds; /* msecs between cycling * /
 WORD  pad;        /* future exp - store 0 here * /
 } ilbmColorCyclingAndTimingChunk;

 

Author(s):
Werner Randelshofer
Version:
1.1 2010-08-03 Added support for blended color cycles.
1.0.1 2010-11-08 Fixed color cycling rate.
1.0 2009-12-23 Created.
 
 public class CRNGColorCycle extends ColorCycle {

    
Lowest color register of the range.
 
     private int low;
    
Highest color register of the range.
 
     private int high;
    
Whether the color cycle is reverse.
 
     private boolean isReverse;
    
Whether the image is in EHB mode.
 
     private boolean isEHB;
 
     public CRNGColorCycle(int rateint timeScaleint lowint highboolean isActiveboolean isReverseboolean isEHB) {
         super(ratetimeScaleisActive);
         this. = low;
         this. = high;
         this. = isReverse;
         this. = isEHB;
     }
 
     public boolean isReverse() {
         return ;
     }
 
     public int getLow() {
         return ;
     }
 
     public int getHigh() {
         return ;
     }
 
     @Override
     public void doCycle(int[] rgbslong time) {
         if () {
             doBlendedCycle(rgbstime);
         } else {
             doHardCycle(rgbs,time);
        }
    }
    public void doBlendedCycle(int[] rgbslong time) {
        if () {
            doHardCycle(rgbstime);
            double blendf =  Math.IEEEremainder((time *  /  / 1000f),  -  + 1);
            blendf = blendf - Math.floor(blendf);
            int blend =  255-(int)(blendf*255);
            if () {
                {
                    blend=255-blend;
                    int tmp = rgbs[];
                    for (int i = i > i--) {
                        rgbs[i] = ((((rgbs[i]&0xff)*blend+(rgbs[i - 1]&0xff)*(255-blend))>>8)&0xff)
                                |((((rgbs[i]&0xff00)*blend+(rgbs[i - 1]&0xff00)*(255-blend))>>8)&0xff00)
                                |((((rgbs[i]&0xff0000)*blend+(rgbs[i - 1]&0xff0000)*(255-blend))>>8)&0xff0000);
                    }
                    rgbs[] =  ((((rgbs[]&0xff)*blend+(tmp&0xff)*(255-blend))>>8)&0xff)
                                |((((rgbs[]&0xff00)*blend+(tmp&0xff00)*(255-blend))>>8)&0xff00)
                                |((((rgbs[]&0xff0000)*blend+(tmp&0xff0000)*(255-blend))>>8)&0xff0000);;
                }
                if () {
                // TO DO
                }
            } else {
                {
                    int tmp = rgbs[];
                    for (int i = i > i--) {
                        rgbs[i] = ((((rgbs[i]&0xff)*blend+(rgbs[i - 1]&0xff)*(255-blend))>>8)&0xff)
                                |((((rgbs[i]&0xff00)*blend+(rgbs[i - 1]&0xff00)*(255-blend))>>8)&0xff00)
                                |((((rgbs[i]&0xff0000)*blend+(rgbs[i - 1]&0xff0000)*(255-blend))>>8)&0xff0000);
                    }
                    rgbs[] =  ((((rgbs[]&0xff)*blend+(tmp&0xff)*(255-blend))>>8)&0xff)
                                |((((rgbs[]&0xff00)*blend+(tmp&0xff00)*(255-blend))>>8)&0xff00)
                                |((((rgbs[]&0xff0000)*blend+(tmp&0xff0000)*(255-blend))>>8)&0xff0000);;
                }
                if () {
                    // TO DO
                }
            }
        }
    }
    public void doHardCycle(int[] rgbslong time) {
        if () {
            int shift = (int) ((time *  /  / 1000) % ( -  + 1));
            if () {
                for (int j = 0; j < shiftj++) {
                    int tmp = rgbs[];
                    for (int i = i < i++) {
                        rgbs[i] = rgbs[i + 1];
                    }
                    rgbs[] = tmp;
                }
                if () {
                    for (int j = 0; j < shiftj++) {
                        int tmp = rgbs[ + 32];
                        for (int i =  + 32; i <  + 32; i++) {
                            rgbs[i] = rgbs[i + 1];
                        }
                        rgbs[ + 32] = tmp;
                    }
                }
            } else {
                for (int j = 0; j < shiftj++) {
                    int tmp = rgbs[];
                    for (int i = i > i--) {
                        rgbs[i] = rgbs[i - 1];
                    }
                    rgbs[] = tmp;
                }
                if () {
                    for (int j = 0; j < shiftj++) {
                        int tmp = rgbs[ + 32];
                        for (int i =  + 32; i >  + 32; i--) {
                            rgbs[i] = rgbs[i - 1];
                        }
                        rgbs[ + 32] = tmp;
                    }
                }
            }
        }
    }
New to GrepCode? Check out our FAQ X