Board index » delphi » why stretchdraw metafile doesn't work?Borland

why stretchdraw metafile doesn't work?Borland

code as followed:
        mf:=TMetaFile.Create;
        mf.MMWidth:=20000;
        mf.MMHeight:=30000;
        mfc:=TMetaFileCanvas.Create(mf,0);
        with mfc do
        begin
                SetMapMode(handle,MM_HIMETRIC);
                ...draw graphics
        end;
        mfc.free;

        with image1.canvas do
        begin
                rc:=Rect(0,0,20000,-30000);
                SetMapMode(handle,MM_HIMETRIC);
                Draw(0,0,mf);//succeed
                StretchDraw(rc,mf);//
                //you can see nothing on the image if using stretchdraw
        end;

        Help!!!!!

 

Re:why stretchdraw metafile doesn't work?Borland


Quote
huangbo wrote:

> code as followed:
>         mf:=TMetaFile.Create;
>         mf.MMWidth:=20000;
>         mf.MMHeight:=30000;
>         mfc:=TMetaFileCanvas.Create(mf,0);
>         with mfc do
>         begin
>                 SetMapMode(handle,MM_HIMETRIC);
>                 ...draw graphics
>         end;
>         mfc.free;

>         with image1.canvas do
>         begin
>                 rc:=Rect(0,0,20000,-30000);
>                 SetMapMode(handle,MM_HIMETRIC);
>                 Draw(0,0,mf);//succeed
>                 StretchDraw(rc,mf);//
>                 //you can see nothing on the image if using stretchdraw
>        end;

Try rc:=Rect(0,0,20000,30000) instead of rc:=Rect(0,0,20000,-30000).
You're drawing the metafile to a rectangle _above_ the visible
portion of the image!

        If that's still invisible it could be because you're only
seeing the upper-left corner of the metafile and maybe there's
nothing there - you didn't specify what "draw graphics" means.
When I say "Brush.Color:= clRed; rectangle(0,0,100,100)" in
your "draw graphics" spot and change your -30000 to 30000 I can
see something appear. But if I say rectangle(20000,20000,30000,30000)
instead I don't see anything, just because I haven't drawn anything
on the part of the metafile that happens to be visible.
--
David Ullrich

sig.txt not found

Other Threads