// This example shows drawing directly to the BitMap
var
x,y : Integer;
BitMap : TBitMap;
P : PByteArray;
begin
BitMap := TBitMap.create;
try
// On Windows replace MyBitmap.png with a full pathname such as
// C:\Program Files\Common Files\Borland Shared\Images\Splash\256color\factory.bmp
BitMap.LoadFromFile('MyBitmap.png');
for y := 0 to BitMap.Height -1 do
begin
P := BitMap.ScanLine[y];
for x := 0 to BitMap.Width -1 do
P[x] := y;
end;
Canvas.Draw(0,0,BitMap);
finally
BitMap.Free;
end;
end;
给你一下例子,求图像亮度的
iCount:=0;
dY:=0;
for j := 64 to 248 do
begin
P := bmp.ScanLine[j];
for i := 16 to 256 do
begin
//访问像素 RGB
b:=P^.rgbtBlue;
g:=P^.rgbtGreen;
r:=P^.rgbtRed ;
inc(P);//指向下一个像素
dY:=dY+r*30+g*59+b*11;
iCount:=iCount+1;
end;
end;
if iCount>0 then dY:=dy div iCount;
edit1.Text:=IntToStr(DY div 100);