Esempio n. 1
0
void
ImageViewer::SaveImage(void)
{
	if(savedPath.GetLength() != 0)
		return;						/*Already saved*/

	result res = E_SUCCESS;
	Image img;
	String fileName;
	int lastFileName = 0;
	String fileNameKey("AppLastSavedFileNum");
	AppRegistry *pAppRegistry = Application::GetInstance()->GetAppRegistry();

	res = pAppRegistry->Get(fileNameKey, lastFileName);
	if ( res == E_KEY_NOT_FOUND)
	{
		lastFileName = 1;
		pAppRegistry->Add(fileNameKey, lastFileName);
	}

	savedPath = L"/Media/Images/";
	savedPath += Application::GetInstance()->GetAppName();
	savedPath.Append(lastFileName);
	savedPath += ".jpg";

	img.Construct();
	res = img.EncodeToFile(*__pDisplayImage, IMG_FORMAT_JPG, savedPath, true);

	pAppRegistry->Set(fileNameKey, lastFileName + 1);

}
Esempio n. 2
0
void
CropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
{
	if(actionId == ID_FOOTERITEMCROP)
	{

		__Croprectangle.x = __x_min ;
		__Croprectangle.y = __y_min ;
		__Croprectangle.width = __x_max - __x_min;
		__Croprectangle.height = __y_max - __y_min;

		if ((__Croprectangle.width <= 0) || (__Croprectangle.height <= 0))
		{
			MessageBox messageBox;
			messageBox.Construct(L"Noting to crop", L"Please select region using finger to crop.", MSGBOX_STYLE_OK, 3000);
			int modalResult = 0;
			messageBox.ShowAndWait(modalResult);
			return;
		}

		Bitmap *pBitmapCroped = new Bitmap();
		pBitmapCroped->Construct(*__pBitmapOriginal,__Croprectangle);
		Image img;
		result r = img.Construct();

		if(!IsFailed(r))
		{
			img.EncodeToFile(*pBitmapCroped, IMG_FORMAT_JPG, USER_CROPPED_FILE_PATH, true);

			AppLogDebug("Save_location : %S", USER_CROPPED_FILE_PATH.GetPointer());

			Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
			Form *pForm = (Form*)pFrame->GetControl(MAIN_FORM_NAME, false);
			if(pForm)
			{
				pFrame->SetCurrentForm(*pForm);
				pForm->SendUserEvent(CROPPING_COMPLETE, null);
				pForm->Draw();
				pForm->Show();
				pFrame->RemoveControl(*this);
			}
		}

		delete pBitmapCroped;
	}
}