Показать сообщение отдельно
  #3  
Старый 27.08.2012, 14:49
Аватар для YVitaliy
YVitaliy YVitaliy вне форума
Местный
 
Регистрация: 14.12.2011
Сообщения: 481
Версия Delphi: Borland Delphi7
Репутация: 17
По умолчанию

Вот специально для пэйнтбокса:
Код:
procedure obsc(pb:TPaintBox;const passColor:TColor; const coeff:single);
const pcprecision=10;
type
  TRGBArray = array[0..32767] of TRGBTriple;
  PRGBArray = ^TRGBArray;
var row:PRGBArray;
bmp:TBitMap;
i,j:Integer;
r,g,b:Byte;
begin
  bmp:=TBitMap.Create;
  bmp.PixelFormat:=pf24bit;
  bmp.Width:=pb.Width;
  bmp.Height:=pb.Height;
  bmp.Canvas.CopyRect(rect(0,0,bmp.Width,bmp.Height),pb.Canvas,
                      rect(0,0,pb.Width,pb.Height));

    for i:=0 to bmp.Height-1 do begin
      Row:=bmp.Scanline[i];
      for j:=0 to bmp.Width-1 do begin
        if  not ((abs(getRValue(passColor)-Row[j].rgbtRed)>pcprecision) and
           (abs(getGValue(passColor)-Row[j].rgbtGreen)>pcprecision) and
           (abs(getBValue(passColor)-Row[j].rgbtBlue)>pcprecision)) then
            begin
              b:=trunc(Row[j].rgbtBlue+(255-Row[j].rgbtBlue)*coeff);
              if b>255 then b:=255;
              g:=trunc(Row[j].rgbtGreen+(255-Row[j].rgbtGreen)*coeff);
              if g>255 then g:=255;
              r:=trunc(Row[j].rgbtRed+(255-Row[j].rgbtRed)*coeff);
              if r>255 then r:=255;
              Row[j].rgbtBlue:=b;
              Row[j].rgbtGreen:=g;
              Row[j].rgbtRed:=r;
            end;
      end;
    end;
    
  pb.Canvas.Draw(0,0,bmp);
  bmp.Free;
end;


.............
obsc(Form1.PaintBox1,clBtnFace,0.7);
"Высветливает" изображение. Но это, как говорил один человек, "через попу" . Лучше рисовать с уже нужными цветами.
Ответить с цитированием