• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ RB_ReadPixels函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: RB_TakeScreenshot

/* 
================== 
RB_TakeScreenshot
================== 
*/  
void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName)
{
	byte *allbuf, *buffer;
	byte *srcptr, *destptr;
	byte *endline, *endmem;
	byte temp;
	
	int linelen, padlen;
	size_t offset = 18, memcount;
		
	allbuf = RB_ReadPixels(x, y, width, height, &offset, &padlen);
	buffer = allbuf + offset - 18;
	
	Com_Memset (buffer, 0, 18);
	buffer[2] = 2;		// uncompressed type
	buffer[12] = width & 255;
	buffer[13] = width >> 8;
	buffer[14] = height & 255;
	buffer[15] = height >> 8;
	buffer[16] = 24;	// pixel size

	// swap rgb to bgr and remove padding from line endings
	linelen = width * 3;
	
	srcptr = destptr = allbuf + offset;
	endmem = srcptr + (linelen + padlen) * height;
	
	while(srcptr < endmem)
	{
		endline = srcptr + linelen;

		while(srcptr < endline)
		{
			temp = srcptr[0];
			*destptr++ = srcptr[2];
			*destptr++ = srcptr[1];
			*destptr++ = temp;
			
			srcptr += 3;
		}
		
		// Skip the pad
		srcptr += padlen;
	}

	memcount = linelen * height;

	// gamma correct
	if(glConfig.deviceSupportsGamma
//openarena: altbright
		&& !r_alternateBrightness->integer
//-openarena
	) {
		R_GammaCorrect(allbuf + offset, memcount);
}

	ri.FS_WriteFile(fileName, buffer, memcount + 18);

	ri.Hunk_FreeTempMemory(allbuf);
}
开发者ID:themuffinator,项目名称:fnq3,代码行数:65,代码来源:tr_init.c


示例2: R_LevelShot

/*
 * R_LevelShot
 *
 * levelshots are specialized 128*128 thumbnails for
 * the menu system, sampled down from full screen distorted images
 */
void
R_LevelShot(void)
{
	char checkname[MAX_OSPATH];
	byte	*buffer;
	byte	*source, *allsource;
	byte	*src, *dst;
	size_t	offset = 0;
	int	padlen;
	int	x, y;
	int	r, g, b;
	float	xScale, yScale;
	int	xx, yy;

	Q_sprintf(checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName);

	allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen);
	source = allsource + offset;

	buffer = ri.hunkalloctemp(128 * 128*3 + 18);
	Q_Memset (buffer, 0, 18);
	buffer[2]	= 2;	/* uncompressed type */
	buffer[12]	= 128;
	buffer[14]	= 128;
	buffer[16]	= 24;	/* pixel size */

	/* resample from source */
	xScale	= glConfig.vidWidth / 512.0f;
	yScale	= glConfig.vidHeight / 384.0f;
	for(y = 0; y < 128; y++)
		for(x = 0; x < 128; x++){
			r = g = b = 0;
			for(yy = 0; yy < 3; yy++)
				for(xx = 0; xx < 4; xx++){
					src = source +
					      (3 * glConfig.vidWidth + padlen) * (int)((y*3 + yy) * yScale) +
					      3 * (int)((x*4 + xx) * xScale);
					r	+= src[0];
					g	+= src[1];
					b	+= src[2];
				}
			dst = buffer + 18 + 3 * (y * 128 + x);
			dst[0]	= b / 12;
			dst[1]	= g / 12;
			dst[2]	= r / 12;
		}

	/* gamma correct */
	if(glConfig.deviceSupportsGamma){
		R_GammaCorrect(buffer + 18, 128 * 128 * 3);
	}

	ri.fswritefile(checkname, buffer, 128 * 128*3 + 18);

	ri.hunkfreetemp(buffer);
	ri.hunkfreetemp(allsource);

	ri.Printf(PRINT_ALL, "Wrote %s\n", checkname);
}
开发者ID:icanhas,项目名称:yantar,代码行数:65,代码来源:init.c


示例3: R_LevelShot

static void R_LevelShot( void ) {
	char		checkname[MAX_OSPATH];
	byte		*buffer;
	byte		*source, *allsource;
	byte		*src, *dst;
	size_t		offset = 0;
	int			padlen;
	int			x, y;
	int			r, g, b;
	float		xScale, yScale;
	int			xx, yy;

	Com_sprintf( checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName );

	allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen);
	source = allsource + offset;

	buffer = (byte *)Hunk_AllocateTempMemory(LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18);
	Com_Memset (buffer, 0, 18);
	buffer[2] = 2;		// uncompressed type
	buffer[12] = LEVELSHOTSIZE & 255;
	buffer[13] = LEVELSHOTSIZE >> 8;
	buffer[14] = LEVELSHOTSIZE & 255;
	buffer[15] = LEVELSHOTSIZE >> 8;
	buffer[16] = 24;	// pixel size

	// resample from source
	xScale = glConfig.vidWidth / (4.0*LEVELSHOTSIZE);
	yScale = glConfig.vidHeight / (3.0*LEVELSHOTSIZE);
	for ( y = 0 ; y < LEVELSHOTSIZE ; y++ ) {
		for ( x = 0 ; x < LEVELSHOTSIZE ; x++ ) {
			r = g = b = 0;
			for ( yy = 0 ; yy < 3 ; yy++ ) {
				for ( xx = 0 ; xx < 4 ; xx++ ) {
					src = source + 3 * ( glConfig.vidWidth * (int)( (y*3+yy)*yScale ) + (int)( (x*4+xx)*xScale ) );
					r += src[0];
					g += src[1];
					b += src[2];
				}
			}
			dst = buffer + 18 + 3 * ( y * LEVELSHOTSIZE + x );
			dst[0] = b / 12;
			dst[1] = g / 12;
			dst[2] = r / 12;
		}
	}

	// gamma correct
	if ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {
		R_GammaCorrect( buffer + 18, LEVELSHOTSIZE * LEVELSHOTSIZE * 3 );
	}

	FS_WriteFile( checkname, buffer, LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18 );

	Hunk_FreeTempMemory( buffer );
	Hunk_FreeTempMemory( allsource );

	Com_Printf ("Wrote %s\n", checkname );
}
开发者ID:Nuk3R4z0r,项目名称:OpenJK,代码行数:59,代码来源:tr_init.cpp


示例4: RB_TakeScreenshot

/*
 * RB_TakeScreenshot
 */
void
RB_TakeScreenshot(int x, int y, int width, int height, char *fileName)
{
	byte	*allbuf, *buffer;
	byte	*srcptr, *destptr;
	byte	*endline, *endmem;
	byte	temp;

	int	linelen, padlen;
	size_t offset = 18, memcount;

	allbuf	= RB_ReadPixels(x, y, width, height, &offset, &padlen);
	buffer	= allbuf + offset - 18;

	Q_Memset (buffer, 0, 18);
	buffer[2]	= 2;	/* uncompressed type */
	buffer[12]	= width & 255;
	buffer[13]	= width >> 8;
	buffer[14]	= height & 255;
	buffer[15]	= height >> 8;
	buffer[16]	= 24;	/* pixel size */

	/* swap rgb to bgr and remove padding from line endings */
	linelen = width * 3;

	srcptr	= destptr = allbuf + offset;
	endmem	= srcptr + (linelen + padlen) * height;

	while(srcptr < endmem){
		endline = srcptr + linelen;

		while(srcptr < endline){
			temp = srcptr[0];
			*destptr++	= srcptr[2];
			*destptr++	= srcptr[1];
			*destptr++	= temp;

			srcptr += 3;
		}

		/* Skip the pad */
		srcptr += padlen;
	}

	memcount = linelen * height;

	/* gamma correct */
	if(glConfig.deviceSupportsGamma)
		R_GammaCorrect(allbuf + offset, memcount);

	ri.fswritefile(fileName, buffer, memcount + 18);

	ri.hunkfreetemp(allbuf);
}
开发者ID:icanhas,项目名称:yantar,代码行数:57,代码来源:init.c


示例5: R_TakeScreenshotPNG

/*
==================
R_TakeScreenshotPNG
==================
*/
static void R_TakeScreenshotPNG( int x, int y, int width, int height, char *fileName )
{
	byte *buffer = RB_ReadPixels( x, y, width, height, 0 );

	if ( tr.overbrightBits > 0 && glConfig.deviceSupportsGamma )
	{
		R_GammaCorrect( buffer, 3 * width * height );
	}

	SavePNG( fileName, buffer, width, height, 3, qfalse );
	ri.Hunk_FreeTempMemory( buffer );
}
开发者ID:ZdrytchX,项目名称:Unvanquished-KoRx,代码行数:17,代码来源:tr_init.c


示例6: R_TakeScreenshotJPEG

/*
==================
R_TakeScreenshot
==================
*/
void R_TakeScreenshotJPEG( int x, int y, int width, int height, char *fileName ) {
	byte *buffer;
	size_t offset = 0, memcount;
	int padlen;

	buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen);
	memcount = (width * 3 + padlen) * height;

	// gamma correct
	if(glConfig.deviceSupportsGamma)
		R_GammaCorrect(buffer + offset, memcount);

	RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen);
	Hunk_FreeTempMemory(buffer);
}
开发者ID:Nuk3R4z0r,项目名称:OpenJK,代码行数:20,代码来源:tr_init.cpp


示例7: R_TakeScreenshotJPEG

void R_TakeScreenshotJPEG(int x, int y, int width, int height, char *fileName) {
	byte *buffer;
	size_t offset = 0, memcount;
	int padlen;

	buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen);
	memcount = (width * 3 + padlen) * height;

	// gamma correct
	if (r_gammamethod->integer == GAMMA_HARDWARE)
		R_GammaCorrect(buffer + offset, (int)memcount);

	SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen);
	ri.Hunk_FreeTempMemory(buffer);
}
开发者ID:entdark,项目名称:jk2mv,代码行数:15,代码来源:tr_init.cpp


示例8: RB_TakeScreenshotPNG

/*
==================
RB_TakeScreenshotPNG
==================
*/
static void RB_TakeScreenshotPNG(int x, int y, int width, int height, char *fileName)
{
	byte *buffer;
	size_t offset = 0, memcount;
	int padlen;

	buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen);
	memcount = (width * 3 + padlen) * height;

	// gamma correct
	if(glConfig.deviceSupportsGamma)
		R_GammaCorrect(buffer + offset, memcount);

	RE_SavePNG(fileName, width, height, buffer+offset, 3, padlen, qfalse);
	ri.Hunk_FreeTempMemory(buffer);
}
开发者ID:Lrns123,项目名称:jkaq3,代码行数:21,代码来源:tr_init.c


示例9: R_TakeScreenshot

/*
==================
R_TakeScreenshot
==================
*/
static void R_TakeScreenshot( int x, int y, int width, int height, char *fileName )
{
	byte *buffer;
	int  dataSize;
	byte *end, *p;

	// with 18 bytes for the TGA file header
	buffer = RB_ReadPixels( x, y, width, height, 18 );
	Com_Memset( buffer, 0, 18 );

	buffer[ 2 ] = 2; // uncompressed type
	buffer[ 12 ] = width & 255;
	buffer[ 13 ] = width >> 8;
	buffer[ 14 ] = height & 255;
	buffer[ 15 ] = height >> 8;
	buffer[ 16 ] = 24; // pixel size

	dataSize = 3 * width * height;

	// RGB to BGR
	end = buffer + 18 + dataSize;

	for ( p = buffer + 18; p < end; p += 3 )
	{
		byte temp = p[ 0 ];
		p[ 0 ] = p[ 2 ];
		p[ 2 ] = temp;
	}

	if ( tr.overbrightBits > 0 && glConfig.deviceSupportsGamma )
	{
		R_GammaCorrect( buffer + 18, dataSize );
	}

	ri.FS_WriteFile( fileName, buffer, 18 + dataSize );

	ri.Hunk_FreeTempMemory( buffer );
}
开发者ID:ZdrytchX,项目名称:Unvanquished-KoRx,代码行数:43,代码来源:tr_init.c


示例10: R_LevelShot

/*
====================
R_LevelShot

levelshots are specialized 128*128 thumbnails for
the menu system, sampled down from full screen distorted images
====================
*/
void R_LevelShot(void)
{
	char   checkname[MAX_OSPATH];
	byte   *buffer;
	byte   *source, *allsource;
	byte   *src, *dst;
	size_t offset = 0;
	int    padlen;
	int    x, y;
	int    r, g, b;
	float  xScale, yScale;
	int    xx, yy;

	Com_sprintf(checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName);

	allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen);
	source    = allsource + offset;

	buffer = ri.Hunk_AllocateTempMemory(128 * 128 * 3 + 18);
	Com_Memset(buffer, 0, 18);
	buffer[2]  = 2;         // uncompressed type
	buffer[12] = 128;
	buffer[14] = 128;
	buffer[16] = 24;        // pixel size

	// resample from source
	xScale = glConfig.vidWidth / 512.0f;
	yScale = glConfig.vidHeight / 384.0f;
	for (y = 0 ; y < 128 ; y++)
	{
		for (x = 0 ; x < 128 ; x++)
		{
			r = g = b = 0;
			for (yy = 0 ; yy < 3 ; yy++)
			{
				for (xx = 0 ; xx < 4 ; xx++)
				{
					src = source + (3 * glConfig.vidWidth + padlen) * ( int ) ((y * 3 + yy) * yScale) +
					      3 * ( int ) ((x * 4 + xx) * xScale);
					r += src[0];
					g += src[1];
					b += src[2];
				}
			}
			dst    = buffer + 18 + 3 * (y * 128 + x);
			dst[0] = b / 12;
			dst[1] = g / 12;
			dst[2] = r / 12;
		}
	}

	// gamma correct
	if (glConfig.deviceSupportsGamma)
	{
		R_GammaCorrect(buffer + 18, 128 * 128 * 3);
	}

	ri.FS_WriteFile(checkname, buffer, 128 * 128 * 3 + 18);

	ri.Hunk_FreeTempMemory(buffer);
	ri.Hunk_FreeTempMemory(allsource);

	Ren_Print("Wrote %s\n", checkname);
}
开发者ID:winrid,项目名称:etlegacy,代码行数:72,代码来源:tr_init.c


示例11: R_LevelShot

/*
====================
R_LevelShot

levelshots are specialized 128*128 thumbnails for
the menu system, sampled down from full screen distorted images
====================
*/
void R_LevelShot( screenshotType_e type, const char *ext ) {
	char		fileName[MAX_OSPATH];
	byte		*source;
	byte		*resample, *resamplestart;
	size_t		offset = 0, memcount;
	int			spadlen, rpadlen;
	int			padwidth, linelen;
	GLint		packAlign;
	byte		*src, *dst;
	int			x, y;
	int			r, g, b;
	float		xScale, yScale;
	int			xx, yy;
	int			width, height;
	int			arg;

	// Allow custom resample width/height
	arg = atoi(ri.Cmd_Argv(2));
	if (arg > 0)
		width = height = arg;
	else
		width = height = 128;

	if (width > glConfig.vidWidth)
		width = glConfig.vidWidth;
	if (height > glConfig.vidHeight)
		height = glConfig.vidHeight;

	Com_sprintf(fileName, sizeof(fileName), "levelshots/%s_small%s", tr.world->baseName, ext);

	source = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &spadlen);

	//
	// Based on RB_ReadPixels
	qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign);

	linelen = width * 3;
	padwidth = PAD(linelen, packAlign);

	// Allocate a few more bytes so that we can choose an alignment we like
	resample = ri.Hunk_AllocateTempMemory(padwidth * height + offset + packAlign - 1);

	resamplestart = PADP((intptr_t) resample + offset, packAlign);

	offset = resamplestart - resample;
	rpadlen = padwidth - linelen;
	//

	// resample from source
	xScale = glConfig.vidWidth / (float)(width * 4.0f);
	yScale = glConfig.vidHeight / (float)(height * 3.0f);
	for ( y = 0 ; y < height ; y++ ) {
		for ( x = 0 ; x < width ; x++ ) {
			r = g = b = 0;
			for ( yy = 0 ; yy < 3 ; yy++ ) {
				for ( xx = 0 ; xx < 4 ; xx++ ) {
					src = source + (3 * glConfig.vidWidth + spadlen) * (int)((y*3 + yy) * yScale) +
						3 * (int) ((x*4 + xx) * xScale);
					r += src[0];
					g += src[1];
					b += src[2];
				}
			}
			dst = resample + 3 * ( y * width + x );
			dst[0] = r / 12;
			dst[1] = g / 12;
			dst[2] = b / 12;
		}
	}

	memcount = (width * 3 + rpadlen) * height;

	// gamma correct
	if(glConfig.deviceSupportsGamma)
		R_GammaCorrect(resample + offset, memcount);

	if ( type == ST_TGA )
		RE_SaveTGA(fileName, width, height, resample + offset, rpadlen);
	else if ( type == ST_JPEG )
		RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, resample + offset, rpadlen);
	else if ( type == ST_PNG )
		RE_SavePNG(fileName, width, height, resample + offset, rpadlen);

	ri.Hunk_FreeTempMemory(resample);
	ri.Hunk_FreeTempMemory(source);

	ri.Printf( PRINT_ALL, "Wrote %s\n", fileName );
}
开发者ID:mecwerks,项目名称:spearmint,代码行数:96,代码来源:tr_init.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ RB_SOURCE_GET_CLASS函数代码示例发布时间:2022-05-30
下一篇:
C++ RB_REMOVE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap