Jak ustawić przezroczystość wypisywanego tekstu na

0

Jak ustawić przezroczystość wypisywanego tekstu na canvansie

0

Yo Ziomalu :-P

[code]Canvas.Brush.style:=bsClear;[/code]

0

Nie oto mi chodziło. Sory że nie sprecyzowałem. Nie chodzi mi o tło tekstu ale o tekst. Mam czarne tło i pisze na nim zielony tekst. Jak zrobić żeby to co jest pod tekstem było troche widoczne. We flashu jest to właściwość alpha jeśli to komuś mówi.

I jeszcze jedno jak zmazać już zapisany tekst.

0

Bierzeszdo jakijeś Canvy tło, które ma być pod textem, półprzezroczyćcie rysujesz na tej Canvie jakiś text i tą Canvaę wklejasz w miejsce z którego wziąłeś tło...

0

Ale jak półprzezroczyście napisać ten tekst?

0

zrodelko mojego programiku demonstrujacego wykorzystanie metody Alpha Blending w Delphi :)

[code]
{
ver. 3 - poprawiono szybkość działania metody ScanLine, dodano AlphaBlending

Trzy sposoby na uzyskanie efektu pzrenikania bitmap...

1- metoda Pixels, wolna i prostacka
2- metoda ScanLine, szybka
3- metoda AlphaBlending, szybka i ładna :)
wzór: Srgb= AC*Frgb+(1-AC)*Brgb
AC - alpha channel (przedział od 0 do 1)
Frgb - pierwsza bitmapa
Brgb - druga bitmapa

Piniol - [email protected]
www.icpnet.pl/~pinio
www.delphi-area.com
}

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, jpeg, ExtDlgs, Buttons;

type
TForm1 = class(TForm)
Button1: TButton;
Image2: TImage;
Button2: TButton;
Image1: TImage;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Konwersja(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Konwersja(Sender: TObject);
var
BMP: TBitmap;
begin
BMP:=TBitmap.Create;
BMP.Width:=Image2.Width;
BMP.Height:=Image2.Height;
BMP.Canvas.Draw(0,0, Image2.Picture.Graphic);
Image2.Picture:=nil;
Image2.Picture.Bitmap:=BMP;
Image2.Picture.Bitmap.PixelFormat:=pf24bit;
Image1.Picture.Bitmap.PixelFormat:=pf24bit;
BMP.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
x1, y1, t: integer;
bmp2: TBitmap;
pix: TColor;
begin
Konwersja(Sender);
Screen.Cursor:=crHourGlass;
t:=GetTickCount;
bmp2:=TBitmap.Create;
bmp2.Assign(Image2.Picture.Bitmap);
pix:=Image1.Picture.Bitmap.Canvas.Pixels[0,0];
for x1:=0 to Image1.Picture.Bitmap.Width-1 do
for y1:=0 to Image1.Picture.Bitmap.Height-1 do
if Odd(x1) and Odd(y1) then
bmp2.Canvas.Pixels[x1,y1+100]:=Image1.Picture.Bitmap.Canvas.Pixels[x1,y1]
else
if not Odd(x1) and not Odd(y1) then
bmp2.Canvas.Pixels[x1,y1+100]:=Image1.Picture.Bitmap.Canvas.Pixels[x1,y1];
Image2.Picture.Bitmap.Canvas.Draw(0, 0, bmp2);
Form1.Caption:='Czas w msek: '+IntToStr(GetTickCount-t);
Screen.Cursor:=crDefault;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.DoubleBuffered:=True;
Image1.Picture.LoadFromFile(ExtractFilePath(ParamStr(0))+'grad.bmp');
Image2.Picture.LoadFromFile(ExtractFilePath(ParamStr(0))+'square.jpg');
end;

procedure TForm1.Button2Click(Sender: TObject);
var
x1, y1, t: integer;
linia, linia2: PByteArray;
begin
Konwersja(Sender);
Screen.Cursor:=crHourGlass;
t:=GetTickCount;
for y1:=0 to Image1.Height-1 do
begin
linia:=Image1.Picture.Bitmap.ScanLine[y1];
linia2:=Image2.Picture.Bitmap.ScanLine[y1+100];
for x1:=0 to Image1.Width-1 do
begin
if Odd(y1) and Odd(x1) then
begin
linia2[x13+2]:=linia[x13+2];
linia2[x13+1]:=linia[x13+1];
linia2[x13]:=linia[x13];
end
else
if not Odd(y1) and not Odd(x1) then
begin
linia2[x13+2]:=linia[x13+2];
linia2[x13+1]:=linia[x13+1];
linia2[x13]:=linia[x13];
end;
end;
end;
Form1.Caption:='Czas w msek: '+IntToStr(GetTickCount-t);
Screen.Cursor:=crDefault;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
image2.Picture:=nil;
image2.Picture.LoadFromFile(ExtractFilePath(paramstr(0))+'square.jpg');
end;

procedure TForm1.Button4Click(Sender: TObject);
var
t, x1, y1: integer;
src1, src2, pd: PByteArray;
begin
Konwersja(Sender);
Screen.Cursor:=crHourGlass;
t:=GetTickCount;
for y1:=0 to Image1.Height-1 do
begin
src1:=Image1.Picture.Bitmap.ScanLine[y1];
src2:=Image2.Picture.Bitmap.ScanLine[y1+100];
for x1:=0 to Image1.Width-1 do
begin
src2[x13]:=round(0.5src1[x13]+(1-0.5)src2[x13]);
src2[x1
3+1]:=round(0.5src1[x13+1]+(1-0.5)src2[x13+1]);
src2[x13+2]:=round(0.5src1[x1*3+2]+(1-0.5)src2[x13+2]);
end;
end;
Form1.Caption:='Czas w msek: '+IntToStr(GetTickCount-t);
Screen.Cursor:=crDefault;
end;

end.
[/code]

1 użytkowników online, w tym zalogowanych: 0, gości: 1