示例#1
0
文件: gbam345.c 项目: poliva/mame-rr
static void draw_roz_bitmap_mode_scanline(running_machine &machine, gba_state *state, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp)
{
	int x = 0;
	UINT32 backdrop = ((UINT16*)state->m_gba_pram)[0] | 0x30000000;

	draw_roz_bitmap_scanline(state, line2, y, DISPCNT_BG2_EN, state->m_BG2CNT, state->m_BG2X, state->m_BG2Y, state->m_BG2PA, state->m_BG2PB, state->m_BG2PC, state->m_BG2PD, &state->m_gfxBG2X, &state->m_gfxBG2Y, state->m_gfxBG2Changed, bpp);
	draw_gba_oam(state, machine, lineOBJ, y);

	for(x = 0; x < 240; x++)
	{
		UINT32 color = backdrop;
		UINT8 top = 0x20;

		if(line2[x] < color)
		{
			color = line2[x];
			top = 0x04;
		}

		if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24))
		{
			color = lineOBJ[x];
			top = 0x10;
		}

		if(top == 0x10 && (color & 0x00010000) != 0)
		{
			UINT32 back = backdrop;
			UINT8 top2 = 0x20;

			if(line2[x] < back)
			{
				back = line2[x];
				top2 = 0x04;
			}

			if(top2 & (state->m_BLDCNT >> BLDCNT_TP2_SHIFT))
			{
				color = alpha_blend_pixel(color, back, coeff[state->m_BLDALPHA & 0x1f], coeff[(state->m_BLDALPHA >> 8) & 0x1f]);
			}
			else
			{
				switch(state->m_BLDCNT & BLDCNT_SFX)
				{
					case BLDCNT_SFX_LIGHTEN:
						if(top & state->m_BLDCNT)
						{
							color = increase_brightness(color, coeff[state->m_BLDY & 0x1f]);
						}
						break;
					case BLDCNT_SFX_DARKEN:
						if(top & state->m_BLDCNT)
						{
							color = decrease_brightness(color, coeff[state->m_BLDY & 0x1f]);
						}
						break;
				}
			}
		}
示例#2
0
int command_dispatcher(int command_id, char * args, char * result_str)
{
    int result = 0;
    int arg_param;
 
    switch(command_id)
    {
        case TS_PREVIEW_START:
            result = start_preview();
            break;

        case TS_PREVIEW_STOP:
            result = stop_preview();
            break;

	    case TS_VIDEO_START:
            result = start_video();
            break;

        case TS_VIDEO_STOP:
            result = stop_video();
            break;

        case TS_SNAPSHOT_YUV_PICTURE:
            result = take_picture(ACTION_TAKE_YUV_PICTURE);
            break;

        case TS_SNAPSHOT_JPEG_PICTURE:
            result = take_picture(ACTION_TAKE_JPEG_PICTURE);
            break;

        case TS_SNAPSHOT_RAW_PICTURE:
            result = take_raw_picture();
            break;

        case TS_SNAPSHOT_STOP:
            result = testsuite_snapshot_stop();
            break;

        case TS_SYSTEM_INIT:
            result = system_init();
            break;

        case TS_SYSTEM_DESTROY:
            result = system_destroy();
            break;

        case TS_PRINT_MAXZOOM:
            result = print_maxzoom();
            break;

        case TS_PRINT_ZOOMRATIOS:
            result = print_zoomratios();
            break;

        case TS_ZOOM_INCREASE:
            result = zoom_increase(1);
            break;

        case TS_ZOOM_DECREASE:
            result = zoom_decrease(1);
            break;

        case TS_ZOOM_STEP_INCREASE:
            result = zoom_increase(0);
            break;

        case TS_ZOOM_STEP_DECREASE:
            result = zoom_decrease(0);
            break;

        case TS_CONTRAST_INCREASE:
            result = increase_contrast();
            break;

        case TS_CONTRAST_DECREASE:
            result = decrease_contrast();
            break;

        case TS_SATURATION_INCREASE:
            result = increase_saturation();
            break;

        case TS_SATURATION_DECREASE:
            result = decrease_saturation();
            break;

        case TS_SPECIAL_EFFECT:
            result = SpecialEffect();
            break;

        case TS_BRIGHTNESS_INCREASE:
            result = increase_brightness();
            break;

        case TS_BRIGHTNESS_DECREASE:
            result = decrease_brightness();
            break;

        case TS_EV_INCREASE:
            result = increase_EV();
            break;

        case TS_EV_DECREASE:
            result = decrease_EV();
            break;

        case TS_ANTI_BANDING:
            result = set_antibanding();
            break;

        case TS_SET_WHITE_BALANCE:
            result = set_whitebalance();
            break;

        case TS_AEC_MODE:
            result = AEC_mode_change();
            break;

        case TS_ISO_INCREASE:
            result = increase_ISO();
            break;

        case TS_ISO_DECREASE:
            result = decrease_ISO();
            break;

        case TS_SHARPNESS_INCREASE:
            result = increase_sharpness();
            break;

        case TS_SHARPNESS_DECREASE:
            result = decrease_sharpness();
            break;

        case TS_SET_AUTO_FOCUS:
            result = set_auto_focus();
            break;

        case TS_SET_HJR:
            result = set_hjr();
            break;

        case TS_SET_LENS_SHADING:
            result = LensShading();
            break;

        case TS_SET_LED_MODE:
            result = LED_mode_change();
            break;

        case TS_GET_SHARPNESS_AF:
            result = set_sharpness_AF();
            break;

        case TS_SNAPSHOT_RESOLUTION:
            arg_param = atoi(args);
            result = snapshot_resolution(arg_param);
            break;

        case TS_PREVIEW_RESOLUTION:
            arg_param = atoi(args);
            result = preview_video_resolution (arg_param);
            break;

        case TS_MOTION_ISO:
            result = set_MotionIso();
            break;

        case TS_TOGGLE_HUE:
            result = toggle_hue();
            break;

        case TS_CANCEL_AUTO_FOCUS:
            result = cancel_af();
            break;

        case TS_GET_AF_STEP:
            result = get_af_step();
            break;

        case TS_SET_AF_STEP:
            result = set_af_step();
            break;

        case TS_ENABLE_AFD:
            result = enable_afd();
            break;

        case TEST_VIDIOC_G_FMT:
            result = msm_v4l2_vidioc_g_fmt();
            break;

        case TEST_VIDIOC_S_FMT:
            result = msm_v4l2_vidioc_s_fmt();
            break;

        case TEST_VIDIOC_CROPCAP:
            result = msm_v4l2_vidioc_cropcap();
            break;

        case TEST_VIDIOC_G_CROP:
            result = msm_v4l2_vidioc_g_crop();
            break;

        case TEST_VIDIOC_S_CROP:
            result = msm_v4l2_vidioc_s_crop();
            break;

        case TEST_VIDIOC_QUERYMENU:
            result = msm_v4l2_vidioc_querymenu(args);
            break;

        case TEST_VIDIOC_QUERYCTRL:
            result = msm_v4l2_vidioc_queryctrl(NULL);
            break;

        case TEST_VIDIOC_S_CTRL:
            result = msm_v4l2_vidioc_s_ctrl(args);
            break;

        case TEST_VIDIOC_G_CTRL:
            result = msm_v4l2_vidioc_g_ctrl(args);
            break;

        default:
            break;
    }
    return result;
}
示例#3
0
文件: dip_p1.c 项目: hbtsai/dip_hw1
int main(int argc, char** argv)
{
	FILE *file = NULL;
	// image data array
	unsigned char Imagedata[Size*Size] = {};

	char fname[1024]={};
	if(argv[1] != NULL && strlen(argv[1])>0)
		strcpy(fname, argv[1]);
	else
	{
		fprintf(stderr, "please specify filename of raw input image.\n");
		exit(-1);
	}

	if (!(file=fopen(fname,"rb")))
	{
		fprintf(stderr, "Cannot open file!\n");
		exit(1);
	}
	fread(Imagedata, sizeof(unsigned char), Size*Size, file);
	fclose(file);

	/* save the original image for comparision */
	write_pgm_image("dip_hw1_p1_I.pgm", Size, Size, Imagedata);

	unsigned char imageD[Size*Size]={};
	/* copy image data */
	memcpy(imageD, Imagedata, sizeof(Imagedata));

	/* decrease brightness (D) */ 
	decrease_brightness(Size, Size, imageD);
	write_pgm_image("dip_hw1_p1_D.pgm", Size, Size, imageD);

	unsigned char imageH[Size*Size]={};
	/* copy image data */
	memcpy(imageH, imageD, sizeof(imageD));

	/* histogram_equalizer (H) */
	histogram_equalizer(Size, Size, imageH);
	write_pgm_image("dip_hw1_p1_H.pgm", Size, Size, imageH);


	/* here loop create local histogram equalizer with different window size */
	/* change w_size to whatever 0< number <256 */
	/*
	int w_size=50;
	unsigned char imageL[Size*Size]={};
	char file_name[1024]={};

	for( int w_size=10; w_size<250; w_size+=10)
	{
		memset(imageL, 0, sizeof(imageL));
		for(int i=0; i<Size; i++)
		{
			for(int j=0; j<Size; j++)
			{
				// just ignore the boarder & corner
				local_histogram_equalizer(w_size, Size, Size, i, j, imageD, imageL);
			}
		}
		sprintf(file_name, "solved_c_%d.pgm", w_size);
		write_pgm_image(file_name, Size, Size, imageL);
	}
	*/

	int i=0, j=0, w_size=10;
	unsigned char imageL[Size*Size]={};
	for(i=0; i<Size; i++)
		for(j=0; j<Size; j++)
			local_histogram_equalizer(w_size, Size, Size, i, j, imageD, imageL);

	write_pgm_image("dip_hw1_p1_L_10.pgm", Size, Size, imageL);
	paint_histogram(Size, Size, imageL,    "dip_hw1_p1_histogram_L_10.pgm");

	memset(imageL, 0, Size*Size);
	for(i=0; i<Size; i++)
		for(j=0; j<Size; j++)
			local_histogram_equalizer(30, Size, Size, i, j, imageD, imageL);
	write_pgm_image("dip_hw1_p1_L_30.pgm", Size, Size, imageL);
	paint_histogram(Size, Size, imageL,    "dip_hw1_p1_histogram_L_30.pgm");

	memset(imageL, 0, Size*Size);
	for(i=0; i<Size; i++)
		for(j=0; j<Size; j++)
			local_histogram_equalizer(120, Size, Size, i, j, imageD, imageL);
	write_pgm_image("dip_hw1_p1_L_120.pgm", Size, Size, imageL);
	paint_histogram(Size, Size, imageL,    "dip_hw1_p1_histogram_L_120.pgm");

	memset(imageL, 0, Size*Size);
	for(i=0; i<Size; i++)
		for(j=0; j<Size; j++)
			local_histogram_equalizer(180, Size, Size, i, j, imageD, imageL);
	write_pgm_image("dip_hw1_p1_L_180.pgm", Size, Size, imageL);
	paint_histogram(Size, Size, imageL,    "dip_hw1_p1_histogram_L_180.pgm");


	paint_histogram(Size, Size, Imagedata, "dip_hw1_p1_histogram_I.pgm");
	paint_histogram(Size, Size, imageD,    "dip_hw1_p1_histogram_D.pgm");
	paint_histogram(Size, Size, imageH,    "dip_hw1_p1_histogram_H.pgm");

	unsigned char imageLog[Size*Size] = {};
	unsigned char imageILog[Size*Size] = {};
	unsigned char imagePlaw[Size*Size] = {};

	memcpy(imageLog, imageD, sizeof(imageD));
	memcpy(imageILog, imageD, sizeof(imageD));
	memcpy(imagePlaw, imageD, sizeof(imageD));

	/* log_c is the constant for log transform */
	const int log_c = 35;
	log_transform(log_c, Size, Size, imageLog);
	write_pgm_image("dip_hw1_p1_D_log.pgm", Size, Size, imageLog);
	paint_histogram(Size, Size, imageLog, "dip_hw1_p1_histogram_D_log.pgm");

	const int log_d = 240;
	inverse_log_transform(log_d, Size, Size, imageILog);
	write_pgm_image("dip_hw1_p1_D_ilog.pgm", Size, Size, imageILog);
	paint_histogram(Size, Size, imageILog, "dip_hw1_p1_histogram_D_ilog.pgm");

	double pow = 30;
	double gamma = 0.5;
	power_law_transform(pow, gamma, Size, Size, imagePlaw);
	write_pgm_image("dip_hw1_p1_D_pow.pgm", Size, Size, imagePlaw);
	paint_histogram(Size, Size, imagePlaw, "dip_hw1_p1_histogram_D_pow.pgm");

	pow = 1;
	gamma = 1.5;
	memcpy(imagePlaw, imageD, sizeof(imageD));
	power_law_transform(pow, gamma, Size, Size, imagePlaw);
	write_pgm_image("dip_hw1_p1_D_pow1.pgm", Size, Size, imagePlaw);
	paint_histogram(Size, Size, imagePlaw, "dip_hw1_p1_histogram_D_pow1.pgm");

	unsigned char imageOtsu[Size*Size]={};
	int thre = otsu_method(Size, Size, Imagedata);
	fprintf(stderr, " thresold = %d \n", thre);
	memcpy(imageOtsu, Imagedata, sizeof(imageOtsu));	
	convert_to_black_n_white(thre, Size, Size, imageOtsu);
	write_pgm_image("dip_hw1_p1_I_otsu.pgm", Size, Size, imageOtsu);

	memcpy(imageOtsu, Imagedata, sizeof(imageOtsu));	
	convert_to_black_n_white(64, Size, Size, imageOtsu);
	write_pgm_image("dip_hw1_p1_I_64.pgm", Size, Size, imageOtsu);

	memcpy(imageOtsu, Imagedata, sizeof(imageOtsu));	
	convert_to_black_n_white(128, Size, Size, imageOtsu);
	write_pgm_image("dip_hw1_p1_I_128.pgm", Size, Size, imageOtsu);

	memcpy(imageOtsu, Imagedata, sizeof(imageOtsu));	
	convert_to_black_n_white(192, Size, Size, imageOtsu);
	write_pgm_image("dip_hw1_p1_I_192.pgm", Size, Size, imageOtsu);

	exit(0);
	return 0;
}