Thema: Delphi About B&W film filter

Einzelnen Beitrag anzeigen

freeway

Registriert seit: 11. Jul 2009
57 Beiträge
 
Delphi XE Professional
 
#6

AW: About B&W film filter

  Alt 5. Mai 2011, 17:45
if the sum from the addition (d1+d2+d3) bigger than 100 then the result is a brighter picture
for brighter colors (yellow) the result is a brighter image
you can limit the RGB values out from yellow (<100) but then you move all RGB to lower due
you can get the same result (brightness) with a darker color, the limit is 100

here with color and expanded up to 255
Delphi-Quellcode:
type TRGBArray = array[0..10000] of TRGBTriple;
     PRGBArray = ^TRGBArray;

var your_color : Tcolor; //your selected color
    R,G,B : integer;
    x,y : integer;
    d1,d2,d3 : double;
    grey : integer; //grey values
    Row : PRGBArray;

begin
  R := GetRValue(your_color); //get RGB colors
  G := GetGValue(your_color);
  B := GetBValue(your_color);
  d1 := R / 255; //convert to due
  d2 := G / 255;
  d3 := B / 255;

  for y := 0 to bmp1.Height - 1 do
    begin
      row := BMP1.scanline[y];
      for x := 0 to BMP1.Width - 1 do
        with row[x] do
          begin
            grey := round((d1 * rgbtRed) + (d2 * rgbtGreen) + (d3 * rgbtBlue)); //calculate grey due (from RGB values)
            if grey > 255 then grey := 255; //check range
            rgbtRed := grey; //set values
            rgbtGreen := grey;
            rgbtBlue := grey;
          end;
    end;
end;
  Mit Zitat antworten Zitat