在linux下使用gtk的gdk-pixbuf实现类似windows下的透明贴图

aishen944-163.com

转贴请注明出处,谢谢!!

 

 

其实透明贴图的原理就是进行xor运算,

 

基本公式:A  xor A = 0    A xor 0 = A   A xor A xor B  = B

 

假如现在有两张图片,一张是我们要对其进行贴图的图片A, 另外一张是要被贴图的图片B

 

1, 复制图片B的一份拷贝为C

2, 将C中指定的背景色变为全白(0xffffff),其他颜色变为全黑(0x00)

3,     依次执行如下运算:

        A  xor B

        A  and C

        A  xor B

 

        对于C中的白色执行运算后的结果如下:

        ((A xor B) and 0xfffffff) xor B =  A xor B xor B =  A

 

        对于C中的黑色执行运算后的结果如下:

        ((A xor B) and 0x0000) xor B =  0 xor B = B

 

 

以下是代码实例,例子中用到的两张图片在这里:

 

 

 

 

 

Table of Contents I. API Reference Initialization and Versions - Library version numbers. The GdkPixbuf Structure - Information that describes an image. Reference Counting and Memory Mangement - Functions for reference counting and memory management on pixbufs. File Loading - Loading a pixbuf from a file. File saving - Saving a pixbuf to a file. Image Data in Memory - Creating a pixbuf from image data that is already in memory. Inline data - Functions for inlined pixbuf handling. Scaling - Scaling pixbufs and scaling and compositing pixbufs Rendering - Rendering a pixbuf to a GDK drawable. Drawables to Pixbufs - Getting parts of a GDK drawable's image data into a pixbuf. Utilities - Utility and miscellaneous convenience functions. Animations - Animated images. GdkPixbufLoader - Application-driven progressive image loading. Module Interface - Extending gdk-pixbuf gdk-pixbuf Xlib initialization - Initializing the gdk-pixbuf Xlib library. Xlib Rendering - Rendering a pixbuf to an X drawable. X Drawables to Pixbufs - Getting parts of an X drawable's image data into a pixbuf. XlibRGB - Rendering RGB buffers to X drawables. II. Tools Reference gdk-pixbuf-csource - C code generation utility for GdkPixbuf images gdk-pixbuf-query-loaders - GdkPixbuf loader registration utility Index Index of deprecated symbols Index of new symbols in 2.2 Index of new symbols in 2.4 Index of new symbols in 2.6 Index of new symbols in 2.8 A. Porting applications from Imlib to gdk-pixbuf Introduction Differences between Imlib and gdk-pixbuf Initialization Memory management The Rendering Process Converting Applications to gdk-pixbuf Image loading and creation Rendering Images Scaling Images
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值