易截截图软件、单文件、免安装、纯绿色、仅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获取本机IP、MAC示例程序

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstring>
using namespace std;
void peek_interfaces(int ......

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内核结构体

 -------------------------------------------------------------------------------------------------------
//By:yuyongbao
//QQ:673360056
LINUX 内核结构体
struct attribute
{
    const char    * name;
    struct module     &nb ......

Linux 无线网络技术: WLAN

当今,不考虑 Linux 和无线网络技术的话,就无法谈到计算机和网络。在这篇文章中,Sreekrishnan Venkateswaran 用
Linux 观点阐释了通过 WLAN、Bluetooth、GPRS、GSM 以及 IrDA
实现无线联网。他使用各种不同的无线设备和相应的内核层,以及用户空间工具来示范它们在 Linux 下如何工作。
无线技术,例如
WLAN (Wireles ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号