コード例 #1
0
 public void adjustFrameIndex(Map<Integer, Integer> frameMap) {
   for (int i = 0; i < pieces.size(); i++) {
     PipAnimateFramePiece piece = pieces.get(i);
     int id = (piece.getImageID() << 16) | piece.getFrame();
     if (frameMap.containsKey(id)) {
       int newFrame = frameMap.get(id);
       piece.setImageID(newFrame >> 16);
       piece.setFrame(newFrame & 0xFFFF);
     }
   }
 }
コード例 #2
0
 // 拟合绘制过渡帧
 public void drawTransform(
     GLGraphics g,
     int x,
     int y,
     double ratio,
     ImageDrawCache cache,
     PipAnimateFrame nextFrame,
     double percent,
     int rotate,
     int scalex,
     int scaley,
     int color) {
   if (parent.drawFrameListener != null) {
     if (!parent.drawFrameListener.beforeDrawFrame(parent, this, g, x, y, ratio)) {
       return;
     }
   }
   int count = pieces.size();
   for (int i = 0; i < count; i++) {
     PipAnimateFramePiece piece = pieces.get(i);
     if (!piece.visible) {
       continue;
     }
     PipAnimateFramePiece nextPiece = null;
     if (nextFrame != null) {
       for (int j = 0; j < nextFrame.getPieceCount(); j++) {
         PipAnimateFramePiece np = nextFrame.getPiece(j);
         if (np.getImageID() == piece.getImageID()
             && np.getFrame() == piece.getFrame()
             && np.getTransition() == piece.getTransition()) {
           nextPiece = np;
           break;
         }
       }
     }
     piece.drawTransform(g, x, y, ratio, cache, nextPiece, percent, rotate, scalex, scaley, color);
   }
   if (parent.drawFrameListener != null) {
     parent.drawFrameListener.afterDrawFrame(parent, this, g, x, y, ratio);
   }
 }
コード例 #3
0
 public void adjustFrameIndex(int image, Map<Integer, Integer> frameMap) {
   for (int i = 0; i < pieces.size(); i++) {
     PipAnimateFramePiece piece = pieces.get(i);
     if (piece.getImageID() == image) {
       Integer newFrame = frameMap.get(piece.getFrame());
       if (newFrame == null) {
         pieces.remove(i);
         i--;
       } else {
         piece.setFrame(newFrame.intValue());
       }
     }
   }
 }
コード例 #4
0
 public void load(DataInputStream dis, boolean isctn) throws IOException {
   if (isctn) {
     name = "N/A";
   } else {
     name = dis.readUTF();
   }
   int fcount = dis.readByte() & 0xFF;
   for (int i = 0; i < fcount; i++) {
     PipAnimateFramePiece piece = new PipAnimateFramePiece(this);
     piece.load(dis);
     if (!isctn) {
       if (piece.getImageID() >= parent.getFileCount()) {
         // 检查依赖的图片是否存在
         continue;
       }
       PipImage sourceImg = parent.getSourceImage(piece.getImageID());
       if (piece.getFrame() >= sourceImg.getImgCount() * sourceImg.getImagePalettes().size()) {
         // 检查指定的帧是否存在
         continue;
       }
     }
     pieces.add(piece);
   }
 }
コード例 #5
0
 public Rectangle getBounds(int repImg, int src, int tgt, int offx, int offy) {
   int minx = 0;
   int miny = 0;
   int maxx = 0;
   int maxy = 0;
   for (int i = 0; i < pieces.size(); i++) {
     PipAnimateFramePiece piece = pieces.get(i);
     boolean replace = false;
     if (piece.getImageID() == repImg && piece.getFrame() == src) {
       piece.setFrame(tgt);
       piece.setDx(piece.getDx() + offx);
       piece.setDy(piece.getDy() + offy);
       replace = true;
     }
     int px = piece.getDx();
     int py = piece.getDy();
     int pw = piece.getWidth();
     int ph = piece.getHeight();
     if (px < minx) {
       minx = px;
     }
     if (py < miny) {
       miny = py;
     }
     if (px + pw > maxx) {
       maxx = px + pw;
     }
     if (py + ph > maxy) {
       maxy = py + ph;
     }
     if (replace) {
       piece.setFrame(src);
       piece.setDx(piece.getDx() - offx);
       piece.setDy(piece.getDy() - offy);
     }
   }
   Rectangle rect = new Rectangle(minx, miny, maxx - minx, maxy - miny);
   if (rect.isEmpty()) {
     rect = new Rectangle(0, 0, 16, 16);
   }
   return rect;
 }