Chinaunix首页 | 论坛 | 博客
  • 博客访问: 735212
  • 博文数量: 769
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4985
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:37
文章分类

全部博文(769)

文章存档

2011年(1)

2008年(768)

我的朋友

分类:

2008-10-15 16:40:08

 //================================================================
int fclamp0255 (int nvalue) {return max (0, min (0xff, nvalue));} // 饱和到0--255

class fcobjimage
{
 public :
  invert () ;
  adjustrgb (int r, int g, int b) ;
} ;
//================================================================
void fcobjimage::invert ()
{
 if ((gethandle() == null) (colorbits() < 24))
  return ;

 int nspan = colorbits() / 8 ; // 每象素字节数3, 4
 for (int y=0 ; y < height() ; y++)
 {
  byte * ppixel = getbits (y) ;
  for (int x=0 ; x < width() ; x++, ppixel += nspan)
  {
   ppixel[0] = ~ppixel[0] ;
   ppixel[1] = ~ppixel[1] ;
   ppixel[2] = ~ppixel[2] ;
  }
 }
}
//================================================================
void fcobjimage::adjustrgb (int r, int g, int b)
{
 if ((gethandle() == null) (colorbits() < 24))
  return ;

 int nspan = colorbits() / 8 ; // 每象素字节数3, 4
 for (int y=0 ; y < height() ; y++)
 {
  byte * ppixel = getbits (y) ;
  for (int x=0 ; x < width() ; x++, ppixel += nspan)
  {
   ppixel[0] = fclamp0255 (ppixel[0] + b) ;
   ppixel[1] = fclamp0255 (ppixel[1] + g) ;
   ppixel[2] = fclamp0255 (ppixel[2] + r) ;
  }
 }
}
//================================================================


--------------------next---------------------

阅读(481) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~