
18.04.2012, 23:11
|
 |
Местный
|
|
Регистрация: 14.12.2011
Сообщения: 481
Версия Delphi: Borland Delphi7
Репутация: 17
|
|
Ну, кто хочет посмотреть на мое "творчество"?
Но код работает, пробовал!!! Оптимизируйте и исправляйте на здоровье!!!
Код:
procedure TextOut(var Obj:TPngObject;const Color, bkColor:TColor; const X,Y, size:Integer; const text:String; const bkTransparent:boolean=false);//вывод текста
var
bmp:TPNGObject;
RowBmp, Row: pRGBLine;
aSL, aSL1: PByteArray;
i,j, t,b,l,r,h, i1,j1:integer;
pcl:TColor;
begin
bmp:=TPNGObject.CreateBlank(COLOR_RGB,16,10,10);
bmp.Canvas.Font.Size:=size;
bmp.Canvas.Font.Color:=Color;
bmp.Canvas.Brush.Style:=bsSolid;
bmp.Canvas.Brush.Color:=bkColor;
l:=bmp.Canvas.TextWidth(text);
h:=bmp.Canvas.TextHeight(text);
bmp.Resize(l,h);
bmp.CreateAlpha;
bmp.Canvas.TextOut(0,0,text);
t:=Y; if (t<0) then t:=0; if (t>=obj.Height) then t:=obj.Height;
b:=Y+bmp.Height; if (b<0) then b:=0; if (b>=obj.Height) then b:=obj.Height;
l:=X; if (l<0) then l:=0; if (l>=obj.Width) then l:=obj.Width;
r:=X+bmp.Width; if (r<0) then r:=0; if (r>=obj.Width) then r:=obj.Width;
i1:=0;
for i:=t to b-1 do begin
RowBmp:=bmp.ScanLine[i1];
Row:=Obj.Scanline[i];
aSL1 := bmp.AlphaScanline[i1];
aSL := Obj.AlphaScanline[i];
j1:=0;
for j:=l to r-1 do begin
pcl:=RGB(RowBmp[j1].rgbtRed,RowBmp[j1].rgbtGreen,RowBmp[j1].rgbtBlue);
if (pcl=Color) or (not bkTransparent) then begin
row[j].rgbtBlue:=RowBmp[j1].rgbtBlue;
row[j].rgbtGreen:=RowBmp[j1].rgbtGreen;
row[j].rgbtRed:=RowBmp[j1].rgbtRed;
aSL[j]:=255;
end;
inc(j1);
end;
inc(i1);
end;
bmp.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var img:TBitMap;
l,h:Integer;
begin
TextOut(pngObject,clRed,clYellow,0,0,12,'textj_YЪ,"',true);
end;
|