Kenny_Liu's profile入乡随俗PhotosBlogListsMore Tools Help

Blog


    2/23/2006

    alpha混合Nokia版

    一年前的东西,忘记贴上来,有bug,不能透明
     
      void drawGame(Graphics g)
      {
        DirectGraphics dg;
        if (bkSrc==null){
          test = Image.createImage(bkWidth,bkHeight);     //为虾米要新创建一个涅,因为原来的image是不可变的,不能getPixels
          test.getGraphics().drawImage(bk,0,0,g.LEFT|g.TOP);
          bkSrc = new short[bk.getWidth()*bk.getHeight()];
          dg = DirectUtils.getDirectGraphics(test.getGraphics());
          dg.getPixels(bkSrc, 0, bkWidth, 0, 0, bkWidth, bkHeight, 444);
        }
       
        if (objSrc==null){
          test = Image.createImage(objWidth,objHeight);
          test.getGraphics().drawImage(obj,0,0,g.LEFT|g.TOP);
          objSrc = new short[obj.getWidth()*obj.getHeight()];
          dg = DirectUtils.getDirectGraphics(test.getGraphics());
          dg.getPixels(objSrc, 0, objWidth, 0, 0, objWidth, objHeight,444);
        }
        dg = DirectUtils.getDirectGraphics(g);
        g.drawImage(bk,0,0,g.LEFT|g.TOP);
        long a = System.currentTimeMillis();
        short drawSrc[] = new short[obj.getWidth()*obj.getHeight()];   
        for (int i = 0;i<objSrc.length;i++){
          short obj = objSrc[i];
          int line = i/objWidth;
          int row = i%objWidth;
          short bk = bkSrc[line*bkWidth+row];
          int objR = obj>>8&0xf;
          int objG = obj>>4&0xf;
          int objB = obj&0xf;
          int bkR = bk>>8&0xf;
          int bkG = bk>>4&0xf;
          int bkB = bk&0xf;
          objR = objR*per/100+bkR*(100-per)/100;
          objG = objG*per/100+bkG*(100-per)/100;
          objB = objB*per/100+bkB*(100-per)/100;
          System.out.println(objSrc[i]&0xf000);
          drawSrc[i] = (short)(objSrc[i]&0xf000|((objR<<8)|(objG<<4)|objB));
        }
        dg.drawPixels(drawSrc,false,0,objWidth,0,0,objWidth,objHeight,0,444);
        g.drawString((System.currentTimeMillis()-a)+"",0,0,g.LEFT|g.TOP);
      }

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://killerliu.spaces.live.com/blog/cns!6EF2055BD4ADB55E!225.trak
    Weblogs that reference this entry
    • None