易截截图软件、单文件、免安装、纯绿色、仅160KB

在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) { // 只


相关文档:

linux pppoe

手头有个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 ......

Linux core文件设置

在一个程序崩溃时,默认情况下是不产生core文件。
下面的命令可以检查生成core文件的选项是否打开:
$ulimit -a该命令将显示所有的用户定制,其中选项-a代表“all”。
$ulimit -c unlimited来让特定的用户可以产生core文件
core文件仅仅是一个内存映象(同时加上调试信息),主要是用来调试的。如果您根本就不想 ......

s3c2410平台下linux四键按键驱动程序

#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include<linux/config.h>
#include<linux/module.h>
#include<linux/version.h>
#include<linux/init.h>
#include<linux/kernel.h>
#include<linux/errno.h>
#include<linux/sche ......

linux sock_raw原始套接字编程

from:http://blog.chinaunix.net/u2/62281/showart_1096746.html
sock_raw原始套接字编程可以接收到本机网卡上的数据帧或者数据包,对与监听网络的流量和分析是很有作用的.一共可以有3种方式创建这种socket
 
1.socket(AF_INET, SOCK_RAW, IPPROTO_TCP|IPPROTO_UDP|IPPROTO_ICMP)发送接收ip数据包
2.socket(PF_PACK ......

Linux设备驱动学习-Davinci开发板上运行的hello模块


Linux设备驱动学习-Davinci开发板上运行的hello模块
 
看了很多个hello world了,自己来写一个在davinci板块上跑的吧。
主体很简单,就是一个C文件hello_davinci.c。
/*================hello_davinci.c==============*/
#include <linux/module.h>  /*所有模块都需要的头文件*/
#include <lin ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号