image2.Picture.Bitmap.Height:=img_mid.picture.width;
image2.Picture.Bitmap.Width:=img_mid.picture.height;
for i:=0 to img_mid.Height do
begin
for j:=0 to img_mid.Width do
begin
if ag_index=0 then //90度
image2.canvas.Pixels[(-i+img_mid.Height),j]:=img_mid.canvas.Pixels[j,i]
else
if ag_index=1 then //180度
image2.canvas.Pixels[(image1.Width-j),(image1.Height-i)]:=img_mid.canvas.Pixels[j,i]
else
if ag_index=2 then //270度
image2.canvas.Pixels[i,(image1.Width-j)]:=img_mid.canvas.Pixels[j,i];
end;
end;
filename:=ExtractFilePath(application.ExeName)+'Temp_RotatePic.bmp';
deletefile(filename);
image2.Picture.SaveToFile(filename);
if fileexists(filename) then
result:=filename;
end;