代码之家  ›  专栏  ›  技术社区  ›  Branko

将EMF转换为BMP

  •  2
  • Branko  · 技术社区  · 14 年前

    如何用Delphi2010将EMF转换成BMP?

    3 回复  |  直到 14 年前
        1
  •  3
  •   Bharat    14 年前

    使用此代码

    procedure ConvertEMF2BMP(EMFFileName, BMPFileName: String) ;
    var
       MetaFile : TMetafile;
       Bitmap : TBitmap;
    begin
       Metafile := TMetaFile.Create;
       Bitmap := TBitmap.Create;
       try
         MetaFile.LoadFromFile(EMFFileName) ;
         with Bitmap do
         begin
           Height := Metafile.Height;
           Width := Metafile.Width;
           Canvas.Draw(0, 0, MetaFile) ;
           SaveToFile(BMPFileName) ;
         end;
       finally
         Bitmap.Free;
         MetaFile.Free;
       end;
    end;
    
        2
  •  4
  •   A.Bouchez    14 年前

    如果你想用反校准绘制EMF,你可以使用我们的免费软件syngdiplus库:

    Gdip := TGDIPlusFull.Create;
    MF := TMetaFile.Create;
    MF.LoadFromFile(Files[Tag]);
    Bmp := Gdip.DrawAntiAliased(MF,100,100); // 100% zoom in both axis
    img1.Picture.Assign(Bmp);
    

    绘图是使用gdi+完成的,因此渲染效果比直接画布要好得多。 您可以尝试通过将位图拉伸到较小的大小来使用基本反对齐,但在这种情况下,字体渲染将被更改。我们的本地GDI+绘图产生更好的渲染质量。 见 http://synopse.info/forum/viewtopic.php?id=10

        3
  •  1
  •   Uli Gerhardt    14 年前

    尝试以下方法:

    var
      bmp: TBitmap;
      wmf: TMetafile;
    bmp.SetSize(wmf.Width, wmf.Height);
    bmp.Canvas.Draw(0, 0, wmf);