亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? imageset.java

?? 大量j2me源代碼
?? JAVA
字號:
/**
 * A container for sets of image frames; typically sprites. A single set
 * is made up of one or more states. Each state represents an animation sequence
 * including Image objects for the frames, animation timing and frame dimensions.
 * <p>
 * An example use of this class would be to animate a little dude. If he had two
 * states of existence, standing (which has short breathing animation) and
 * walking (which has a much longer animation). This would be implemented by
 * creating an ImageSet object and then adding two states, each with their own
 * Image array for all the animation frames (use the static methods at the end
 * of this class to load a clipped file image and then extract the image frame
 * array from it). You can then use a Sprite class associated with this ImageSet
 * to draw the character to the screen as well as keep track of animation frames.
 * <p>
 * This version expands on the original ImageSet concept by adding an option for
 * the images in a state to be reflected dynamically using the Nokia UI. This
 * saves image memory space becuase you no longer need to cache reflected images
 * you can render them on the fly.
 * <p>
 * This version also adds an option for a very simple state that has only a
 * single image frame. This means you can do without using an array for all the
 * image access (something done very often). Array access is a lot slower than
 * a single image.
 * <p>
 * @see Sprite
 */

//#ifdef nokia

import com.nokia.mid.ui.DirectGraphics;
import com.nokia.mid.ui.DirectUtils;
//#endif
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
import java.io.IOException;

public class ImageSet
{
   private int totalStates;		// incremented by addState method only

   // can either use multiple frames for each state or single (much faster)
   private Image[][] stateFramesMulti;
   private Image[] stateFramesSingle;

   // reflection types are based on nokia UI.
   private int[] stateAnimTime, stateReflectionOf, stateReflectionType;
   private boolean singleImage;

   public static final int FLIP_HORIZONTAL = 8192;
   public static final int FLIP_VERTICAL = 16384;

   public ImageSet(int numStates, boolean isSingleImage)
   {
      singleImage = isSingleImage;

      stateAnimTime = new int[numStates];
      stateReflectionOf = new int[numStates];
      stateReflectionType = new int[numStates];

      if (singleImage)
         stateFramesSingle = new Image[numStates];
      else
         stateFramesMulti = new Image[numStates][];

   }

   /**
    * Quick version of the addState method that takes an image arrray and anim
    * time.
    * @param frames The image frames.
    * @param animTime The time to animate through all those images.
    * @return The number of the new state.
    */
   public final int addState(Image frames[], int animTime)
   {
      return addState(frames, animTime, 0, 0);
   }

   /**
    * Adds a new state with which is a reflection of another one. Whenever
    * the images for this state are rendered the images from to reflectionOf
    * state will be drawn instead using the reflection specified in the
    * reflectionType parameter.
    * @param frames The images for the state, or null if reflectionOf is set.
    * @param animTime The animation time for this state.
    * @param reflectionOf The number of another state in this ImageSet to
    * create a reflection of.
    * @param reflectionType The type of reflection (FLIP_HORIZONTAL |
    * FLIP_VERTICAL)
    * @return The number of the new state.
    */
   public final int addState(Image frames[], int animTime, int reflectionOf,
                             int reflectionType)
   {
      int state = totalStates++;
      if (state >= stateAnimTime.length)
         expandArrays();

      stateAnimTime[state] = animTime;
      stateFramesMulti[state] = frames;
      stateReflectionOf[state] = reflectionOf;
      stateReflectionType[state] = reflectionType;
      return state;
   }

   /**
    * Adds a new state with which is a reflection of another one using
    * a single image source (for speed).
    * @param reflectionOf The number of another state in this ImageSet to
    * create a reflection of.
    * @param reflectionType The type of reflection (FLIP_HORIZONTAL |
    * FLIP_VERTICAL)
    * @return The number of the new state.
    */
   public final int addState(Image frame, int reflectionOf, int reflectionType)
   {
      int state = totalStates++;
      if (state >= stateAnimTime.length)
         expandArrays();

      stateReflectionOf[state] = reflectionOf;

      if (reflectionOf == -1)
         stateFramesSingle[state] = frame;
      else
         stateReflectionType[state] = reflectionType;
      return state;
   }

   public void expandArrays()
   {
      // expand the number of states
      if (singleImage)
         stateFramesSingle = expandArray(stateFramesSingle, 1);
      else
      {
         stateFramesMulti = expandArray(stateFramesMulti, 1);
         stateAnimTime = expandArray(stateAnimTime, 1);
      }

      stateReflectionOf = expandArray(stateReflectionOf, 1);
      stateReflectionType = expandArray(stateReflectionType, 1);
   }

   // Enahcned versions of expand array copied in from a tools class.
   public final static int[] expandArray(int[] oldArray, int expandBy)
   {
      int[] newArray = new int[oldArray.length + expandBy];
      System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
      return newArray;
   }

   public final static Image[] expandArray(Image[] oldArray, int expandBy)
   {
      Image[] newArray = new Image[oldArray.length + expandBy];
      System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
      return newArray;
   }

	public final static Image[][] expandArray(Image[][] oldArray, int expandBy)
	{
		Image[][] newArray = new Image[oldArray.length + expandBy][];
		System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
		return newArray;
	}

   public final int getTotalFrames(int state)
   {
      //#ifdef debug
      if (state >= totalStates)
         System.out.println("oops, trying to get state: " + state + " when totalStates = " + totalStates);
      //#endif
      if (singleImage)
         return 1;
      else
         return stateFramesMulti[state].length;
   }

   public final int getAnimTime(int state)
   {
      return stateAnimTime[state];
   }

   public final int getAnimTimePerFrame(int state)
   {
      if (singleImage) return 0;
      return stateAnimTime[state] / stateFramesMulti[state].length;
   }

   /**
    * Draw a specific frame of this sprite onto a graphics object
    */
   public final void draw(Graphics target, int state, int frame, int targetX, int targetY)
   {
      //#ifdef debug
      if (state >= totalStates)
         System.out.println("oops, bad state " + state + " total states = " + totalStates);

      if (!singleImage && frame >= stateFramesMulti[state].length)
         System.out.println("oops, bad frame " + frame + " in draw(" +
                            frame + ", " + state + ")");
      //#endif

      if (singleImage)
      {
         if (stateReflectionOf[state] != -1)
         {
            drawReflectedImage(target, stateFramesSingle[stateReflectionOf[state]],
                               targetX, targetY,
                               stateReflectionType[state]);
         }
         else
         {

            target.drawImage(stateFramesSingle[state],
                             targetX, targetY, Tools.GRAPHICS_TOP_LEFT);
         }

      }
      else
      {
         // note: reflections on multi frame states not supported (yet)
         target.drawImage(stateFramesMulti[state][frame],
                          targetX, targetY, Tools.GRAPHICS_TOP_LEFT);
      }
   }

   /**
    * get a specific frame
    */
   public final Image getFrame(int state, int frame)
   {
      //#ifdef debug
      if (state >= totalStates)
         System.out.println("oops, bad state " + state);

      if (singleImage && frame >= stateFramesMulti[state].length)
         System.out.println("oops, bad frame " + state + ", " + frame + " in getFrame()");
      //#endif

      if (singleImage)
         return stateFramesSingle[state];
      else
         return stateFramesMulti[state][frame];
   }


   //
   // STATIC IMAGE TOOLS
   //

   public final static Image loadClippedImage(String filename, int originX, int originY, int width,
                                              int height)
   {
      try
      {
         // load full image from file and create a mutable version
         Image fileImage = Image.createImage(filename);
         return getImageRegion(fileImage, originX, originY, width, height);
      }

      catch (IOException ioe)
      {
         System.out.println("can't load file: " + filename);
         return null;
      }
   }

   public final static Image loadClippedImage(String filename, int originX, int originY)
   {
      try
      {
         // load full image from file and create a mutable version
         Image fileImage = Image.createImage(filename);
         return getImageRegion(fileImage, originX, originY, fileImage.getWidth(), fileImage.getHeight());
      }

      catch (IOException ioe)
      {
         System.out.println("can't load file: " + filename);
         return null;
      }
   }

   public final static Image getImageRegion(Image source, int x, int y, int width, int height)
   {
      // create a placeholder for our resulting image region
      Image result = null;

      //#ifdef nokia
      result = DirectUtils.createImage(width, height, 0x00000000);
      //#else
      result = Image.createImage(width, height);
      //#endif

      if (x + width > source.getWidth() || y + height > source.getHeight())
         System.out.println("Warning: attempting extract using (" +
                            x + "," + y + "," + width + "," + height + ") when image is " +
                            "(" + source.getWidth() + "," + source.getHeight() + ")");

      // set the clipping region so we ignore the portion of the source image to
      // the right and bottom of the region we want
      result.getGraphics().setClip(0, 0, width, height);

      // draw the image, offset by the region starting position
      result.getGraphics().drawImage(source, -x, -y, Tools.GRAPHICS_TOP_LEFT);

      return result;
   }

   public final static Image[] extractFrames(Image sourceImage, int sourceX, int sourceY,
                                             int framesWide, int framesHigh,
                                             int frameWidth, int frameHeight)
   {
      // auto-detect the frame width if it wasn't supplied (based on total image
      // size.
      if (frameWidth == 0) frameWidth = sourceImage.getWidth() / framesWide;
      if (frameHeight == 0) frameHeight = sourceImage.getHeight() / framesHigh;

      // extract all the frames from the source image
      Image[] frames = new Image[framesWide * framesHigh];
      int frameCount = 0;

      for (int fy = 0; fy < framesHigh; fy++)
         for (int fx = 0; fx < framesWide; fx++)
            frames[frameCount++] =
                    getImageRegion(sourceImage, sourceX + (fx * frameWidth),
                                   sourceY + (fy * frameHeight),
                                   frameWidth, frameHeight);
      return frames;
   }


   public final static void drawReflectedImage(Graphics g, Image source, int x, int y,
                                               int flipType)
   {
      DirectGraphics rdg = DirectUtils.getDirectGraphics(g);
      rdg.drawImage(source, x, y, Tools.GRAPHICS_TOP_LEFT, flipType);
   }


}











?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲日韩av| 国产精品18久久久久久久网站| 欧美日韩dvd在线观看| 欧美精品精品一区| 日韩在线卡一卡二| 欧美日韩亚洲国产综合| 亚洲欧美成人一区二区三区| 色八戒一区二区三区| 亚洲精品国产第一综合99久久 | 一区二区三区中文字幕精品精品 | 色婷婷综合久久久中文字幕| 亚洲猫色日本管| 欧美日韩国产系列| 久久精品久久综合| 国产精品久99| 欧美三级午夜理伦三级中视频| 日韩国产成人精品| 久久久影院官网| 色悠悠久久综合| 日韩精品电影在线观看| 国产亚洲一区二区三区在线观看| 99视频精品在线| 亚洲成人动漫在线观看| www久久久久| 日本道在线观看一区二区| 蜜臀av性久久久久蜜臀aⅴ | 亚洲欧美偷拍另类a∨色屁股| 欧亚洲嫩模精品一区三区| 蜜桃视频一区二区三区在线观看| 国产三级欧美三级| 欧美视频一区二区三区四区 | 欧美激情中文不卡| 欧美日韩国产成人在线91| 99国产欧美久久久精品| 亚洲国产sm捆绑调教视频| 久久综合色播五月| 在线亚洲免费视频| 韩国av一区二区三区四区| 一区二区三区四区不卡在线 | 亚洲精品自拍动漫在线| 日韩精品一区二区三区在线播放 | 丁香啪啪综合成人亚洲小说| 亚洲第一福利视频在线| www久久精品| 3atv一区二区三区| 91色视频在线| 国产乱码精品一区二区三区忘忧草 | 日韩高清在线电影| 亚洲欧美视频一区| 久久精品夜色噜噜亚洲a∨| 欧美男女性生活在线直播观看| 岛国精品在线观看| 国产一区欧美二区| 日韩精品一二区| 一级特黄大欧美久久久| 国产女人水真多18毛片18精品视频 | 日韩精品资源二区在线| 欧洲av一区二区嗯嗯嗯啊| 99国产精品久| 成人白浆超碰人人人人| 国产精品一区二区久激情瑜伽| 日本成人在线一区| 日韩国产欧美三级| 亚洲一卡二卡三卡四卡五卡| 亚洲猫色日本管| 亚洲欧美乱综合| 亚洲欧美中日韩| 中文字幕在线观看一区| 国产精品久久久久久户外露出 | 亚洲国产精品一区二区www在线| 中文字幕亚洲区| 日本一区二区三区视频视频| 久久天堂av综合合色蜜桃网| 日韩精品一区二区三区在线播放 | 欧美精品tushy高清| 在线观看国产精品网站| 精品粉嫩超白一线天av| 欧美揉bbbbb揉bbbbb| 欧美视频在线不卡| 91精品国产日韩91久久久久久| 精品视频一区二区三区免费| 欧美日韩国产另类不卡| 91精品蜜臀在线一区尤物| 666欧美在线视频| 日韩一卡二卡三卡四卡| 日韩欧美中文一区| 久久青草欧美一区二区三区| 中文字幕免费不卡在线| 中文字幕欧美一| 亚洲专区一二三| 首页国产欧美久久| 蜜臀久久99精品久久久画质超高清| 看电影不卡的网站| 国产精品一区二区久激情瑜伽| 成人av免费在线| 欧美在线视频日韩| 91精品久久久久久久91蜜桃| 精品国产区一区| 国产精品成人免费在线| 亚洲在线免费播放| 蜜桃视频免费观看一区| 成人综合婷婷国产精品久久蜜臀| 99re亚洲国产精品| 欧美久久一二三四区| 精品国产成人系列| 自拍偷拍亚洲欧美日韩| 丝袜美腿亚洲色图| 国产麻豆成人传媒免费观看| 色域天天综合网| xfplay精品久久| 一区二区三区精品| 蜜桃视频免费观看一区| 99久久99久久精品免费看蜜桃| 欧美日韩在线电影| 欧美r级在线观看| 综合久久综合久久| 美国毛片一区二区三区| 国产高清亚洲一区| 在线观看亚洲成人| 久久久精品免费观看| 一区二区三区在线观看国产| 久久精品国产**网站演员| 波多野结衣91| 日韩欧美一二三四区| 国产精品久久久久久久久快鸭 | 国产一区二区免费视频| 色老汉一区二区三区| 亚洲欧美另类久久久精品| 精品在线播放免费| 日本乱人伦aⅴ精品| 久久先锋资源网| 亚洲午夜激情网页| 成人黄色大片在线观看| 制服视频三区第一页精品| 欧美韩国日本综合| 美女尤物国产一区| 在线观看成人免费视频| 国产女主播一区| 黄色资源网久久资源365| 色婷婷狠狠综合| 中文字幕欧美一区| 成人一级视频在线观看| 日韩精品一区二区三区swag| 亚洲综合色婷婷| 91免费在线视频观看| 久久人人爽人人爽| 精品午夜一区二区三区在线观看| 欧美日韩免费观看一区二区三区| 日本一区二区综合亚洲| 精品在线你懂的| 日韩女优制服丝袜电影| 三级不卡在线观看| 欧美熟乱第一页| 亚洲天堂2014| 91捆绑美女网站| 国产精品久久福利| 不卡视频一二三| 国产精品毛片大码女人| 国产精品亚洲一区二区三区妖精 | 欧美刺激脚交jootjob| 婷婷综合五月天| 欧美日韩中文字幕一区| 精品亚洲成av人在线观看| 欧美视频一区二区三区在线观看| 一区二区三区不卡在线观看 | 久久久久久久av麻豆果冻| 久久精品国产精品亚洲综合| 欧美一区二区三区日韩| 日本人妖一区二区| 日韩欧美高清在线| 久久99国产精品尤物| 精品91自产拍在线观看一区| 六月婷婷色综合| 精品国产乱码久久久久久老虎| 久久er99精品| 国产欧美日韩精品a在线观看| 国产不卡在线播放| 国产精品久久久久久久蜜臀| 91视频www| 亚洲国产乱码最新视频| 欧美日韩高清一区二区三区| 亚洲综合清纯丝袜自拍| 欧美日韩国产小视频| 卡一卡二国产精品| 久久久五月婷婷| 成人免费毛片app| 亚洲激情校园春色| 欧美日韩高清一区二区三区| 久久99热国产| 国产精品美女一区二区在线观看| 波多野结衣亚洲| 亚洲电影第三页| 精品久久一区二区三区| 国产99久久久精品| 亚洲一区二区三区不卡国产欧美| 在线不卡的av| 高清成人在线观看| 亚洲一区视频在线| 久久久精品2019中文字幕之3| 91免费观看国产|