小弟在image上自绘制图形,并均匀显示在A4纸上。大家都知道,放大会带来锯齿的问题,所以我绘制在Tmetafile上,这样打印起来,由于是矢量图,不会有锯齿。
   但是,问题是如何显示在 Image控件上? 是要用GDI+图形库?这个东西会大幅度增加exe大小吗? 我想了一个笨方法,就是在image上同时绘制一遍?  麻烦高手赐教,谢谢!

解决方案 »

  1.   

     button1: 
     mc   :=   TMetafileCanvas.Create(mf,   0);
      DrawReport(TCanvas(mc)) ;                           //这是绘制过程
      mf.SaveToFile('234.wmf');                           //无内容
      w := mf.Width;                                      
      h := mf.Height;
      showmessage(inttostr(w)+' '+ inttostr(h)) ;         //单步发现w、h为0
      ImageBmp := TBitmap.Create;
      ImageBmp.Width := Panel1.Width;
      ImageBmp.Height := Panel1.Height;
      ImageBmp.Canvas.Draw(0,0,mf);
      ImageBmp.SaveToFile('22323.bmp');
    button2:                                                   //打印,可以看到正常的图
      w := mf.Width;
      h := mf.Height;
      if (w >0) and (h >0) then
      begin
        if dlgPntSet1.Execute then
        begin
          Printer.Orientation := poLandscape;
          Printer.BeginDoc;
          Printer.NewPage;
          Printer.Canvas.StretchDraw(Rect(0,   0,   Printer.PageWidth,   Printer.PageHeight),   mf);
          Printer.EndDoc;
        end;
       end;
      

  2.   

    你纸张有多大,就创建多大的 Tmetafile,直接显示到image上