![]()  | 
	
 
  | 
| 
	 | 
| 
		 
			 
			#1  
			
			
			
			
		 
		
		
	 | 
|||
		
		
  | 
|||
| 
	
	
		
			
			 Мне задали сделать примитивный графический редактор на подобии Paint по методечке, и отдельно задание: 
		
	
		
		
		
		
		
		
			Как сделать кисть, которая будет рисовать по шаблону из рисунка в формате bmp размером 8 на 8 пикселей. на подсказку дали вот это: A brush's Bitmap property lets you specify a bitmap image for the brush to use as a pattern for filling shapes and other areas. The following example loads a bitmap from a file and assigns it to the Brush of the Canvas of Form1: Код: 
	var
Bitmap: TBitmap;
begin
Bitmap := TBitmap.Create;
try
Bitmap.LoadFromFile('MyBitmap.bmp');
Form1.Canvas.Brush.Bitmap := Bitmap;
Form1.Canvas.FillRect(Rect(0,0,100,100));
finally
Form1.Canvas.Brush.Bitmap := nil;
Bitmap.Free;
end;
end;Note The brush does not assume ownership of a bitmap object assigned to its Bitmap property. You must ensure that the Bitmap object remains valid for the lifetime of the Brush, and you must free the Bitmap object yourself afterwards. Помогите пожалуйста, очень срочно вот архив с моим редактором http://www.sendspace.com/file/5oa4an Последний раз редактировалось Admin, 29.12.2008 в 10:11.  | 
| 
		 
			 
			#2  
			
			
			
			
		 
		
		
	 | 
|||
		
		
  | 
|||
| 
	
	
		
			
			 Код: 
	type
  TForm1 = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  X1,Y1 : Integer; 
  bmp : tbitmap;
implementation
{$R *.dfm}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  x1:=X;
  y1:=Y;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  form1.Canvas.CopyRect(rect(x1,y1,x,y),bmp.Canvas,Rect(0,0,64,37));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  bmp := tbitmap.Create;
  bmp.LoadFromFile('e:\22.bmp');
end;
end.Последний раз редактировалось Admin, 11.05.2009 в 15:13.  |