델파이/델파이관련

Canvas Antialias

지병철 2014. 8. 13. 16:19

procedure TForm1.AntiAlias;

const

  ZOOM = 16;

var

  Bmp: TBitmap;

  StretchMode: Integer;

begin

  Bmp := TBitmap.Create;

  // create a large bitmap and set coordinate extents accordingly

  Bmp.SetSize(qrimage1.clientwidth * ZOOM, qrimage1.ClientHeight * ZOOM);

  SetMapMode(Bmp.Canvas.Handle, MM_ISOTROPIC);

  SetWindowExtEx(Bmp.Canvas.Handle, 100, 100, nil);

  SetViewportExtEx(Bmp.Canvas.Handle, 100 * ZOOM, 100 * ZOOM, nil);

  // without halftone we won't gain anything

  SetStretchBltMode(Bmp.Canvas.Handle, HALFTONE);

  // transfer what's on the list box to bitmap canvas

  BitBlt(Bmp.Canvas.Handle, 0, 0, Bmp.Width, Bmp.Height,

          qrimage1.Canvas.Handle, 0, 0, SRCCOPY);


  Bmp.Canvas.Polygon([Point(20, 10), Point(10, 50), Point(80, 30)]);

  Bmp.Canvas.Ellipse(100,100,150,150);

  Bmp.Canvas.Rectangle(150,150,200,200);


  // transfer bitmap contents

  StretchMode := SetStretchBltMode(qrimage1.Canvas.Handle, HALFTONE);

  StretchBlt(qrimage1.Canvas.Handle, 0, 0,

      qrimage1.ClientWidth * ZOOM, qrimage1.ClientHeight * ZOOM,

      Bmp.Canvas.Handle, 0, 0, Bmp.Width, Bmp.Height, SRCCOPY);

  SetStretchBltMode(qrimage1.Canvas.Handle, StretchMode);


  Bmp.Free;

end;