Opacity

Résolu
sarssor Messages postés 63 Date d'inscription dimanche 22 juillet 2007 Statut Membre Dernière intervention 28 avril 2011 - 21 avril 2011 à 13:20
sarssor Messages postés 63 Date d'inscription dimanche 22 juillet 2007 Statut Membre Dernière intervention 28 avril 2011 - 23 avril 2011 à 00:46
Salut
je voudrais faire opacité entre 2 Bitmaps mais
le valeur ne doit pas être le meme par example
de haut en bas
commet ca :
Example
Je crois il faut faire masque. mais je ne sais pas comment
et voila mon code :
procedure TForm1.Button1Click(Sender: TObject);
const TransparentGrad = 0.5;
VAR oldColor, aColor: TColor;
    x,y: Integer;
    tmpColor1,
    tmpColor2: TColor;
begin
  Image3.Picture.Assign(Image2.Picture);
  Image3.AutoSize := True;

  for x := 0 to Image1.Picture.Width do
    for y := 0 to Image1.Picture.Height do begin
      oldColor := Image1.Canvas.Pixels[x,y];
      aColor := Image2.Canvas.Pixels[x,y];
      Image3.Canvas.Pixels[x,y] := RGB(Trunc(Max(0,GetRValue(oldColor) - TransparentGrad * GetRValue(aColor))),
                                       Trunc(Max(0,GetGValue(oldColor) - TransparentGrad * GetGValue(aColor))),
                                       Trunc(Max(0,GetBValue(oldColor) - TransparentGrad * GetBValue(aColor))));
    end;
end;


je voudrais de coûté un peut de transparent et d autre coûté plus transparent

1 réponse

sarssor Messages postés 63 Date d'inscription dimanche 22 juillet 2007 Statut Membre Dernière intervention 28 avril 2011
23 avril 2011 à 00:46
Salut
tu a raison mais je suis débutant en Delphi c est pourquoi j ai besoin que vous me aidez s.v.p

Voila une autre fonction qui très rapide que l autre :
procedure TForm1.TrackBar1Change(Sender: TObject);
type
TLine = array [0..22222] of TRGBTriple;
PLine = ^TLine;
var
n : byte; // value from trackbar
w, h : integer; // loop variables for going through all the pixels of bmp1 and bmp2
l1, l2, l3 : PLine; // "scanlines" for bmp1, bmp2, TImage().Picture.Bitmap
begin
n := TrackBar1.Position;
for h := 0 to bmp1.Height - 1 do begin
l1 := bmp1.ScanLine[h];
l2 := bmp2.ScanLine[h];
l3 := Image1.Picture.Bitmap.ScanLine[h];
for w := 0 to bmp1.Width - 1 do begin
l3[w].rgbtRed := trunc(l1[w].rgbtRed / 100 * (100 - n) + l2[w].rgbtRed / 100 * n);
l3[w].rgbtGreen := trunc(l1[w].rgbtGreen / 100 * (100 - n) + l2[w].rgbtGreen / 100 * n);
l3[w].rgbtBlue := trunc(l1[w].rgbtBlue / 100 * (100 - n) + l2[w].rgbtBlue / 100 * n);
end;
end;
Image1.Refresh;
end;


j ai lu Delphi avec des livres et pas dans un École

Et merci bien pour ton temps pour m aider
0
Rejoignez-nous