|
#1
|
|||
|
|||
Не выходит
Народ у меня почемуто не сохраняются картинки (можете помочь что они сохранялись (ico формат) вот скрипт
|
#2
|
|||
|
|||
Код:
unit main; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Buttons, StdCtrls, Menus; type TForm1 = class(TForm) Panel1: TPanel; ScrollBox1: TScrollBox; PaintBox1: TPaintBox; SpeedButton2: TSpeedButton; SpeedButton3: TSpeedButton; SpeedButton4: TSpeedButton; SpeedButton1: TSpeedButton; ColorBox1: TColorBox; ColorBox2: TColorBox; Label1: TLabel; Label2: TLabel; MainMenu1: TMainMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; N5: TMenuItem; SpeedButton5: TSpeedButton; PaintBox2: TPaintBox; procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormCreate(Sender: TObject); procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure PaintBox1Paint(Sender: TObject); procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } end; TShape=(sPen, sRect, sEllipse, sPoly, sFill); var Form1: TForm1; nowdrawing:TShape; img, buffer:TBitmap; x0,y0:integer; dwn:boolean; implementation {$R *.dfm} procedure TForm1.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if button=mbLeft then begin img.assign(buffer); x0:=x; y0:=y; if SpeedButton1.Down then begin nowdrawing:=sPen; img.canvas.MoveTo(x,y); end else if SpeedButton2.Down then nowdrawing:=sEllipse else if SpeedButton3.Down then nowdrawing:=sRect else if SpeedButton4.Down then nowdrawing:=sPoly else if SpeedButton5.Down then nowdrawing:=sFill; dwn:=true; img.Canvas.Pen.Color:=ColorBox1.Sel ected; img.Canvas.Brush.Color:=ColorBox2.S elected; if nowdrawing=sFill then begin img.Canvas.FloodFill(x0,y0,img.Canv as.Pixels[x,y],fsSurface); buffer.Assign(img); dwn:=false; end end else begin if (dwn)and(nowdrawing=sPoly) then begin x0:=x; y0:=y; buffer.Assign(img); end; end; paintbox1.Canvas.CopyRect(bounds(0, 0,img.Width,img.Height),img.Canvas, bounds(0,0,img.Width,img.Height)); end; procedure TForm1.FormCreate(Sender: TObject); begin Img:=TBitmap.Create; buffer:=TBitmap.Create; img.Width:=PaintBox1.ClientWidth; buffer.Width:=PaintBox1.ClientWidth ; img.Height:=PaintBox1.ClientHeight; buffer.Height:=PaintBox1.ClientHeig ht; nowdrawing:=sPen; dwn:=false; end; procedure TForm1.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if not dwn then exit; img.assign(buffer); case nowdrawing of sPen:begin img.Canvas.LineTo(x,y); buffer.Assign(img); end; sRect:begin img.Canvas.Rectangle(x0,y0,x,y); end; sEllipse:begin img.Canvas.Ellipse(x0,y0,x,y); end; sPoly:begin img.Canvas.MoveTo(x0,y0); img.Canvas.LineTo(x,y); end; sFill:begin //nothing. end; end; paintbox1.Canvas.CopyRect(bounds(0, 0,img.Width,img.Height),img.Canvas, bounds(0,0,img.Width,img.Height)); end; procedure TForm1.PaintBox1Paint(Sender: TObject); begin paintbox1.Canvas.CopyRect(bounds(0, 0,img.Width,img.Height),buffer.Canv as,bounds(0,0,img.Width,img.Height) ); end; procedure TForm1.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if button=mbLeft then dwn:=false; buffer.Assign(img); end; end Последний раз редактировалось Admin, 14.12.2009 в 10:14. |