国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

古代帝國中的圖片資源節省算法

2019-11-18 14:55:00
字體:
來源:轉載
供稿:網友

代碼:

 /**
  * 圖片轉換
  * @param content 原始圖片信息
  * @param type 類型,1 :中立角色 2 : 敵方 0 :自己
  */
 public static void imgConvert(byte content[], int type){
  try{
   int pos = 33;
   int relpos = 0;
   relpos = ((content[pos] & 0xff) << 24 (content[pos + 1] & 0xff) << 16 (content[pos + 2] & 0xff) << 8 content[pos + 3] & 0xff) & -1;
   pos += 4;
   int newcolor = -1;
   for(int idx = 0; idx < 4; idx++)
    newcolor = pixelConvert(content[pos + idx], newcolor);

   pos += 4;
   boolean flag = true;
   boolean flag1 = false;
   boolean flag2 = false;
   for(int idx = pos; idx < pos + relpos; idx += 3){
    int b = content[idx] & 0xff;
    int g = content[idx + 1] & 0xff;
    int r = content[idx + 2] & 0xff;
    if(r > b && r > g){
     //綠色和藍色互換,中立角色
     if(type == 1){
      int tmp = b;
      b = g;
      r = b;
      g /= 2;
      }
      //轉換為紅色,敵人角色
     else if (type == 2){
      b = r;
      g = r;
      }
     content[idx] = (byte)b;
     content[idx + 1] = (byte)g;
     content[idx + 2] = (byte)r;
     }
    newcolor = pixelConvert(content[idx], newcolor);
    newcolor = pixelConvert(content[idx + 1], newcolor);
    newcolor = pixelConvert(content[idx + 2], newcolor);
    }
   
   newcolor = ~newcolor;
   int actpos = 41 + relpos;
   content[actpos] = (byte)(newcolor >> 24);
   content[actpos + 1] = (byte)(newcolor >> 16);
   content[actpos + 2] = (byte)(newcolor >> 8);
   content[actpos + 3] = (byte)newcolor;
   }
  catch(Exception e){}
  }
 
 /**
  * 像素轉換
  * @param pixel 像素
  * @param color 顏色值
  * @return
  */
 public static int pixelConvert(byte pixel, int color){
  int tmp = pixel & 0xff;
  color ^= tmp;
  for(int idx = 0; idx < 8; idx++)
   if((color & 1) != 0)
   //土黃色
    color = color >>> 1 ^ 0xedb88320;
   else
    color >>>= 1;
  return color;
  }



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 广东省| 怀柔区| 湟源县| 仁布县| 海晏县| 苗栗市| 图木舒克市| 宣化县| 沁水县| 衡南县| 虞城县| 肇源县| 漳平市| 绥滨县| 大宁县| 县级市| 盐源县| 正定县| 阳江市| 南漳县| 义马市| 清原| 合川市| 石楼县| 本溪市| 长春市| 玉屏| 福贡县| 政和县| 巩留县| 常宁市| 禄丰县| 宁河县| 涟源市| 元阳县| 梅河口市| 乐山市| 晋宁县| 顺平县| 宝山区| 彭山县|