示例#1
0
// Convert
int PuzzleTV::draw(YUV* src_yuv, RGB32* dst_rgb, char* dst_msg)
{
	LOGI("%s(L=%d)", __func__, __LINE__);
	RGB32* src_rgb = mUtils->yuv_YUVtoRGB(src_yuv);

	memset(dst_rgb, 0, video_area * PIXEL_SIZE);

	if (autoSolveTimer == 0) {
		autoSolve();
	} else {
		autoSolveTimer--;
	}

	for (int i=0; i<blockNum; i++) {
		if (i == movingBlock || i == spaceBlock) {
			RGB32* q = dst_rgb + blocks[i].destOffset;
			for (int y=0; y<blockSizeH; y++) {
				memset(q, 0, blockSizeW * PIXEL_SIZE);
				q += video_width;
			}
		} else {
			copyBlockImage(src_rgb + blocks[i].srcOffset, dst_rgb + blocks[i].destOffset);
		}
		if (hint) {
			copyHintImage(src_rgb, dst_rgb, blocks[i].destOffset);
		}
	}

	if (movingBlock >= 0) {
		moveBlock(src_rgb, dst_rgb);
	}

	return 0;
}
示例#2
0
文件: puzzle.c 项目: Elive/effectv
static int draw(RGB32 *src, RGB32 *dest)
{
	int  y, i;
	RGB32 *p, *q;

	if(autoSolveTimer == 0) {
		autoSolve();
	} else {
		autoSolveTimer--;
	}

	for(i=0; i<blockNum; i++) {
		if(i == movingBlock || i == spaceBlock) {
			q = dest + blocks[i].destOffset;
			for(y=0; y<blockSize; y++) {
				memset(q, 0, blockSize * PIXEL_SIZE);
				q += video_width;
			}
		} else {
			copyBlockImage( src + blocks[i].srcOffset,
						   dest + blocks[i].destOffset);
		}
	}

	if(movingBlock >= 0) {
		moveBlock(src, dest);
	}

	if(marginW) {
		p =  src + blockW * blockSize;
		q = dest + blockW * blockSize;
		for(y=0; y<blockH * blockSize; y++) {
			memcpy(q, p, marginW * PIXEL_SIZE);
			p += video_width;
			q += video_width;
		}
	}
	if(marginH) {
		p =  src + (blockH * blockSize) * video_width;
		q = dest + (blockH * blockSize) * video_width;
		memcpy(q, p, marginH * video_width * PIXEL_SIZE);
	}

	return 0;
}
示例#3
0
文件: puzzle.c 项目: Elive/effectv
static void moveBlock(RGB32 *src, RGB32 *dest)
{
	int sx, sy;
	int dx, dy;
	int x, y;

	sx = movingBlock % blockW;
	sy = movingBlock / blockW;
	dx = spaceBlock % blockW;
	dy = spaceBlock / blockW;

	sx *= blockSize;
	sy *= blockSize;
	dx *= blockSize;
	dy *= blockSize;

	x = dx + (sx - dx) * phase / SLIDING_INTERVAL;
	y = dy + (sy - dy) * phase / SLIDING_INTERVAL;

	copyBlockImage(src + blocks[movingBlock].srcOffset,
			dest + y * video_width + x);

	if(autoSolveTimer == 0) {
		phase--;
	} else {
		phase-=2;
	}
	if(phase < 0) {
		int tmp;
		/* Exchanges positions of the moving block and the space */
		tmp = blocks[movingBlock].position;
		blocks[movingBlock].position = blocks[spaceBlock].position;
		blocks[spaceBlock].position = tmp;

		blockSetSrcOffset(movingBlock);
		blockSetSrcOffset(spaceBlock);

		spaceBlock = movingBlock;
		movingBlock = -1;
	}
}