QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 3051|回复: 0
打印 上一主题 下一主题

Create memory DCs and BitBlt to the screen with BCB.

[复制链接]
字体大小: 正常 放大
韩冰        

823

主题

3

听众

4048

积分

我的地盘我做主

该用户从未签到

发帖功臣 元老勋章

跳转到指定楼层
1#
发表于 2005-1-26 12:43 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
<>Create memory DCs and BitBlt to the screen with BCB. </P>0 D3 ^' B$ k+ H# N8 X" B8 E
<>Answer: The VCL TBitmap class contains a Canvas that encapsulates a memory DC for the bitmap. You can create a memory DC by creating a TBitmap object and drawing on its canvas. </P>$ p  s  V$ ^( l2 v) c/ V# G
<>void __fastcall TForm1::FormPaint(TObject *Sender)1 F7 v' F5 d# f) {+ A7 q! J
{3 q3 G, n+ A: F+ W0 E1 r0 Y5 r9 H
    Graphics::TBitmap *bmp = new Graphics::TBitmap;7 }3 V! a3 g- R' J3 ~: G: x9 O$ `
    bmp-&gt;Width  = ClientWidth;
6 ]/ }/ A! L6 P$ E( y  Z- a    bmp-&gt;Height = ClientHeight;
8 i6 J9 V/ M7 n/ [    bmp-&gt;Canvas-&gt;Rectangle(0,0,ClientWidth/2, ClientHeight/2);
( U! J: K7 t4 q+ e    Canvas-&gt;Draw(0,0,bmp);( F# e0 i+ \1 Y* F
    delete bmp;- v! V: B$ Z9 |( i$ i; p
}</P>, v; O" B- F* f' J6 O
<>Notes: The Canvas property of TBitmap is NULL until you use the Canvas for the first time. In the code above, Canvas is NULL until the Rectangle call. It doesn't matter how you access the Canvas. The Canvas is created in the first call to the GetCanvas function (the read function for the Canvas property). </P>
& m! X$ ?7 C9 [. f" @) }9 V% R<>The Draw method of TCanvas results in an API StretchBlt function call (StretchBlt will be called if source graphic is a bitmap, DrawIcon will be called if the graphic is an icon). StretchBlt blasts the contents of the memory bitmap into the display canvas. The CopyRect method of TCanvas also calls the StretchBlt function. However, CopyRect copies from a source Canvas into another Canvas, and the source Canvas does not have to be the same size as the destination. </P>
) h8 ]( J4 C* N+ a0 m# p<>Setting the Width and Height of the TBitmap object is important when you are not loading a bitmap image into the object. If you do load a bitmap into the object from a resource or BMP file, the Width and Height properties will be set to match the loaded image. In this case, omit the assignments to Height and Width. For example: </P>9 g* c8 N0 H* f% s1 `1 w
<>Graphics::TBitmap *bmp = new Graphics::TBitmap;& t1 O6 L' l3 b. J" ~; z
bmp-&gt;LoadFromResourceName( (int) HInstance, "IDD_BITMAP1");6 n2 k% T/ R; P* T+ L% G
bmp-&gt;Canvas-&gt;Rectangle(10,10,ClientWidth/2, ClientHeight/2);) R; \) s  D' R1 L/ B
Canvas-&gt;Draw(0,0,bmp);
4 z6 s+ t9 \, vdelete bmp;</P>
zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
您需要登录后才可以回帖 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085
fastpost

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2025-5-11 17:32 , Processed in 0.630927 second(s), 51 queries .

回顶部