Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi About B&W film filter (https://www.delphipraxis.net/160021-about-b-w-film-filter.html)

WojTec 23. Apr 2011 14:55

About B&W film filter
 
Liste der Anhänge anzeigen (Anzahl: 1)
Paint Shop Photo -> Effects -> Photo effects -> Black and White Film

I have already this filter (without this nice circle), but don't have Suggest Color option. I don't have idea how it can work, do you have some ideas? I tried grey average color.

:?:

freeway 3. Mai 2011 19:31

AW: About B&W film filter
 
this code should help you

Delphi-Quellcode:
type TRGBArray = array[0..10000] of TRGBTriple;
      PRGBArray = ^TRGBArray;

var R,G,B : integer;     //range 0 to 100
    x,y : integer;
    d1,d2,d3 : double;
    grey : integer;
    Row : PRGBArray;

begin
  d1 := R / 100;   //calc percent
  d2 := G / 100;
  d3 := B / 100;

  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
            if grey > 255 then grey := 255;  //check range
            rgbtRed  := grey;               //set values
            rgbtGreen := grey;
            rgbtBlue := grey;
          end;
    end;
end;

WojTec 4. Mai 2011 19:16

Re: About B&W film filter
 
Thanks, but could you tell me, what values are for R, G and B (calc % part)?

Aphton 4. Mai 2011 19:52

AW: About B&W film filter
 
Try using 128 for each one of them!

WojTec 5. Mai 2011 08:44

Re: About B&W film filter
 
Why, I don't understand?

Maybe it's average brightness (eh, nope I think) or color which is the most (or the least) in image?

freeway 5. Mai 2011 16:45

AW: About B&W film filter
 
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;


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:56 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz