当前位置: 首页>>代码示例>>C++>>正文


C++ Graph_IsValid函数代码示例

本文整理汇总了C++中Graph_IsValid函数的典型用法代码示例。如果您正苦于以下问题:C++ Graph_IsValid函数的具体用法?C++ Graph_IsValid怎么用?C++ Graph_IsValid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Graph_IsValid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Graph_Replace

int Graph_Replace( LCUI_Graph *back, const LCUI_Graph *fore, LCUI_Pos pos )
{
	LCUI_Graph write_slot;
	LCUI_Rect read_rect,write_rect;
	
	if( !Graph_IsValid(back) || !Graph_IsValid(fore) ) {
		return -1;
	}

	write_rect.x = pos.x;
	write_rect.y = pos.y;
	write_rect.width = fore->width;
	write_rect.height = fore->height;
	Graph_Quote( &write_slot, back, &write_rect );
	Graph_GetValidRect( &write_slot, &write_rect );
	Graph_GetValidRect( fore, &read_rect );
	if( write_rect.width <= 0 || write_rect.height <= 0
	 || read_rect.width <= 0 || read_rect.height <= 0 ) {
		return -2;
	}
	pos.x = read_rect.x;
	pos.y = read_rect.y;
	fore = Graph_GetQuote( fore );
	back = Graph_GetQuote( back );

	switch( fore->color_type ) {
	case COLOR_TYPE_RGB888:
		return Graph_RGBReplaceRGB( back, write_rect, fore, pos );
	case COLOR_TYPE_ARGB8888:
		return Graph_ARGBReplaceARGB( back, write_rect, fore, pos );
	default:break;
	}

	return -1;
}
开发者ID:rokite,项目名称:LCUI,代码行数:35,代码来源:graph.c

示例2: Graph_Mix

int Graph_Mix( LCUI_Graph *back, const LCUI_Graph *fore, LCUI_Pos pos )
{
	LCUI_Graph write_slot;
	LCUI_Rect read_rect, write_rect;
	void (*mixer)(LCUI_Graph*, LCUI_Rect, const LCUI_Graph *, LCUI_Pos) = NULL;

	/* 预先进行有效性判断 */
	if( !Graph_IsValid(back) || !Graph_IsValid(fore) ) {
		return -1;
	}

	write_rect.x = pos.x;
	write_rect.y = pos.y;
	write_rect.width = fore->width;
	write_rect.height = fore->height;
	LCUIRect_GetCutArea( Size( back->width, back->height ),
			     write_rect, &read_rect );
	write_rect.x += read_rect.x;
	write_rect.y += read_rect.y;
	write_rect.width = read_rect.width;
	write_rect.height = read_rect.height;
	Graph_Quote( &write_slot, back, &write_rect );
	/* 获取实际操作区域 */
	Graph_GetValidRect( &write_slot, &write_rect );
	Graph_GetValidRect( fore, &read_rect );
	/* 若读或写的区域无效 */
	if( write_rect.width <= 0 || write_rect.height <= 0
	 || read_rect.width <= 0 || read_rect.height <= 0 ) {
		return -2;
	}
	pos.x = read_rect.x;
	pos.y = read_rect.y;
	/* 获取引用的源图像 */
	fore = Graph_GetQuote( fore );
	back = Graph_GetQuote( back );

	switch( fore->color_type ) {
	case COLOR_TYPE_RGB888:
		if( back->color_type == COLOR_TYPE_RGB888 ) {
			mixer = Graph_RGBReplaceRGB;
		} else {
			mixer = Graph_ARGBReplaceRGB;
		}
		break;
	case COLOR_TYPE_ARGB8888:
		if( back->color_type == COLOR_TYPE_RGB888 ) {
			mixer = Graph_RGBMixARGB;
		} else {
			mixer = Graph_ARGBMixARGB;
		}
	default:break;
	}

	if( mixer ) {
		mixer( back, write_rect, fore, pos );
		return 0;
	}
	return -3;
}
开发者ID:WhatDream,项目名称:LCUI,代码行数:59,代码来源:graph.c

示例3: Graph_FillImage

LCUI_API int Graph_FillImage(	LCUI_Graph *graph,
				LCUI_Graph *bg, 
				int mode,
				LCUI_RGB color )
{
	LCUI_Size size;
	LCUI_Pos pos;
	LCUI_Graph temp_bg;
	LCUI_BOOL replace_mix;
	
	if( Check_Option( mode, GRAPH_MIX_FLAG_REPLACE ) ) {
		/* 将alpha通道置为0 */
		Graph_FillAlpha( graph, 0 );
		replace_mix = TRUE;
	} else {
		/* 填充背景色,将alpha通道置为255 */
		Graph_FillColor( graph, color );
		Graph_FillAlpha( graph, 255 );
		replace_mix = FALSE;
	}
	if(!Graph_IsValid(bg) || !Graph_IsValid(graph)) {
		return -1; 
	}
	size.w = graph->w;
	size.h = graph->h;
	Graph_Init(&temp_bg);
	pos.x = pos.y = 0;
	/* 平铺 */
	if( Check_Option( mode, LAYOUT_TILE ) ) {
		return Graph_Tile( bg, graph, replace_mix );
	}
	/* 缩放 */
	if( Check_Option( mode, LAYOUT_ZOOM ) ) {
		Graph_Zoom( bg, &temp_bg, TRUE, size );
		pos.x = (size.w - temp_bg.w) / 2.0;
		pos.y = (size.h - temp_bg.h) / 2.0;
		bg = &temp_bg;
	}
	/* 拉伸 */
	else if( Check_Option( mode, LAYOUT_STRETCH ) ) {
		Graph_Zoom( bg, &temp_bg, FALSE, size );
		bg = &temp_bg;
	}
	/* 居中 */
	else if( Check_Option( mode, LAYOUT_CENTER ) ) {
		pos.x = (size.w - bg->w) / 2.0;
		pos.y = (size.h - bg->h) / 2.0;
	}
	if( replace_mix ) {
		Graph_Replace( graph, bg, pos );
	} else {
		Graph_Mix( graph, bg, pos );
	}
	Graph_Free( &temp_bg );
	return 0; 
}
开发者ID:fshunj,项目名称:LCUI,代码行数:56,代码来源:LCUI_Graph.c

示例4: PictureBox_MoveViewArea

/* 移动PictureBox部件内的图片的显示区域的位置 */
LCUI_API int
PictureBox_MoveViewArea( LCUI_Widget *widget, LCUI_Pos des_pos )
{
	LCUI_Size size;
	LCUI_Graph *p;
	LCUI_PictureBox *pic_box;
	
	pic_box = Widget_GetPrivData(widget);
	
	if(!Graph_IsValid(pic_box->image)) {
		return -1;
	}
	if(pic_box->scale == 1.00 || !Graph_IsValid(&pic_box->buff_graph)) {
		p = pic_box->image;
	} else {
		p = &pic_box->buff_graph;
	}
	size.w = pic_box->read_box.width;
	size.h = pic_box->read_box.height;
	/* 处理区域数据,使之为有效区域 */
	if(des_pos.x < 0) {
		des_pos.x = 0;
	}
	if(des_pos.y < 0) {
		des_pos.y = 0;
	}
	if(des_pos.x + size.w > p->w) {
		des_pos.x = p->w - size.w;
	}
	if(des_pos.y + size.h > p->h) {
		des_pos.y = p->h - size.h;
	}
	if(des_pos.x == pic_box->read_box.x 
	&& des_pos.y == pic_box->read_box.y) {
		return 0; 
	}
	/* 更新图片盒子内的图像 */
	pic_box->read_box.x = des_pos.x;
	pic_box->read_box.y = des_pos.y;
	/* 重新计算中心点的位置 */ 
	pic_box->read_box.center_x = (des_pos.x + size.w/2.0)/p->w;
	pic_box->read_box.center_y = (des_pos.y + size.h/2.0)/p->h;
	
	Widget_Draw(widget);
	//用于调试
	//printf("read box: %d,%d,%d,%d; %d/%d, %d/%d\n", 
	//pic_box->read_box.x, pic_box->read_box.y, 
	//pic_box->read_box.width, pic_box->read_box.height, 
	//pic_box->read_box.x + pic_box->read_box.width,
	//pic_box->read_box.y + pic_box->read_box.height,
	//pic_box->buff_graph.w, pic_box->buff_graph.h);
	return 0;
}
开发者ID:fshunj,项目名称:LCUI,代码行数:54,代码来源:picturebox.c

示例5: Graph_PutImage

LCUI_API int Graph_PutImage( LCUI_Graph *graph, LCUI_Graph *image, int flag )
{
	LCUI_Pos pos;
	
	if(!Graph_IsValid(graph) || ! Graph_IsValid(image)) {
		return -1; 
	}
	pos.x = pos.y = 0;
	if((flag & ALIGN_TOP_LEFT) == ALIGN_TOP_LEFT); /* 左上角对齐 */
	else if((flag & ALIGN_TOP_CENTER) == ALIGN_TOP_CENTER) {
		/* 向上中间对齐 */
		pos.x = (graph->w - image->w) / 2;  
	}/* 向右上角对齐 */
	else if((flag & ALIGN_TOP_RIGHT) == ALIGN_TOP_RIGHT) {
		pos.x = graph->w - image->w;
	}/* 向中央偏左对齐 */ 
	else if((flag & ALIGN_MIDDLE_LEFT) == ALIGN_MIDDLE_LEFT) {
		pos.y = (graph->h - image->h) / 2; 
	}/* 向正中央对齐 */
	else if((flag & ALIGN_MIDDLE_CENTER) == ALIGN_MIDDLE_CENTER) { 
		pos.x = (graph->w - image->w) / 2;
		pos.y = (graph->h - image->h) / 2;
	}/* 向中央偏右对齐 */
	else if((flag & ALIGN_MIDDLE_RIGHT) == ALIGN_MIDDLE_RIGHT) { 
		pos.x = graph->w - image->w;
		pos.y = (graph->h - image->h) / 2;
	}/* 向底部偏左对齐 */ 
	else if((flag & ALIGN_BOTTOM_LEFT) == ALIGN_BOTTOM_LEFT) {
		pos.y = graph->h - image->h; 
	}/* 向底部居中对齐 */
	else if((flag & ALIGN_BOTTOM_CENTER) == ALIGN_BOTTOM_CENTER) { 
		pos.x = (graph->w - image->w) / 2;
		pos.y = graph->h - image->h;
	}/* 向底部偏右对齐 */
	else if((flag & ALIGN_BOTTOM_RIGHT) == ALIGN_BOTTOM_RIGHT) { 
		pos.x = graph->w - image->w;
		pos.y = graph->h - image->h;
	}
	
	if( Check_Option(flag, GRAPH_MIX_FLAG_OVERLAY) ) {
	/* 如果包含GRAPH_MIX_FLAG_OVERLAY选项 */
		Graph_Mix(graph, image, pos); 
	}
	else if( Check_Option(flag, GRAPH_MIX_FLAG_REPLACE) ) {
	/* 如果包含GRAPH_MIX_FLAG_REPLACE选项 */
		Graph_Replace(graph, image, pos); 
	} else {
		Graph_Mix(graph, image, pos);
	}
	
	return 0;
}
开发者ID:fshunj,项目名称:LCUI,代码行数:52,代码来源:LCUI_Graph.c

示例6: Graph_VertiFlipARGB

static int Graph_VertiFlipARGB( const LCUI_Graph *graph, LCUI_Graph *buff )
{
	int y;
	LCUI_Rect rect;
	uchar_t *byte_src, *byte_des;

	if(!Graph_IsValid(graph)) {
		return -1;
	}
	Graph_GetValidRect( graph, &rect );
	graph = Graph_GetQuote( graph );
	buff->opacity = graph->opacity;
	buff->color_type = graph->color_type;
	if( 0 != Graph_Create( buff, rect.width, rect.height ) ) {
		return -2;
	}
	byte_src = graph->bytes + (rect.y + rect.h - 1)*graph->bytes_per_row;
	byte_src += rect.x * graph->bytes_per_pixel;
	byte_des = buff->bytes;
	for( y=0; y<rect.h; ++y ) {
		memcpy( byte_des, byte_src, buff->bytes_per_row );
		byte_src -= graph->bytes_per_row;
		byte_des += buff->bytes_per_row;
	}
	return 0;
}
开发者ID:WhatDream,项目名称:LCUI,代码行数:26,代码来源:graph.c

示例7: Graph_HorizFlipARGB

static int Graph_HorizFlipARGB( const LCUI_Graph *graph, LCUI_Graph *buff )
{
	int x, y;
	LCUI_Rect rect;
	LCUI_ARGB *pixel_src, *pixel_des;

	if(!Graph_IsValid(graph)) {
		return -1;
	}
	Graph_GetValidRect( graph, &rect );
	graph = Graph_GetQuote( graph );
	buff->opacity = graph->opacity;
	buff->color_type = graph->color_type;
	if( 0 != Graph_Create( buff, rect.width, rect.height ) ) {
		return -2;
	}

	for( y=0; y<rect.h; ++y ) {
		pixel_des = buff->argb + y*buff->w;
		pixel_src = graph->argb + (rect.y+y)*graph->w;
		pixel_src += rect.x + rect.w - 1;
		for( x=0; x<rect.w; ++x ) {
			*pixel_des++ = *pixel_src--;
		}
	}
	return 0;
}
开发者ID:WhatDream,项目名称:LCUI,代码行数:27,代码来源:graph.c

示例8: Graph_FillRectRGB

int Graph_FillRectRGB( LCUI_Graph *graph, LCUI_Color color, LCUI_Rect rect )
{
	int x, y;
	LCUI_Graph canvas;
	uchar_t *rowbytep, *bytep;

	if(!Graph_IsValid(graph)) {
		return -1;
	}
	Graph_Quote( &canvas, graph, &rect );
	Graph_GetValidRect( &canvas, &rect );
	graph = Graph_GetQuote( &canvas );
	rowbytep = graph->bytes + rect.y*graph->bytes_per_row;
	rowbytep += rect.x*graph->bytes_per_pixel;
	for( y=0; y<rect.h; ++y ) {
		bytep = rowbytep;
		for( x=0; x<rect.w; ++x ) {
			*bytep++ = color.blue;
			*bytep++ = color.green;
			*bytep++ = color.red;
		}
		rowbytep += graph->bytes_per_row;
	}
	return 0;
}
开发者ID:WhatDream,项目名称:LCUI,代码行数:25,代码来源:graph.c

示例9: Graph_HorizFlipRGB

static int Graph_HorizFlipRGB( const LCUI_Graph *graph, LCUI_Graph *buff )
{
	int x, y, n;
	LCUI_Rect rect;
	uchar_t *byte_src, *byte_des;

	if(!Graph_IsValid(graph)) {
		return -1;
	}
	Graph_GetValidRect( graph, &rect );
	graph = Graph_GetQuote( graph );
	buff->color_type = graph->color_type;
	if( 0 != Graph_Create( buff, rect.width, rect.height ) ) {
		return -2;
	}

	for( y=0; y<rect.h; ++y ) {
		byte_des = buff->bytes + y*buff->w*3;
		n = ((rect.y+y)*graph->w + rect.x + rect.w - 1)*3;
		byte_src = buff->bytes + n;
		for( x=0; x<rect.w; ++x ) {
			*byte_des++ = *byte_src--;
			*byte_des++ = *byte_src--;
			*byte_des++ = *byte_src--;
		}
	}
	return 0;
}
开发者ID:WhatDream,项目名称:LCUI,代码行数:28,代码来源:graph.c

示例10: Graph_FillAlpha

int Graph_FillAlpha( LCUI_Graph *graph, uchar_t alpha )
{
	int x, y;
	LCUI_Rect rect;
	LCUI_ARGB *pixel, *pixel_row;

	Graph_GetValidRect( graph, &rect );
	graph = Graph_GetQuote( graph );
	if( !Graph_IsValid(graph) ) {
		return -1;
	}
	if( !Graph_HasAlpha(graph) ) {
		return -2;
	}

	pixel_row = graph->argb + rect.y*graph->w + rect.x;
	for(y=0; y<rect.h; ++y) {
		pixel = pixel_row;
		for( x=0; x<rect.w; ++x ) {
			pixel->alpha = alpha;
			++pixel;
		}
		pixel_row += graph->w;
	}
	return 0;
}
开发者ID:WhatDream,项目名称:LCUI,代码行数:26,代码来源:graph.c

示例11: Graph_GetPixel

LCUI_API LCUI_BOOL Graph_GetPixel( LCUI_Graph *graph, LCUI_Pos pos, LCUI_RGBA *pixel )
{
	int i;
	LCUI_Rect rect;
	
	if( pos.x < 0 || pos.y < 0 ) {
		return FALSE;
	}
	rect = Graph_GetValidRect( graph );
	/* 若坐标超出范围 */
	if( pos.x >= rect.width || pos.y >= rect.height ) {
		return FALSE;
	}
	graph = Graph_GetQuote( graph );
	if( !Graph_IsValid(graph) ) {
		return FALSE;
	}
	i = graph->w*(pos.y+rect.y) + pos.x + rect.x;
	pixel->red = graph->rgba[0][i];
	pixel->green = graph->rgba[1][i];
	pixel->blue = graph->rgba[2][i];
	
	if(graph->color_type == COLOR_TYPE_RGBA) {
		pixel->alpha = graph->rgba[3][i];
	} else {
		pixel->alpha = 255;
	}
	return TRUE;
}
开发者ID:fshunj,项目名称:LCUI,代码行数:29,代码来源:LCUI_Graph.c

示例12: Graph_Free

LCUI_API void Graph_Free( LCUI_Graph *pic )
{
	LCUI_Graph *p;

	if( pic && pic->quote ) {
		pic->src = NULL; 
		pic->quote = FALSE;
		return;
	}
	p = Graph_GetQuote( pic );
	if( !Graph_IsValid(p)) {
		return;
	}
	LCUIMutex_Lock( &p->mutex );
	free( p->rgba[0] );
	free( p->rgba[1] );
	free( p->rgba[2] );
	if( p->color_type == COLOR_TYPE_RGBA ) {
		free( p->rgba[3] );
	}
	free( p->rgba );
	p->rgba = NULL;
	p->w = 0;
	p->h = 0;
	LCUIMutex_Unlock( &p->mutex );
	LCUIMutex_Destroy( &pic->mutex );
}
开发者ID:fshunj,项目名称:LCUI,代码行数:27,代码来源:LCUI_Graph.c

示例13: Graph_FillAlpha

LCUI_API int Graph_FillAlpha( LCUI_Graph *src, uchar_t alpha )
{
	int y, row_start;
	LCUI_Rect src_rect;
	
	/* 获取引用的区域在源图形中的有效区域 */
	src_rect = Graph_GetValidRect( src );
	/* 获取引用的源图指针 */
	src = Graph_GetQuote( src );
	
	if(! Graph_IsValid(src) ) {
		return -1;
	}
	if( !Graph_HaveAlpha(src) ) {
		return -2;
	}
	
	row_start = src_rect.x + src_rect.y * src->w;
	for(y=0; y<src_rect.height; ++y) {
		memset( &src->rgba[3][row_start], 
			alpha, src_rect.width*sizeof(uchar_t) );
		row_start += src->w;
	}
	return 0; 
}
开发者ID:fshunj,项目名称:LCUI,代码行数:25,代码来源:LCUI_Graph.c

示例14: PictureBox_ZoomViewArea

/* 缩放PictureBox部件的图片浏览区域 */
LCUI_API int
PictureBox_ZoomViewArea( LCUI_Widget *widget, double scale )
{
	LCUI_Graph buff, temp;
	LCUI_PictureBox *pic_box;
	
	pic_box = Widget_GetPrivData(widget);
	if(!Graph_IsValid(pic_box->image)) {
		return -1;
	}
	Graph_Init(&buff);
	Graph_Init(&temp);
	/* 有效范围为2%~2000% */
	if(scale < 0.02) {
		scale = 0.02;
	}
	if(scale > 20) {
		scale = 20;
	}
	if(pic_box->size_mode != SIZE_MODE_ZOOM
	 && pic_box->size_mode != SIZE_MODE_BLOCK_ZOOM) {
		pic_box->size_mode = SIZE_MODE_ZOOM; /* 改为缩放模式 */
	}
	pic_box->scale = scale; 
	Update_BuffGraph(widget); 
	Update_ReadBox(widget);
	Widget_Draw(widget);
	Widget_Refresh(widget);
	return 0;
}
开发者ID:fshunj,项目名称:LCUI,代码行数:31,代码来源:picturebox.c

示例15: Graph_VertiFlip

LCUI_API int Graph_VertiFlip( LCUI_Graph *src_graph, LCUI_Graph *out_graph )
{
	uchar_t buff;
	LCUI_Rect rect;
	int x, y, center; 
	int src_top_pos, src_bottom_pos;
	int des_top_pos, des_bottom_pos;
	int src_start_top_pos, src_start_bottom_pos;
	int des_start_top_pos, des_start_bottom_pos;

	if(!Graph_IsValid(src_graph)) {
		return -1;
	}
	src_graph = Graph_GetQuote(src_graph );
	rect = Graph_GetValidRect( src_graph );
	out_graph->color_type = src_graph->color_type;
	if( 0 != Graph_Create(out_graph, rect.width, rect.height ) ) {
		return -2;
	}

	center = (int)(rect.height / 2.0);
	/* 记录基坐标 */
	des_start_top_pos = 0;
	des_start_bottom_pos = (rect.height-1)*rect.width;
	src_start_top_pos = rect.y * src_graph->w + rect.x;
	src_start_bottom_pos = (rect.y + rect.height-1)*src_graph->w + rect.x;

	for (x=0; x < rect.width; ++x) {
		/* 当前坐标=基坐标+x */
		des_top_pos = des_start_top_pos + x;
		des_bottom_pos = des_start_bottom_pos + x;
		src_top_pos = src_start_top_pos + x;
		src_bottom_pos = src_start_bottom_pos + x;
		for (y = 0; y <= center; ++y) {
			buff = src_graph->rgba[0][src_top_pos]; 
			out_graph->rgba[0][des_top_pos] = src_graph->rgba[0][src_bottom_pos];  
			out_graph->rgba[0][des_bottom_pos] = buff;

			buff = src_graph->rgba[1][src_top_pos]; 
			out_graph->rgba[1][des_top_pos] = src_graph->rgba[1][src_bottom_pos];  
			out_graph->rgba[1][des_bottom_pos] = buff;

			buff = src_graph->rgba[2][src_top_pos]; 
			out_graph->rgba[2][des_top_pos] = src_graph->rgba[2][src_bottom_pos];  
			out_graph->rgba[2][des_bottom_pos] = buff;

			if(src_graph->color_type == COLOR_TYPE_RGBA) {
				buff = src_graph->rgba[3][src_top_pos]; 
				out_graph->rgba[3][des_top_pos] = src_graph->rgba[3][src_bottom_pos];  
				out_graph->rgba[3][des_bottom_pos] = buff;
			}
			src_top_pos += src_graph->w;
			des_top_pos += rect.width;
			src_bottom_pos -= src_graph->w;
			des_bottom_pos -= rect.width;
		}
	}
	return 0;
}
开发者ID:fshunj,项目名称:LCUI,代码行数:59,代码来源:LCUI_Graph.c


注:本文中的Graph_IsValid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。