delphi4arab منتديات دلفي للعرب
الكتابة على صورة وتعيينها كخلفية - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : مصادر دلفي مفتوحة تعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=14)
+--- الموضوع : الكتابة على صورة وتعيينها كخلفية (/showthread.php?tid=5253)



الكتابة على صورة وتعيينها كخلفية - onexite - 24-05-2013

السلام عليكم
الخصائص
  • تغيير الخط وحجمه نسيت اللون
  • الكتابة على صورة وتعيينها خلفية
  • امكانية اخفاء او اظهار ايقونات سطح المكتب
[صورة: 20130524221056.jpg]

لون الخط
PHP كود :
procedure imgsettext(img: timage; text: string);
begin
 with Img
.Picture.Bitmap.Canvas do
    
begin
      Font
.Color  := Form1.ColorGrid1.ForegroundColor; 
PHP كود :
procedure TForm1.ColorGrid1Change(Sender: TObject);
begin
mmo1
.Font.Color:=ColorGrid1.ForegroundColor;
end; 



الكتابة على صورة وتعيينها كخلفية - SMP3 - 25-05-2013

و عليكم السلام ...
مثال جميل و رائع ..
لدي بعض الملاحظات على السريع :
لماذا قمت بارفاق صورة 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; 
بالنسبة للمثال سيكون جيد جدا لو استخدمت ال GDI+ بدل ال GDI
مثال على السريع :

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; 
[COLOR="Red"]أخيرا هذه هدية مني :
ComboBoxFont : لعرض و معاينة الخطوط Smile بدون 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;