Perl/TkFAQ-11.1如何在画布中显示位图?

王朝perl·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

原文:

11.1. Display a bitmap?

Unlike other widgets the Canvas does not take the -bitmap configuration option. One of the ways to place things - including bitmaps - onto a Canvas is to call create on it. To emphasize how a Canvas handles bitmaps differently from the configurable widgets let me assume that you wanted to specify the 'hourglass' built in bitmap in the following. (For more on xbm file specification see a previous question [10.9] within this FAQ.) Here is a way to combine the Canvas; and create; calls: my($canvar) = $main->Canvas(); my($bittag) = $canvar->create('bitmap',10,10, -bitmap=>'hourglass'); $canvar->pack;

You can also create an image that will display a bitmap (plus a whole lot more): my($canvar) = $main->Canvas(); my($bitmap) = $main->Bitmap(-data => $data); my($bittag) = $canvar->create(qw(image 10 10), -image => $bitmap); $canvar->pack; MainLoop;

译文:

11.1 如何在画布中显示位图?

画布不像其它的组件,它不能使用-bitmap的配置选项显示位图。而在画布中设置元素(包括位图)的一个方法是调用create方法。下面我们就假设你想要设置一个内置位图“hourglass”,以此为例向大家解释一下在画布中显示位图有什么不同。(关于xbm文件的问题,请参阅前面的10.9部分)

my($canvar) = $main->Canvas();

my($bittag) = $canvar->create('bitmap',10,10, -bitmap=>'hourglass');

$canvar->pack;

当然,你也可以自己创建位图(还有很多其它的内容):

my($canvar) = $main->Canvas();

my($bitmap) = $main->Bitmap(-data => $data);

my($bittag) = $canvar->create(qw(image 10 10), -image => $bitmap);

$canvar->pack;

MainLoop;

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航