예제 #1
0
int main(int argc, char **argv) {
	if(argc < 2) {
		usage();
		return -1;
	}
	//operate the params of cmd
	const char* inputFileName; 
    const char* outputFileName; 
    inputFileName = (argv[1]);
    outputFileName = (argv[2]);
    printf("1233556\n");
	//calculate the sin(theta) & cos(theta)
	float sinTheta = sinf(THETA);
	float cosTheta = cosf(THETA);

    //the image height and width
    int imageHeight, imageWidth;
    

    //read the bmp image to the memory
    float* inputImage = readBmpImage(inputFileName, &imageWidth, &imageHeight);

    //to check the read is succ
    printf("the width of the image is %d, the height of the image is %d\n", imageWidth, imageHeight);

    //calculate the datasize
    int dataSize = imageHeight * imageWidth * sizeof(float);

    //output image
    float *outputImage = NULL;
    outputImage = (float*)malloc(dataSize);

    //init lparm
    SNK_INIT_LPARM(lparm, (imageWidth * imageHeight));
    lparm->ndim=2; 
    lparm->gdims[0]=imageWidth;
    lparm->gdims[1]=imageHeight;
    lparm->ldims[0]=1;
    lparm->ldims[1]=1;
    
    //call the rotate function
    image_rotate(outputImage,inputImage,imageWidth,imageHeight,sinTheta,cosTheta,lparm);

    //store the image 
    storeBmpImage(outputImage, outputFileName, imageHeight, imageWidth, inputFileName);
    free(outputImage);


	return 0;
}
예제 #2
0
static PRESULT win_imageslide_unkown_act_proc(VACTION act)
{
	PRESULT ret = PROC_PASS;
	UINT8 rotate_mode, display_mode;
	POBJECT_HEAD win,mplayer_menu;
	int next_image;
	UINT16 slide_interval;
	FileInfo file_node;
	char image_name[FULL_PATH_SIZE];
	
	switch(act)
	{
	case VACT_ROTATEL:
	case VACT_ROTATER:
		if(FALSE == decode_finish_flag)
			break;
		
		if(imageslide_pause_state == IMG_UNPAUSE_STATE)
		{
			api_stop_timer(&imageslide_timer_id);
			imageslide_pause_state = IMG_PAUSE_STATE;
		}
		if(act == VACT_ROTATER)
		{
			image_rot_ang = (image_rot_ang + 1)%IMAGE_ANGLE_CNT;
		}
		else
		{
			image_rot_ang = (image_rot_ang+IMAGE_ANGLE_CNT - 1)%IMAGE_ANGLE_CNT;
		}
		
		image_rotate(image_rot_ang);
		
		if(image_rot_ang == ANG_ORI)
		{
			win_imageslide_showrotate(FALSE);
			win_imageslide_showpause();
		}
		else
		{
			OSD_ClearObject((POBJECT_HEAD)&imageslide_pause, 0);
			win_imageslide_showrotate(TRUE);
		}
		slideidx_display(TRUE);
		break;
	case VACT_INCREASE:
	case VACT_DECREASE:
		if(imageslide_pause_state == IMG_UNPAUSE_STATE)
		{
			api_stop_timer(&imageslide_timer_id);
			imageslide_pause_state = IMG_PAUSE_STATE;
			win_imageslide_showpause();
		}
		if(act == VACT_INCREASE)
		{
			next_image = get_next_index_from_play_list(cur_playlist_image);
		}
		else
		{
			next_image = get_previous_index_from_play_list(cur_playlist_image);
		}
		if(next_image != -1)
		{
			cur_image_idx = next_image;
			api_stop_timer(&imageslide_timer_id);
			image_abort();
			if(image_rot_ang!= ANG_ORI)
			{
				image_rot_ang = ANG_ORI;
				win_imageslide_showrotate(FALSE);
				win_imageslide_showpause();
			}
			osal_task_sleep(20);
			set_play_list_info(cur_playlist_image,&cur_image_idx,NULL);
			get_file_from_play_list(cur_playlist_image, cur_image_idx, &file_node);
			win_get_fullname(image_name, file_node.path, file_node.name);
			win_image_file_play(image_name, image_rot_ang);
			decode_finish_flag = FALSE;
			osal_task_sleep(20);
			slideidx_display(TRUE);
		}
		break;
	case VACT_PAUSE:
		if(imageslide_pause_state == IMG_UNPAUSE_STATE)
		{
			imageslide_pause_state = IMG_PAUSE_STATE;
			win_imageslide_showpause();
			api_stop_timer(&imageslide_timer_id);
		}
	    else
	    {
			if(image_rot_ang == ANG_ORI)
			{
				imageslide_pause_state = IMG_UNPAUSE_STATE;
				slide_interval = (image_slide_setting.uTime_gap * 1000);
				win_imageslide_showpause();
				if(0 != image_slide_setting.uTime_gap)
					imageslide_timer_id = api_start_timer("IMAGESLIDE",slide_interval,win_imageslide_handler);
			}
	    }
		ret = PROC_LOOP;
		break;
	case VACT_PLAY:
		if(IMG_PAUSE_STATE == imageslide_pause_state)
		{
			if(image_rot_ang == ANG_ORI)
			{
				imageslide_pause_state = IMG_UNPAUSE_STATE;
				win_imageslide_showpause();
				slide_interval = (image_slide_setting.uTime_gap * 1000);
				if(0 != image_slide_setting.uTime_gap)
					imageslide_timer_id = api_start_timer("IMAGESLIDE",slide_interval,win_imageslide_handler);
			}
		}
		ret = PROC_LOOP;
		break;
	case VACT_ZOOM:
		if(decode_finish_flag)
		{
			if(imageslide_pause_state == IMG_UNPAUSE_STATE)
			{
				imageslide_pause_state = IMG_PAUSE_STATE;
				win_imageslide_showpause();
				api_stop_timer(&imageslide_timer_id);
			}

			win_mpzoom_open();

			if(image_rot_ang == ANG_ORI)
			{
				imageslide_pause_state = IMG_UNPAUSE_STATE;
				slide_interval = (image_slide_setting.uTime_gap * 1000);
				win_imageslide_showpause();
				imageslide_timer_id = api_start_timer("IMAGESLIDE",slide_interval,win_imageslide_handler);
			}
		}
		break;
	case VACT_MP:
		win = (POBJECT_HEAD)(&g_win_imageslide);
		OSD_ObjClose(win,C_CLOSE_CLRBACK_FLG);

		while((POBJECT_HEAD)&g_win_usb_filelist != menu_stack_get_top())
		{
			menu_stack_pop();
		}
		
		image_abort();
		win_set_image_multiview_firstidx();
		mplayer_menu = (POBJECT_HEAD)(&g_win_imagepreview);

		if(OSD_ObjOpen(mplayer_menu,(UINT32)(~0)) != PROC_LEAVE)
			menu_stack_push(mplayer_menu);
		break;
	default:
		break;
	}

	return ret;
}
예제 #3
0
  /**
   * [working thread]
   */
  virtual void onJob()
  {
    UndoTransaction undoTransaction(m_document, "Rotate Canvas");

    // get all sprite cels
    CelList cels;
    m_sprite->getCels(cels);

    // for each cel...
    for (CelIterator it = cels.begin(); it != cels.end(); ++it) {
      Cel* cel = *it;
      Image* image = m_sprite->getStock()->getImage(cel->getImage());

      // change it location
      switch (m_angle) {
	case 180:
	  undoTransaction.setCelPosition(cel,
					 m_sprite->getWidth() - cel->getX() - image->w,
					 m_sprite->getHeight() - cel->getY() - image->h);
	  break;
	case 90:
	  undoTransaction.setCelPosition(cel, m_sprite->getHeight() - cel->getY() - image->h, cel->getX());
	  break;
	case -90:
	  undoTransaction.setCelPosition(cel, cel->getY(), m_sprite->getWidth() - cel->getX() - image->w);
	  break;
      }
    }

    // for each stock's image
    for (int i=0; i<m_sprite->getStock()->size(); ++i) {
      Image* image = m_sprite->getStock()->getImage(i);
      if (!image)
	continue;

      // rotate the image
      Image* new_image = image_new(image->imgtype,
				   m_angle == 180 ? image->w: image->h,
				   m_angle == 180 ? image->h: image->w);
      image_rotate(image, new_image, m_angle);

      undoTransaction.replaceStockImage(i, new_image);

      jobProgress((float)i / m_sprite->getStock()->size());

      // cancel all the operation?
      if (isCanceled())
	return;	       // UndoTransaction destructor will undo all operations
    }

    // rotate mask
    if (m_document->isMaskVisible()) {
      Mask* origMask = m_document->getMask();
      Mask* new_mask = mask_new();
      int x = 0, y = 0;

      switch (m_angle) {
	case 180:
	  x = m_sprite->getWidth() - origMask->x - origMask->w;
	  y = m_sprite->getHeight() - origMask->y - origMask->h;
	  break;
	case 90:
	  x = m_sprite->getHeight() - origMask->y - origMask->h;
	  y = origMask->x;
	  break;
	case -90:
	  x = origMask->y;
	  y = m_sprite->getWidth() - origMask->x - origMask->w;
	  break;
      }

      // create the new rotated mask
      mask_replace(new_mask, x, y,
		   m_angle == 180 ? origMask->w: origMask->h,
		   m_angle == 180 ? origMask->h: origMask->w);
      image_rotate(origMask->bitmap, new_mask->bitmap, m_angle);

      // copy new mask
      undoTransaction.copyToCurrentMask(new_mask);
      mask_free(new_mask);

      // regenerate mask
      m_document->generateMaskBoundaries();
    }

    // change the sprite's size
    if (m_angle != 180)
      undoTransaction.setSpriteSize(m_sprite->getHeight(), m_sprite->getWidth());

    // commit changes
    undoTransaction.commit();
  }
예제 #4
0
파일: image.c 프로젝트: psychon/lualock
static int lualock_lua_image_rotate(lua_State *L) {
    lua_settop(L, 4);
    image_t *image = luaL_checkudata(L, 1, "lualock.image");
    image_rotate(image, luaL_checknumber(L, 2), lua_tonumber(L, 3), lua_tonumber(L, 4));
    return 0;
}
예제 #5
0
static void egd_drv_output(ErlDrvData handle, char *buffer, int n) {
    egd_data* d = (egd_data*)handle;
    int command = 0;
    unsigned char error_code[4];
    
    /* Error Control  */
    /* get command */
    command = decode(&buffer); n -= 2;

    switch(command) {
    	case IM_CREATE: 
	image_create(d, buffer, n);
	break;
    	
	case IM_PIXEL:
	image_pixel(d, buffer, n);	
    	break;
	
	case IM_LINE:
	image_line(d, buffer, n);	
    	break;

	case IM_RECTANGLE:
	image_rectangle(d, buffer, n);
	break;
	
	case IM_FILLEDRECTANGLE:
	image_filled_rectangle(d, buffer, n);
	break;
	
	case IM_POLYGON:
	image_polygon(d, buffer, n);
	break;
	
	case IM_FILLEDPOLYGON:
	image_filled_polygon(d, buffer, n);
	break;
	
	case IM_COLOR:
	image_color(d, buffer, n);
	break;

	case IM_ARC:
	image_arc(d, buffer, n);
	break;

	case IM_FILLEDARC:
	image_filled_arc(d, buffer, n);
	break;

	case IM_FILLEDELLIPSE:
	image_filled_ellipse(d, buffer, n);
	break;

	case IM_TEXT:
	image_text(d, buffer, n);
	break;
	
	case IM_TEXTUP:
	image_text_up(d, buffer, n);
	break;
	
	case IM_FONT_SIZE:
	image_font_size(d, buffer, n);
	break;

	case IM_FILL:
	image_fill(d, buffer, n);
	break;

	/* Resampling och Rotate */

	case IM_RESAMPLE:
	image_resample(d, buffer, n);
	break;
	
	case IM_ROTATE:
	image_rotate(d, buffer, n);
	break;

	/* Fetching images */
	case IM_GIF:
	image_gif(d,buffer,n);
	break;

	case IM_JPEG:
	image_jpeg(d,buffer,n);
	break;

	case IM_PNG:
	image_png(d,buffer,n);
	break;
	
	default:
    	driver_output(d->port, (char *)encode((char *)error_code, 1), 4);
	break;
    }

}
예제 #6
0
static dword scene_rotateimage(void)
{
	int ret;

	ret = image_rotate(imgdata, &width, &height, oldangle,
					   (dword) config.rotate * 90);

	if (ret < 0) {
		win_msg("内存不足无法完成旋转!", COLOR_WHITE, COLOR_WHITE,
				config.msgbcolor);
		config.rotate = conf_rotate_0;
	}

	oldangle = (dword) config.rotate * 90;

	if (config.fit > 0
		&& (config.fit != conf_fit_custom || config.scale != 100)) {

		reset_image_show_ptr();

		if (config.fit == conf_fit_custom) {
			width_rotated = width * config.scale / 100;
			height_rotated = height * config.scale / 100;
		} else if (config.fit == conf_fit_width) {
			config.scale = PSP_SCREEN_WIDTH / width;

			if (config.scale > 200)
				config.scale = (config.scale / 50) * 50;
			else {
				config.scale = (config.scale / 10) * 10;
				if (config.scale < 10)
					config.scale = 10;
			}

			width_rotated = PSP_SCREEN_WIDTH;
			height_rotated = height * PSP_SCREEN_WIDTH / width;
		} else if (config.fit == conf_fit_dblwidth) {
			config.scale = 960 / width;

			if (config.scale > 200)
				config.scale = (config.scale / 50) * 50;
			else {
				config.scale = (config.scale / 10) * 10;
				if (config.scale < 10)
					config.scale = 10;
			}

			width_rotated = 960;
			height_rotated = height * 960 / width;
		} else if (config.fit == conf_fit_dblheight) {
			config.scale = imgh / height;

			if (config.scale > 200)
				config.scale = (config.scale / 50) * 50;
			else {
				config.scale = (config.scale / 10) * 10;
				if (config.scale < 10)
					config.scale = 10;
			}

			height_rotated = imgh * 2;
			width_rotated = width * imgh * 2 / height;
		} else {
			config.scale = imgh / height;

			if (config.scale > 200)
				config.scale = (config.scale / 50) * 50;
			else {
				config.scale = (config.scale / 10) * 10;
				if (config.scale < 10)
					config.scale = 10;
			}

			height_rotated = imgh;
			width_rotated = width * imgh / height;
		}

		imgshow =
			(pixel *) memalign(16,
							   sizeof(pixel) * width_rotated * height_rotated);

		if (imgshow != NULL) {
			if (config.bicubic)
				image_zoom_bicubic(imgdata, width, height,
								   imgshow, width_rotated, height_rotated);
			else
				image_zoom_bilinear(imgdata, width, height,
									imgshow, width_rotated, height_rotated);
		} else {
			imgshow = imgdata;
			width_rotated = width;
			height_rotated = height;
		}
	} else {
		config.scale = 100;
		imgshow = imgdata;
		width_rotated = width;
		height_rotated = height;
	}

	curleft = curtop = 0;
	xpos = (int) config.viewpos % 3;
	ypos = (int) config.viewpos / 3;

	if (width_rotated < PSP_SCREEN_WIDTH)
		paintleft = (PSP_SCREEN_WIDTH - width_rotated) / 2;
	else {
		paintleft = 0;
		switch (xpos) {
			case 1:
				curleft = (width_rotated - PSP_SCREEN_WIDTH) / 2;
				break;
			case 2:
				curleft = width_rotated - PSP_SCREEN_WIDTH;
				break;
		}
	}

	if (height_rotated < imgh)
		painttop = (imgh - height_rotated) / 2;
	else {
		painttop = 0;
		switch (ypos) {
			case 1:
				curtop = (height_rotated - imgh) / 2;
				break;
			case 2:
				curtop = height_rotated - imgh;
				break;
		}
	}

	if (width > height) {
		thumb_width = 128;
		thumb_height = height * 128 / width;
	} else {
		thumb_height = 128;
		thumb_width = width * 128 / height;
	}

	image_zoom_bilinear(imgdata, width, height, thumbimg, thumb_width,
						thumb_height);

	if (slideshow)
		lasttime = time(NULL);

	return 0;
}