网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
03月24日漏签0天
c语言吧 关注:801,949贴子:4,376,819
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 首页 上一页 1 2 3
  • 35回复贴,共3页
  • ,跳到 页  
<<返回c语言吧
>0< 加载中...

回复:Cairo & C语言 & GTK+3.0 & Linux

  • 取消只看楼主
  • 收藏

  • 回复
  • AutoRunAs
  • 麻婆豆腐
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

/* cairo036.c 剪切图片内容 */
#include <cairo.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
static cairo_surface_t *surface = NULL;
struct df_canvas
{
char filename[28];
int type;
double width;
double height;
};
void df_draw_brush (struct df_canvas const *pcanvas)
{
cairo_surface_t* image;
cairo_t *cr;
cr = cairo_create (surface);
cairo_arc (cr, 300.0, 300.0, 150.0, 0, 2 * M_PI);
cairo_clip (cr); /* 以上内容做剪切路径 */
cairo_new_path (cr);
image = cairo_image_surface_create_from_png ("star.png"); /* 读取图片内容 */
cairo_scale (cr, 1.1, 1.1);
cairo_set_source_surface (cr, image, 0, 0);
cairo_paint (cr);
cairo_surface_destroy (image);
cairo_surface_write_to_png (surface, pcanvas -> filename);
cairo_destroy (cr);
}
void df_init_canvas (struct df_canvas const *pcanvas)
{
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int) pcanvas -> width, (int) pcanvas -> height);
}
int main (int argc, char *argv[])
{
struct df_canvas *canvas;
canvas = (struct df_canvas*) malloc (sizeof (struct df_canvas));
strncpy(canvas -> filename, "hello.png", 28);
canvas -> type = CAIRO_SURFACE_TYPE_IMAGE;
canvas -> width = 600.0;
canvas -> height = 600.0;
df_init_canvas (canvas);
df_draw_brush (canvas);
free (canvas);
if (surface != NULL) cairo_surface_destroy (surface);
return 0;
}


  • AutoRunAs
  • 麻婆豆腐
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

/* cairo037.c 重复图片 */
#include <cairo.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
static cairo_surface_t *surface = NULL;
struct df_canvas
{
char filename[28];
int type;
double width;
double height;
};
void df_draw_brush (struct df_canvas const *pcanvas)
{
int w, h;
cairo_surface_t *image;
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
cairo_t *cr;
cr = cairo_create (surface);
image = cairo_image_surface_create_from_png ("star.png"); /* 读取图片内容 */
w = cairo_image_surface_get_width (image);
h = cairo_image_surface_get_height (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_translate (cr, 0.5 * w, 0.5 * h);
cairo_rotate (cr, 18 * M_PI / 180);
/* cairo_scale (cr, 1.2, 1.2); */
cairo_translate (cr, -0.5 * w, -0.5 * h);
cairo_matrix_init_scale (&matrix, 8.0, 12.0);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (cr, pattern);
cairo_rectangle (cr, 100, 100, 400.0, 700.0);
cairo_fill (cr);
cairo_surface_destroy (image);
cairo_pattern_destroy (pattern);
cairo_surface_write_to_png (surface, pcanvas -> filename);
cairo_destroy (cr);
}
void df_init_canvas (struct df_canvas const *pcanvas)
{
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int) pcanvas -> width, (int) pcanvas -> height);
}
int main (int argc, char *argv[])
{
struct df_canvas *canvas;
canvas = (struct df_canvas*) malloc (sizeof (struct df_canvas));
strncpy(canvas -> filename, "hello.png", 28);
canvas -> type = CAIRO_SURFACE_TYPE_IMAGE;
canvas -> width = 600.0;
canvas -> height = 900.0;
df_init_canvas (canvas);
df_draw_brush (canvas);
free (canvas);
if (surface != NULL) cairo_surface_destroy (surface);
return 0;
}


2026-03-24 12:10:56
广告
不感兴趣
开通SVIP免广告
  • AutoRunAs
  • 麻婆豆腐
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

/* cairo038.c 镜像图片 */
#include <cairo.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
static cairo_surface_t *surface = NULL;
struct df_canvas
{
char filename[28];
int type;
double width;
double height;
};
void df_draw_brush (struct df_canvas const *pcanvas)
{
int w, h;
cairo_surface_t *image;
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
cairo_t *cr;
cr = cairo_create (surface);
image = cairo_image_surface_create_from_png ("star.png"); /* 读取图片内容 */
w = cairo_image_surface_get_width (image);
h = cairo_image_surface_get_height (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REFLECT); /* CAIRO_EXTEND_PAD */
cairo_translate (cr, 0.5 * w, 0.5 * h);
/* cairo_rotate (cr, 18 * M_PI / 180); */
/* cairo_scale (cr, 1.2, 1.2); */
cairo_translate (cr, -0.5 * w, -0.5 * h);
cairo_matrix_init_scale (&matrix, 1.0, 4.0);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (cr, pattern);
cairo_rectangle (cr, 0, 0, 600.0, 900.0);
cairo_fill (cr);
cairo_surface_destroy (image);
cairo_pattern_destroy (pattern);
cairo_surface_write_to_png (surface, pcanvas -> filename);
cairo_destroy (cr);
}
void df_init_canvas (struct df_canvas const *pcanvas)
{
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int) pcanvas -> width, (int) pcanvas -> height);
}
int main (int argc, char *argv[])
{
struct df_canvas *canvas;
canvas = (struct df_canvas*) malloc (sizeof (struct df_canvas));
strncpy(canvas -> filename, "hello.png", 28);
canvas -> type = CAIRO_SURFACE_TYPE_IMAGE;
canvas -> width = 600.0;
canvas -> height = 900.0;
df_init_canvas (canvas);
df_draw_brush (canvas);
free (canvas);
if (surface != NULL) cairo_surface_destroy (surface);
return 0;
}


  • AutoRunAs
  • 麻婆豆腐
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

/* cairo039.c 分割图片cairo_surface_map_to_image */
#include <cairo.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
static cairo_surface_t *surface = NULL;
struct df_canvas
{
char filename[28];
int type;
double width;
double height;
};
void df_draw_brush (struct df_canvas *pcanvas)
{
cairo_surface_t *image;
cairo_surface_t *gsurface;
int i;
char str[] = "0123456789";
cairo_rectangle_int_t prec = {0, 0, 64, 64};
image = cairo_image_surface_create_from_png ("boom.png"); /* 读取图片 580_64 */
for (i = 0; i < 10; i++)
{
pcanvas -> filename[5] = str[i];
prec.x = i * 64;
gsurface = cairo_surface_map_to_image (image, &prec);
cairo_surface_write_to_png (gsurface, pcanvas -> filename);
}
cairo_surface_destroy (image);
cairo_surface_destroy (gsurface);
}
void df_init_canvas (struct df_canvas const *pcanvas)
{
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int) pcanvas -> width, (int) pcanvas -> height);
}
int main (int argc, char *argv[])
{
struct df_canvas *canvas;
canvas = (struct df_canvas*) malloc (sizeof (struct df_canvas));
strncpy(canvas -> filename, "hello0.png", 28);
canvas -> type = CAIRO_SURFACE_TYPE_IMAGE;
canvas -> width = 600.0;
canvas -> height = 370.0;
df_init_canvas (canvas);
df_draw_brush (canvas);
free (canvas);
if (surface != NULL) cairo_surface_destroy (surface);
return 0;
}


  • AutoRunAs
  • 麻婆豆腐
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

C语言 _ XOXO 井字游戏 Tic-Tac-Toe [开源]
http://tieba.baidu.com/p/3970342930
XOXO 井字游戏 源码下载
http://pan.baidu.com/s/1kTAcaLx
C语言 > zzgtkcairo > gtkcairo004.7z


  • AutoRunAs
  • 麻婆豆腐
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

/* cairo040.c 掩模 cairo_mask_surface */
#include <cairo.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
static cairo_surface_t *surface = NULL;
struct df_canvas
{
char filename[28];
int type;
double width;
double height;
};
void df_draw_brush (struct df_canvas *pcanvas)
{
cairo_surface_t *image;
cairo_t *cr;
image = cairo_image_surface_create_from_png ("star.png"); /* 读取图片内容 */
pcanvas -> width = cairo_image_surface_get_width (image);
pcanvas -> height = cairo_image_surface_get_height (image);
/* 创建同图片image大小一致的画布surface */
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, pcanvas -> width, pcanvas -> height);
cr = cairo_create (surface);
cairo_rectangle (cr, 80, 60, 220, 440); /* 长方形掩模 */
cairo_set_source_rgb (cr, 0.7, 0.5, 0.7); /* 长方形填充色 */
cairo_fill_preserve (cr);
cairo_stroke (cr);
cairo_set_source_surface (cr, image, 0, 0);
cairo_mask_surface (cr, surface,0, 0); /* 掩模操作 */
cairo_stroke (cr);
cairo_surface_write_to_png (surface, pcanvas -> filename);
cairo_surface_destroy (image);
cairo_destroy (cr);
}
void df_init_canvas (struct df_canvas const *pcanvas)
{
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int) pcanvas -> width, (int) pcanvas -> height);
}
int main (int argc, char *argv[])
{
struct df_canvas *canvas;
canvas = (struct df_canvas*) malloc (sizeof (struct df_canvas));
strncpy(canvas -> filename, "hello.png", 28);
canvas -> type = CAIRO_SURFACE_TYPE_IMAGE;
canvas -> width = 600.0;
canvas -> height = 600.0;
df_init_canvas (canvas);
df_draw_brush (canvas);
free (canvas);
if (surface != NULL) cairo_surface_destroy (surface);
return 0;
}


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 首页 上一页 1 2 3
  • 35回复贴,共3页
  • ,跳到 页  
<<返回c语言吧
分享到:
©2026 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示