Kenny_Liu's profile入乡随俗PhotosBlogListsMore ![]() | Help |
|
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); } TrackbacksThe trackback URL for this entry is: http://killerliu.spaces.live.com/blog/cns!6EF2055BD4ADB55E!225.trak Weblogs that reference this entry
|
|
|