抓图再翻转,谁来?(100分)

F

fanwei

Unregistered / Unconfirmed
GUEST, unregistred user!
抓下form1某一矩形部分的图后,要求能作成打印预览的样子,就是说
对此部分拷贝后将生成的图象翻转90度(左右都行),按比例缩放后
放在一个专门实现打印预览的FORM中,按键实现打印,打印用FORM。PRINT
就可以了,但是众大虾小弟有三件不会:
一、怎样实现对某一矩形部分的抓图?
二、怎样翻转和按一定比例缩放?
三、用FORM。PRINT的时候打印窗体上的“打印”按键如何不被打印出来?
这个问题我用好几种方式问了好几次了,但是结果都不满意,要交工了,好急!
300大洋五体奉上,求好心人救命!
 
//垂直反转
var
dummyimage:timage;
x,y:integer;
srcrect,dstrect:trect;
begin
x:=image1.picture.width;
y:=image1.picture.height;
dummyimage:=timage.create(self);
try
srcrect:=rect(0,0,x,y);
dstrect:=rect(0,y,x,0);
dummyimage.width:=x;
dummyimage.height:=y;
dummyimage.canvas.copymode:=cmsrccopy;
dummyimage.canvas.copyrect(dstrect,image1.canvas,srcrect);
image1.picture:=dummyimage.picture;
finally
dummyimage.free;
end;
end;
 
用第三方控件解决.
 
to D影子D:我没有说清楚,比如现在的是这样的--------------
--------------
我要它反成| |
| |
| |
| |
就是象一本书被放倒一样,你的方法只能实现翻转180度,还有别的招吗?
就想ACDSEE中的图象增强中的功能似的
to hbezwwl:有什么控件能实现我的功能吗?
 
怎么用啊,这是什么东东?那里?定义?天,详细些好吗?
 

卷起千堆雪tyn的方法(没有试过)
旋转90度的快速方法 : 在Image1上加载一幅位图

type
EInvalidPixelFormat = class(Exception);

const
BitsPerByte = 8;

function GetPixelSize(aBitmap: TBitmap): integer;
var
nBitCount, nMultiplier: integer;
begin
case aBitmap.PixelFormat of
pfDevice:
begin
nBitCount := GetDeviceCaps(aBitmap.Canvas.Handle, BITSPIXEL);
nMultiplier := nBitCount div BitsPerByte;
if (nBitCount mod BitsPerByte)>0 then
Inc(nMultiplier);
end;
pf1bit: nMultiplier := 1;
pf4bit: nMultiplier := 1;
pf8bit: nMultiplier := 1;
pf15bit: nMultiplier := 2;
pf16bit: nMultiplier := 2;
pf24bit: nMultiplier := 3;
pf32bit: nMultiplier := 4;
else raise EInvalidPixelFormat.Create('Bitmap pixelformat is unknown.');
end;
Result := nMultiplier;
end;

procedure ImageRotate90(aBitmap: TBitmap);
var
nIdx, nOfs,
x, y, i,nMultiplier: integer;
nMemWidth, nMemHeight, nMemSize,nScanLineSize: LongInt;
aScnLnBuffer: PChar;
aScanLine: PByteArray;
begin
nMultiplier := GetPixelSize(ABitmap);
nMemWidth := aBitmap.Height;
nMemHeight := aBitmap.Width;
nMemSize := nMemWidth * nMemHeight * nMultiplier;
GetMem(aScnLnBuffer, nMemSize);
try
nScanLineSize := aBitmap.Width * nMultiplier;
GetMem(aScanLine, nScanLineSize);
try
for y := 0 to aBitmap.Height-1 do
begin
Move(aBitmap.ScanLine[y]^, aScanLine^, nScanLineSize);
for x := 0 to aBitmap.Width-1 do
begin
nIdx := ((aBitmap.Width-1) - x) * nMultiplier;
nOfs := (x * nMemWidth * nMultiplier) +(y * nMultiplier);
for i := 0 to nMultiplier-1 do
Byte(aScnLnBuffer[nOfs + i]) := aScanLine[nIdx+i];
end;
end;
aBitmap.Height := nMemHeight;
aBitmap.Width := nMemWidth;
for y := 0 to nMemHeight-1 do
begin
nOfs := y * nMemWidth * nMultiplier;
Move((@(aScnLnBuffer[nOfs]))^, aBitmap.ScanLine[y]^, nMemWidth * nMultiplier);
end;
finally
FreeMem(aScanLine, nScanLineSize);
end;
finally
FreeMem(aScnLnBuffer, nMemSize);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ImageRotate90(Image1.Picture.Bitmap);
end;
 
凌云天地有你要的控件.
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部