用API处理位图

procedure TForm1.Button1Click(Sender: TObject);
var
  dc : hdc;
  MemDc : hdc;
  MemBitmap : hBitmap;
  OldMemBitmap : hBitmap;
begin

{Get the handle to the screen's dc}
  dc := GetDc(0);

{Create and retrieve a handle to a memory dc based on the screen}
  MemDc := CreateCompatibleDc(dc);

{Create a bitmap that is compatible with the display.}
{Note: if you pass "MemDc" to CreateCompatibleBitmap()}
{instead of "dc", you will get a monochrome bitmap!}
  MemBitmap := CreateCompatibleBitmap(dc, 100, 100);

{Release the screen dc}
  ReleaseDc(0, dc);

{Select the bitmap surface into the MemDc}
{remembering the default bitmap}
  OldMemBitmap := SelectObject(MemDc, MemBitmap);

{Draw on the MemoryDc}
  PatBlt(MemDc, 0, 0, 100, 100, WHITENESS);
  Ellipse(MemDc, 0, 0, 100, 100);

{Copy the MemDc to the Form Canvas}
  BitBlt(Form1.Canvas.Handle,
         100, 100,
         100, 100,
         MemDc,
         0, 0,
         SRCCOPY);

{Select the default bitmap back into the memory dc}
  SelectObject(MemDc, OldMemBitmap);

{Note: You can now use the memory bitmap handle with}
{functions such as GetDiBits()}

{Delete the Memory Bitmap}
  DeleteObject(MemBitmap);

{Delete the MemoryDc}
  DeleteDc(MemDc);

end;

 

转载于:https://www.cnblogs.com/yzryc/p/6373618.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值