1,183
社区成员
发帖
与我相关
我的任务
分享
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Jpeg;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Image2: TImage;
Image3: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
JPGpic: TJpegImage;
Bmp: TBitmap;
y, h:integer;
begin
JPGpic := TJpegImage.Create();
JPGpic.LoadFromFile('D:\未命名.JPG');
Bmp := TBitmap.Create();
Bmp.Width := JPGpic.Width;
h := JPGpic.Height div 3;
Bmp.Height := h;
y := 0;
with Image1 do
begin
Height:=Bmp.Height;
Width:=Bmp.Width;
Bmp.Canvas.Draw(0, y, JPGpic);
Picture.Assign(Bmp);
end;
Dec(y, h);
with Image2 do
begin
Height:=Bmp.Height;
Width:=Bmp.Width;
Bmp.Canvas.Draw(0, y, JPGpic);
Picture.Assign(Bmp);
end;
Dec(y, h);
with Image3 do
begin
Height:=Bmp.Height;
Width:=Bmp.Width;
Bmp.Canvas.Draw(0, y, JPGpic);
Picture.Assign(Bmp);
end;
Bmp.Free();
end;
end.
procedure TForm1.Button1Click(Sender: TObject);
var Rect1,Rect2,Rect3:TRect;
bmp:TBitmap;
w,h:integer;
begin
bmp:= TBitmap.Create;
bmp.Assign(Image1.Picture.Graphic);
w:=Image1.Width ;
h:=Image1.Height div 3;
Rect1:=Rect(0,0,w,h);
Rect2:=Rect(0,h,w,h*2);
Rect3:=Rect(0,h*2,w,h*3);
with Image2 do
begin
Height:=h;
Width:=w;
Canvas.CopyRect(Rect1,bmp.Canvas,Rect1);
end;
with Image3 do
begin
Height:=h;
Width:=w;
Canvas.CopyRect(Rect1,bmp.Canvas,Rect2);
end;
with Image4 do
begin
Height:=h;
Width:=w;
Canvas.CopyRect(Rect1,bmp.Canvas,Rect3);
end;
bmp.Free;
end;