Splitting a Metafile

Please discuss general Delphi programming topics here.

Splitting a Metafile

Postby Feike » August 2nd, 2006, 9:53 am

Hello,

I need to split a metafile.
It has an a3 format and I want to split the file in two a4 metafiles so I can print it on two pages.(I use Printpreview) How can I do this?
I know how to do this with a bitmap, but not with a metafile.
Feike
Active Member
Active Member
 
Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

Postby Johnny_Bit » August 2nd, 2006, 3:07 pm

it's scallable vector graphics, meaning that it would scale itself to proper width and height. but spit in in two pages? only some grahics programs came to my mind, eg corel or inkscape
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Feike » August 3rd, 2006, 7:33 pm

but spit in in two pages? only some grahics programs came to my mind, eg corel or inkscape

So it can't be done in Delphi?
Feike
Active Member
Active Member
 
Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

Postby Johnny_Bit » August 4th, 2006, 5:47 am

And you know how hard it's done? Sime way wouldbe draw metafile on bitmap then split bitmap, as I am no expert when it commes to metafiles i think that best wa to do it without bitmap wouldbe fixed-point scale and then place virtual ruller on middle, then cut objects along it. but how, I don't know
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Kambiz » August 4th, 2006, 12:39 pm

There's no need to physically split the metafile.
  1. Devide the metafile to some logical sections. For example to print an A3 size metafile, you should consider two A4 size sections.
  2. For each section, offset origion of the destination canvas to top-left corner of the section.
  3. Stretch draw the metafile on the canvas, as you print on an A3 paper. However, your actual canvas size should be A4 size.
That's all.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2424
Joined: March 7th, 2003, 7:10 pm

Postby Feike » August 8th, 2006, 11:42 am

There's no need to physically split the metafile.

1. Devide the metafile to some logical sections. For example to print an A3 size metafile, you should consider two A4 size sections.
2. For each section, offset origion of the destination canvas to top-left corner of the section.
3. Stretch draw the metafile on the canvas, as you print on an A3 paper. However, your actual canvas size should be A4 size.


How can I devide a canvas in sections?
Can you give some more info?
Thanks in advance
Feike
Active Member
Active Member
 
Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

Postby Kambiz » August 11th, 2006, 4:02 pm

Feike wrote:How can I devide a canvas in sections?

In the same way you divide a paper; by measuring and locating the right coordinates.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2424
Joined: March 7th, 2003, 7:10 pm

Postby Feike » August 11th, 2006, 8:17 pm

Is this what you mean?

Code: Select all
procedure split metafile(Index:Integer);
var
 BWidth, BHeight : Integer;
 SrcRect, DestRect : TRect;
 BlzCanvas:TCanvas;
begin
 BWidth := Picture.Width div 2;
 BHeight := Picture.Height div 2;

 DestRect := pa4; // a4 papersize

 SrcRect.Left := (Index mod 2) * BWidth;
 SrcRect.Top := (Index div 2) * BHeight;
 SrcRect.Right := SrcRect.Left + BWidth;
 SrcRect.Bottom := SrcRect.Top + BHeight;

 try
   BlzCanvas := TMetafileCanvas.Create(FPicture.Metafile,0);
   BlzCanvas.Draw(0 - (SrcRect.Left ),0 - (SrcRect.Top ),Picture.Metafile);
 finally
   BlzCanvas.Free;
 end;
  PreviewPrinter1.Canvas.StretchDraw(pa4,BlzCanvas);
end;
Feike
Active Member
Active Member
 
Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

Postby Kambiz » August 12th, 2006, 4:54 am

Yes!

You do not need BlzCanvas.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2424
Joined: March 7th, 2003, 7:10 pm

Postby Feike » August 12th, 2006, 7:39 am

I tried this and it works!

Thanks for your help!
Feike
Active Member
Active Member
 
Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron