T
tjlqp
Unregistered / Unconfirmed
GUEST, unregistred user!
做了一个将一张一寸数码照片排版变成3*3的照片,以备出“洗印”。可没想到虽然照的是像素300的照片,变成3*3版时却成了像素72的,因此尺寸就大了好几倍,不能正常工作。究其原因,应该是开始建立的背景黙认像素是72造成的。那怎么才能建立一个像素300的背景呢?
程序核心代码:
procedure TForm1.Button1Click(Sender: TObject);
var wc :string;
x,y,i,j,z,jgxs,zxjg,d1,d2:integer;
begin
GroupBox1.Caption :='照片处理结果';
if (trim(Edit1.Text)<>'') then d1:=1 else d1:=1;//行数
if (trim(Edit2.Text)<>'') then d2:=1 else d2:=1;//列数
if (trim(edit3.Text)<>'') then jgxs:=1 else jgxs:=0;//照片列间隔
if (trim(edit4.Text)<>'') then zxjg:=1 else zxjg:=0;//照片行间隔
//在opendialog 的Option属性的 ofMutilSelect选项 设为true一次打开多个文件
opendialog1.Execute;
Label4.Caption :=inttostr(opendialog1.Files.Count);
for i:=0 to opendialog1.Files.Count-1 do
begin
//创建一个图片
aa:=tjpegimage.create;
//取出文件
aa.LoadFromFile(opendialog1.Files);
//显示文件
image1.Stretch:=true;
//背景底image1大小变化时图形大小跟着所选照片的大小 d1*d2 确定
x:=aa.width;
y:=aa.Height;
jgxs:=round(strtoint(edit3.Text)*11.8/2);
zxjg:=round(strtoint(edit4.Text)*11.8/2);
image1.Picture.Bitmap.Width:=(x+jgxs)*d1+jgxs;
image1.Picture.Bitmap.Height:=(y+zxjg)*d2+zxjg;
image1.Picture.Bitmap.Canvas.Rectangle(0,0,image1.Picture.Bitmap.Width,image1.Picture.Bitmap.Height);
//背景底的分辩率如何确定呢????????
//行循环
for j:=0 to strtoint(edit2.Text)-1 do //实际为d1行
begin
//列循环
for z:=0 to strtoint(edit1.Text)-1 do //实际为d2列
begin
//重画图片内容
image1.Canvas.Draw((x+jgxs)*j+jgxs,(y+zxjg)*z+zxjg,aa);
end;
end;
//图片文件存储
aa.Assign(image1.Picture.Bitmap);
aa.SaveToFile(copy(opendialog1.Files,1,length(opendialog1.Files)-4)+'_new'+copy(opendialog1.Files,length(opendialog1.Files)-4,length(opendialog1.Files)));
aa.Free;
wc:='1'; //重新排版完成
end;
if (wc='1') then showmessage('修改已完成,谢谢使用'); //重新排版完成提示
end;
程序核心代码:
procedure TForm1.Button1Click(Sender: TObject);
var wc :string;
x,y,i,j,z,jgxs,zxjg,d1,d2:integer;
begin
GroupBox1.Caption :='照片处理结果';
if (trim(Edit1.Text)<>'') then d1:=1 else d1:=1;//行数
if (trim(Edit2.Text)<>'') then d2:=1 else d2:=1;//列数
if (trim(edit3.Text)<>'') then jgxs:=1 else jgxs:=0;//照片列间隔
if (trim(edit4.Text)<>'') then zxjg:=1 else zxjg:=0;//照片行间隔
//在opendialog 的Option属性的 ofMutilSelect选项 设为true一次打开多个文件
opendialog1.Execute;
Label4.Caption :=inttostr(opendialog1.Files.Count);
for i:=0 to opendialog1.Files.Count-1 do
begin
//创建一个图片
aa:=tjpegimage.create;
//取出文件
aa.LoadFromFile(opendialog1.Files);
//显示文件
image1.Stretch:=true;
//背景底image1大小变化时图形大小跟着所选照片的大小 d1*d2 确定
x:=aa.width;
y:=aa.Height;
jgxs:=round(strtoint(edit3.Text)*11.8/2);
zxjg:=round(strtoint(edit4.Text)*11.8/2);
image1.Picture.Bitmap.Width:=(x+jgxs)*d1+jgxs;
image1.Picture.Bitmap.Height:=(y+zxjg)*d2+zxjg;
image1.Picture.Bitmap.Canvas.Rectangle(0,0,image1.Picture.Bitmap.Width,image1.Picture.Bitmap.Height);
//背景底的分辩率如何确定呢????????
//行循环
for j:=0 to strtoint(edit2.Text)-1 do //实际为d1行
begin
//列循环
for z:=0 to strtoint(edit1.Text)-1 do //实际为d2列
begin
//重画图片内容
image1.Canvas.Draw((x+jgxs)*j+jgxs,(y+zxjg)*z+zxjg,aa);
end;
end;
//图片文件存储
aa.Assign(image1.Picture.Bitmap);
aa.SaveToFile(copy(opendialog1.Files,1,length(opendialog1.Files)-4)+'_new'+copy(opendialog1.Files,length(opendialog1.Files)-4,length(opendialog1.Files)));
aa.Free;
wc:='1'; //重新排版完成
end;
if (wc='1') then showmessage('修改已完成,谢谢使用'); //重新排版完成提示
end;