bt:Tbitmap;
line
bytearray;
bt:=Tbitmap.create;
bt.loadfromfile('');
bt.PixelFormat := pf24bit;
line:=pbytearray(bt.scanline[y]);// y:要得到图象像素的行。line 是一个指针,第一个像素的值是line[0],line[1],line[2]代表rgb三色,以后类推。
bt.pixlformat:=pf8bit;
bt.savetofile('');
bt.free;
//line 的值可读,可写。
大概就这样,得到像素值还有一个函数,getRvalue(bt.Canvas.Pixels[x,y]) 红;getGvalue(bt.Canvas.Pixels[x,y]) 绿;getBvalue(bt.Canvas.Pixels[x,y]) 蓝;
设置时,用bt.Canvas.Pixels[x,y]:=rgb(R,G,B);
写的应该很明白,有什么问题在说。
在加一点,在事件中用,需要刷新。(把程序最小化,在还原就可以了)否则你可能看不到效果。