⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pixman-image.c

📁 嵌入式图形库
💻 C
📖 第 1 页 / 共 2 页
字号:
    if (!image) {	if (free_me)	    free (free_me);	return NULL;    }        image->type = BITS;    image->bits.format = format;    image->bits.width = width;    image->bits.height = height;    image->bits.bits = bits;    image->bits.free_me = free_me;    image->bits.rowstride = rowstride_bytes / (int) sizeof (uint32_t); /* we store it in number								  * of uint32_t's								  */    image->bits.indexed = NULL;    pixman_region_fini (&image->common.full_region);    pixman_region_init_rect (&image->common.full_region, 0, 0,			     image->bits.width, image->bits.height);    reset_clip_region (image);    return image;}pixman_bool_tpixman_image_set_clip_region (pixman_image_t    *image,			      pixman_region16_t *region){    image_common_t *common = (image_common_t *)image;    if (region)    {	return pixman_region_copy (&common->clip_region, region);    }    else    {	reset_clip_region (image);	return TRUE;    }}/* Sets whether the clip region includes a clip region set by the client */voidpixman_image_set_has_client_clip (pixman_image_t *image,				  pixman_bool_t	  client_clip){    image->common.has_client_clip = client_clip;}pixman_bool_tpixman_image_set_transform (pixman_image_t           *image,			    const pixman_transform_t *transform){    static const pixman_transform_t id =    {	{ { pixman_fixed_1, 0, 0 },	  { 0, pixman_fixed_1, 0 },	  { 0, 0, pixman_fixed_1 }	}    };    image_common_t *common = (image_common_t *)image;    if (common->transform == transform)	return TRUE;    if (memcmp (&id, transform, sizeof (pixman_transform_t)) == 0)    {	free(common->transform);	common->transform = NULL;	return TRUE;    }    if (common->transform == NULL)	common->transform = malloc (sizeof (pixman_transform_t));    if (common->transform == NULL)	return FALSE;    memcpy(common->transform, transform, sizeof(pixman_transform_t));    return TRUE;}voidpixman_image_set_repeat (pixman_image_t  *image,			 pixman_repeat_t  repeat){    image->common.repeat = repeat;}pixman_bool_tpixman_image_set_filter (pixman_image_t       *image,			 pixman_filter_t       filter,			 const pixman_fixed_t *params,			 int		       n_params){    image_common_t *common = (image_common_t *)image;    pixman_fixed_t *new_params;    if (params == common->filter_params && filter == common->filter)	return TRUE;    new_params = NULL;    if (params)    {	new_params = pixman_malloc_ab (n_params, sizeof (pixman_fixed_t));	if (!new_params)	    return FALSE;	memcpy (new_params,		params, n_params * sizeof (pixman_fixed_t));    }    common->filter = filter;    if (common->filter_params)	free (common->filter_params);    common->filter_params = new_params;    common->n_filter_params = n_params;    return TRUE;}voidpixman_image_set_source_clipping (pixman_image_t  *image,				  pixman_bool_t    source_clipping){    image_common_t *common = &image->common;    if (source_clipping)	common->src_clip = &common->clip_region;    else	common->src_clip = &common->full_region;}/* Unlike all the other property setters, this function does not * copy the content of indexed. Doing this copying is simply * way, way too expensive. */voidpixman_image_set_indexed (pixman_image_t	 *image,			  const pixman_indexed_t *indexed){    bits_image_t *bits = (bits_image_t *)image;    bits->indexed = indexed;}voidpixman_image_set_alpha_map (pixman_image_t *image,			    pixman_image_t *alpha_map,			    int16_t         x,			    int16_t         y){    image_common_t *common = (image_common_t *)image;    return_if_fail (!alpha_map || alpha_map->type == BITS);    if (common->alpha_map != (bits_image_t *)alpha_map)    {	if (common->alpha_map)	    pixman_image_unref ((pixman_image_t *)common->alpha_map);	if (alpha_map)	    common->alpha_map = (bits_image_t *)pixman_image_ref (alpha_map);	else	    common->alpha_map = NULL;    }    common->alpha_origin.x = x;    common->alpha_origin.y = y;}voidpixman_image_set_component_alpha   (pixman_image_t       *image,				    pixman_bool_t         component_alpha){    image->common.component_alpha = component_alpha;}voidpixman_image_set_accessors (pixman_image_t             *image,			    pixman_read_memory_func_t	read_func,			    pixman_write_memory_func_t	write_func){    return_if_fail (image != NULL);    image->common.read_func = read_func;    image->common.write_func = write_func;}uint32_t *pixman_image_get_data (pixman_image_t *image){    if (image->type == BITS)	return image->bits.bits;    return NULL;}intpixman_image_get_width (pixman_image_t *image){    if (image->type == BITS)	return image->bits.width;    return 0;}intpixman_image_get_height (pixman_image_t *image){    if (image->type == BITS)	return image->bits.height;    return 0;}intpixman_image_get_stride (pixman_image_t *image){    if (image->type == BITS)	return image->bits.rowstride * (int) sizeof (uint32_t);    return 0;}intpixman_image_get_depth (pixman_image_t *image){    if (image->type == BITS)	return PIXMAN_FORMAT_DEPTH (image->bits.format);    return 0;}pixman_bool_tcolor_to_pixel (pixman_color_t *color,		uint32_t       *pixel,		pixman_format_code_t format){    uint32_t c = color_to_uint32 (color);    if (!(format == PIXMAN_a8r8g8b8	||	  format == PIXMAN_x8r8g8b8	||	  format == PIXMAN_a8b8g8r8	||	  format == PIXMAN_x8b8g8r8	||	  format == PIXMAN_r5g6b5	||	  format == PIXMAN_b5g6r5	||	  format == PIXMAN_a8))    {	return FALSE;    }    if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_ABGR)    {	c = ((c & 0xff000000) >>  0) |	    ((c & 0x00ff0000) >> 16) |	    ((c & 0x0000ff00) >>  0) |	    ((c & 0x000000ff) << 16);    }    if (format == PIXMAN_a8)	c = c >> 24;    else if (format == PIXMAN_r5g6b5 ||	     format == PIXMAN_b5g6r5)	c = cvt8888to0565 (c);#if 0    printf ("color: %x %x %x %x\n", color->alpha, color->red, color->green, color->blue);    printf ("pixel: %x\n", c);#endif    *pixel = c;    return TRUE;}pixman_bool_tpixman_image_fill_rectangles (pixman_op_t		    op,			      pixman_image_t		   *dest,			      pixman_color_t		   *color,			      int			    n_rects,			      const pixman_rectangle16_t   *rects){    pixman_image_t *solid;    pixman_color_t c;    int i;    if (color->alpha == 0xffff)    {	if (op == PIXMAN_OP_OVER)	    op = PIXMAN_OP_SRC;    }    if (op == PIXMAN_OP_CLEAR)    {	c.red = 0;	c.green = 0;	c.blue = 0;	c.alpha = 0;	color = &c;	op = PIXMAN_OP_SRC;    }    if (op == PIXMAN_OP_SRC)    {	uint32_t pixel;	if (color_to_pixel (color, &pixel, dest->bits.format))	{	    for (i = 0; i < n_rects; ++i)	    {		pixman_region16_t fill_region;		int n_boxes, j;		pixman_box16_t *boxes;		pixman_region_init_rect (&fill_region, rects[i].x, rects[i].y, rects[i].width, rects[i].height);		pixman_region_intersect (&fill_region, &fill_region, &dest->common.clip_region);		boxes = pixman_region_rectangles (&fill_region, &n_boxes);		for (j = 0; j < n_boxes; ++j)		{		    const pixman_box16_t *box = &(boxes[j]);		    pixman_fill (dest->bits.bits, dest->bits.rowstride, PIXMAN_FORMAT_BPP (dest->bits.format),				 box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1,				 pixel);		}		pixman_region_fini (&fill_region);	    }	    return TRUE;	}    }    solid = pixman_image_create_solid_fill (color);    if (!solid)	return FALSE;    for (i = 0; i < n_rects; ++i)    {	const pixman_rectangle16_t *rect = &(rects[i]);	pixman_image_composite (op, solid, NULL, dest,				0, 0, 0, 0,				rect->x, rect->y,				rect->width, rect->height);    }    pixman_image_unref (solid);    return TRUE;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -