25-05-2013, 01:37 PM
و عليكم السلام ...
مثال جميل و رائع ..
لدي بعض الملاحظات على السريع :
لماذا قمت بارفاق صورة Image1.bmp مع المشروع (الصورة حجمها أكثر من التطبيق نفسه (أكثر من 1 ميجا ))
يمكنك تجنب ذلك عن طريق الرسم مباشرة في ال TBitmap
بالنسبة للمثال سيكون جيد جدا لو استخدمت ال GDI+ بدل ال GDI
مثال على السريع :
[COLOR="Red"]أخيرا هذه هدية مني :
ComboBoxFont : لعرض و معاينة الخطوط
بدون OOP :[/COLOR]
مثال جميل و رائع ..
لدي بعض الملاحظات على السريع :
لماذا قمت بارفاق صورة Image1.bmp مع المشروع (الصورة حجمها أكثر من التطبيق نفسه (أكثر من 1 ميجا ))
يمكنك تجنب ذلك عن طريق الرسم مباشرة في ال TBitmap
PHP كود :
var bmp : TBitmap ;
begin
bmp := TBitmap.Create ;
bmp.SetSize(200,200);
bmp.Canvas.Brush.Color:=clBlack;
bmp.Canvas.FillRect(Rect(0,0,200,200));
bmp.SaveToFile('...');
end;
مثال على السريع :
PHP كود :
uses GDIPlus;
//-----------By SMP3 ---------------
var
Graphics: IGPGraphics;
GraphicsPath: IGPGraphicsPath;
FontFamily: IGPFontFamily;
Font: IGPFont;
Point: TGPPointF;
StringFormat: IGPStringFormat;
pen: IGPPen;
brush: IGPSolidBrush;
i: Integer;
begin
Graphics := TGPGraphics.Create(Canvas.Handle);
Graphics.SmoothingMode := SmoothingModeAntiAlias;
Graphics.InterpolationMode := InterpolationModeHighQualityBicubic;
FontFamily := TGPFontFamily.Create('Times New Roman');
Font := TGPFont.Create(FontFamily, 24, FontStyleRegular, UnitPixel);
Point.Initialize(10, 20);
GraphicsPath := TGPGraphicsPath.Create;
StringFormat := TGPStringFormat.Create();
GraphicsPath.AddString('SMP3|Delphi4Arab ', FontFamily, FontStyleRegular, 80,
Point, StringFormat);
pen := TGPPen.Create(TGPColor.Create(32, 0, 128, 192), 4);
brush := TGPSolidBrush.Create(TGPColor.Create(255, 255, 255));
for i := 0 to 10 do
begin
pen.Width := i;
pen.LineJoin := LineJoinRound;
Graphics.DrawPath(pen, GraphicsPath);
end;
Graphics.DrawPath(pen, GraphicsPath);
Graphics.FillPath(brush, GraphicsPath);
end;
ComboBoxFont : لعرض و معاينة الخطوط
بدون OOP :[/COLOR]PHP كود :
var FFont: TFont = nil;
procedure TForm1.ComboBoxFontDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
FComboBoxFont: TComboBox;
begin
FComboBoxFont := TComboBox(Control);
if not Assigned(FFont) then
FFont := TFont.Create;
if odSelected in State then
begin
FComboBoxFont.Canvas.brush.Color := clHighlight;
FComboBoxFont.Canvas.FillRect(Rect);
FComboBoxFont.Canvas.TextOut(Rect.Left, Rect.Top,
FComboBoxFont.Items[index]);
end
else
begin
FFont.Name := FComboBoxFont.Items[index];
FComboBoxFont.Canvas.Font.Assign(FFont);
FComboBoxFont.Canvas.brush.Color := FComboBoxFont.Color;
FComboBoxFont.Canvas.FillRect(Rect);
FComboBoxFont.Canvas.TextOut(Rect.Left, Rect.Top,
FComboBoxFont.Items[index]);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBoxFont.Style := csOwnerDrawVariable;
if not Assigned(FFont) then
FFont := TFont.Create;
with ComboBoxFont do
begin
Items.AddStrings(Screen.Fonts);
ItemIndex := 0;
ItemIndex := 6;
end;
end;

