在linux下使用gtk的gdk
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
以下是代码实例,例子中用到的两张图片在这里:
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
static GdkPixbuf *bkpixbuf;
static GdkPixbuf *footballpixbuf;
static gboolean
on_expose_event (GtkWidget * widget,
GdkEventExpose * event, gpointer data)
{
cairo_t *cr;
cr = gdk_cairo_create (widget->window);
gdk_cairo_set_source_pixbuf(cr, bkpixbuf, 0, 0);
cairo_paint(cr);
cairo_destroy (cr);
return FALSE;
}
gboolean blttransparent(GdkPixbuf *dest, const GdkPixbuf *src, gint destx, gint desty, guint transcolor) {
GdkPixbuf *maskpixbuf = NULL; /* 蒙板 */
guchar *p = NULL, *dp = NULL, *sp = NULL;
gint x = 0, y = 0, i = 0;
/* 检查目的区域 */
if(destx + gdk_pixbuf_get_width(src) >= gdk_pixbuf_get_width(dest) ||
desty + gdk_pixbuf_get_height(src) >= gdk_pixbuf_get_height(dest)) { /* 超出目的大小, 什么也不做 */
return TRUE;
}
/* 检查颜色采样数 */
if(gdk_pixbuf_get_bits_per_sample(dest) != 8 ||
gdk_pixbuf_get_bits_per_sample(src) != 8) { // 只
相关文档:
手头有个ep9315的板,今天突然想起跑一下adsl上网。晚上回来就开始搞。
从10点到现在,终于能够跑起来。
给大家借鉴一下。
1.编译内核,把ppp的那些选项选上。 (我用2.6.8.1的kernel,cirrus 的patch)
2.libpcap-0.9.1 这个包是pppd需要的。
./configure CC=arm-linux-gcc CFLAGS=-msoft-float --target=arm-linu ......
#!/bin/bash
while getopts "ab:cd:" Option
# b and d take arguments
#
do
case $Option in
a) echo -e "a = $OPTIND";;
b) echo -e "b = $OPTIND $OPTARG";;
c) echo -e "c = $OPTIND";;
d) echo -e "d = $OPTIND $OPTARG";;
esac
done
shift $(($OPTIND - 1)) ......
-------------------------------------------------------------------------------------------------------
//By:yuyongbao
//QQ:673360056
//平台powerpc mpc8379e linux 2.6.22
1、先用fdisk 给硬盘分一个区,用作文件系统。参照u-boot-ppc编译说明一文。
2、用mke2fs格式化硬盘的一个分区mke2fs /dev/sd ......
在Solaris上面工作有几个不方便地方:
一个是ls不能按照文件类型显示颜色;
另一个是VI也不能显现语法色彩;
这里就来说明如何解决这两个问题:
其实这两个问题都是Solaris自身所带的ls和vi版本的问题;
所以解决办法就是下载最新的ls和vim源文件包重新编译进行安装,看上去好像挺麻烦,其实就几步,很简单的:
最新的ls是在 ......
Linux设备驱动学习-Davinci开发板上运行的hello模块
看了很多个hello world了,自己来写一个在davinci板块上跑的吧。
主体很简单,就是一个C文件hello_davinci.c。
/*================hello_davinci.c==============*/
#include <linux/module.h> /*所有模块都需要的头文件*/
#include <lin ......