现在的位置: 首页 > 综合 > 正文

图像去除彩色源代码

2018年01月29日 ⁄ 综合 ⁄ 共 445字 ⁄ 字号 评论关闭

#define EXTRA_NAME "@nocolor."
#include "loadbmp.h"

void NoColor()
{
 if (lpBitmap==0) return;
 int x,y,p;
 BYTE Point;
 for(y=0;y<nHeight;y++)
  for(x=0;x<nWidth;x++)
  {
   p=x*3+y*nByteWidth;
   Point=(BYTE)(0.299*(float)lpBits[p+2]+0.587*(float)lpBits[p+1]+0.114*(float)lpBits[p]+0.1);
   lpBits[p+2]=Point;
   lpBits[p+1]=Point;
   lpBits[p]=Point;
  }
}

void main(int argc, char *argv[])
{
 if(argc==2)
  FileName=argv[1];
 else
  return; 
 OpenFile();
 NoColor();
 SaveAs();
}

抱歉!评论已关闭.