当前位置: 首页>>代码示例>>C++>>正文


C++ TBitmap类代码示例

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


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

示例1: CheckValid

//
/// Create a bitmap & get its handle, given an other bitmap
/// Used by ctors here and in derived classes. Assumes Handle can be
/// written over, & adds handle to reference container.
//
void
TBitmap::Create(const TBitmap& src)
{
  TMemoryDC memDC1;
  TMemoryDC memDC2;

  BITMAP  bm;
  src.GetObject(bm);
  if (bm.bmPlanes != 1 || bm.bmBitsPixel != 1) {
    // create a color bitmap (Assume screen compatible)
    TScreenDC dc;
    Handle = ::CreateCompatibleBitmap(dc, bm.bmWidth, bm.bmHeight);
  }
  else
    // create a mono bitmap
    Handle = ::CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, 0);

  CheckValid();
  RefAdd(Handle, Bitmap);

  memDC1.SelectObject(src);
  memDC2.SelectObject(*this);
  memDC2.BitBlt(TRect(TPoint(0, 0), TSize(bm.bmWidth, bm.bmHeight)),
                memDC1, TPoint(0, 0), SRCCOPY);
}
开发者ID:Darkman-M59,项目名称:Meridian59_115,代码行数:30,代码来源:bitmap.cpp

示例2: denoiseNLMeans

template<typename I, typename O> int denoiseNLMeans(std::string inputfile, EBitmapType inputtype, std::string outputfile, EBitmapType outputtype, int r = 3, int f = 1, Float k = 0.7, Float sigma = 0.1, bool dump = true) {
	NLMeansDenoiser<I, O> *denoiser = new NLMeansDenoiser<I, O>(sigma, dump);
	TBitmap<I> *input = new TBitmap<I>();
	if (!input->loadBitmap(inputfile, inputtype)){
		std::cout << "Input bitmap " << inputfile << " failed to load!\n";
		std::cin.get();
		return 0;
	}
	DenoiserInput<I> *dInput = new DenoiserInput<I>(outputfile);
	dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), input->getSize(), 1, false, input));
	DenoiserOutput<O> *dOutput = denoiser->denoise(dInput);
	LOG(EInfo, "Denoising finished. Time taken = %d seconds", dOutput->getDenoiseDuration());
	dumpMap(dOutput->getDenoisedImage()->getBitmap(), outputfile, outputtype);
	input->unloadBitmap();
	std::cin.get();
	_CrtDumpMemoryLeaks(); // prints mem leaks
	return 0;
}
开发者ID:mssurajkaiga,项目名称:nlmeans,代码行数:18,代码来源:nlmeans.cpp

示例3: CelSize

//
/// Add new cel(s) to the CelArray - return index of new addition.
/// No mask bitmap is added.
//
int
TCelArray::Add(const TBitmap& image)
{
  int width = image.Width();
  int count = width / CelSize().cx;

  if (!MaybeResize(count))
    return -1;

  OwlCopyBmp(*Bitmap, image, CelOffset(NCelsUsed,0), image.Size());

  int index = NCelsUsed;
  NCelsUsed += count;

  TRACEX(OwlGadget, 1, "TCelArray @" << (void*)this << " added bitmap @" <<
    (void*)&image);

  return index;
}
开发者ID:Meridian59,项目名称:Meridian59,代码行数:23,代码来源:celarray.cpp

示例4: TSize

//
/// Constructs a TImageList from a bitmap, slicing it up into a horizontal array of
/// the given number of evenly sized images.
// !CQ add an optional mask color? or mask?
//
TImageList::TImageList(const TBitmap& bmp, uint flags, int imageCount, int growBy)
{
  if (!TCommCtrl::IsAvailable())
    TXCommCtrl::Raise();

  if (!imageCount)
    imageCount = 1;

  ImageSize = TSize(bmp.Width() / imageCount, bmp.Height());
  Bitmap = 0;

  Handle = TCommCtrl::Dll()->ImageList_Create(ImageSize.cx, ImageSize.cy,
                                       flags, imageCount, growBy);

  CheckValid();
  WARNX(OwlCommCtrl, !Handle, 0, "Cannot create ImageList");

  // Use masked support with 3dFace color as background color
  //
  Add(bmp, TColor::Sys3dFace); // !CQ
}
开发者ID:Meridian59,项目名称:Meridian59,代码行数:26,代码来源:imagelst.cpp

示例5: DebugOutput

//---------------------------------------------------------------------------
void __fastcall TFormMain::ApplicationEventsMessage(tagMSG &Msg, bool &Handled)
{
	try {
		if (Msg.message == WM_HOTKEY && Msg.wParam == IDHOTKEY) {
			DebugOutput("ReghotKey press");
			TBitmap *screenshot = new TBitmap;
			this->WinGrab(screenshot);
			if (this->Ftp->Connected() == false)
				this->Ftp->Connect();
			if (this->Ftp->Connected() == false)
				throw new Exception("Ftp not connected");

			TMemoryStream *mem = new TMemoryStream;
			screenshot->SaveToStream(mem);
			this->Ftp->Put(mem, this->EditPwd->Text+"/"+Now().DateString()+"_"+
										Now().TimeString()+".jpg", false, 0);
            ShowMessage("”спех.");
		}
	} catch (Exception *e) {
		DebugOutput(e->Message);
		ShowMessage("Error.");
	}
}
开发者ID:alex-rassanov,项目名称:screenshoot,代码行数:24,代码来源:Unit1.cpp

示例6: denoiseMLTNLMeans

template<typename I, typename O> int denoiseMLTNLMeans(std::string inputfile, EBitmapType inputtype, std::string outputfile, EBitmapType outputtype, int r = 3, int f = 1, Float k = 0.7, Float sigma = 0.1, int numinstances = 1, bool dump = true) {
	MLTNLMeansDenoiser<I, O> *denoiser = new MLTNLMeansDenoiser<I, O>(r, f, k, sigma, numinstances, dump);

	DenoiserInput<I> *dInput = new DenoiserInput<I>(outputfile);
	// load bitmaps into DenoiserInput
	for (int i = 1; i <= numinstances; ++i) {
		TBitmap<I> *inputBitmap = new TBitmap<I> ;
		std::string stri = std::to_string(i);
		Assert(inputBitmap->loadBitmap(inputfile + "_" + stri, inputtype), "Input bitmap no."+ stri +" failed to load!");
		dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), inputBitmap->getSize(), 1, false, inputBitmap));
	}

	DenoiserOutput<O> *dOutput = denoiser->denoise(dInput);
	LOG(EInfo, "Denoising finished. Time taken = %d seconds", dOutput->getDenoiseDuration());
	dumpMap(dOutput->getDenoisedImage()->getBitmap(), outputfile, outputtype);

	for (int i = 0; i < numinstances; ++i) {
		dInput->getImageBlocks()[i]->getBitmap()->unloadBitmap();
	}
	std::cin.get();
	_CrtDumpMemoryLeaks(); // prints mem leaks
	return 0;
}
开发者ID:mssurajkaiga,项目名称:nlmeans,代码行数:23,代码来源:nlmeans.cpp

示例7: GetColor

void PresetButtonControl::OnPaint(DibBitmap *pbm)
{
	bool fSet = (m_wf & kfCtlSet) != 0;

	Rect rcForm;
	m_pfrm->GetRect(&rcForm);

	bool fSelected = m_pfrm->IsControlInside(this);
	Rect rcT = m_rc;
	rcT.Offset(rcForm.left, rcForm.top);

	if (fSelected) {
		pbm->Fill(rcT.left + 1, rcT.top + 1, rcT.Width() - 2, rcT.Height() - 2, GetColor(kiclrButtonFillHighlight));
	}

	TBitmap *ptbm;
	if (fSet)
		ptbm = m_ptbmDown;
	else
		ptbm = m_ptbmUp;

	if (ptbm != NULL)
		ptbm->BltTo(pbm, m_rc.left + rcForm.left + 1, m_rc.top + rcForm.top + 1);
}
开发者ID:spiffcode,项目名称:hostile-takeover,代码行数:24,代码来源:misccontrols.cpp

示例8: OnPaint

void CheckBoxControl::OnPaint(DibBitmap *pbm)
{
	Rect rcForm;
	m_pfrm->GetRect(&rcForm);

	// Draw up / down image (if present)

	TBitmap *ptbm;
	bool fPenDownInside = m_pfrm->IsControlInside(this);
	if (fPenDownInside) {
		ptbm = m_fChecked ? s_ptbmOnDown : s_ptbmOffDown;
	} else {
		ptbm = m_fChecked ? s_ptbmOnUp : s_ptbmOffUp;
	}

	// Center the text horizontally and draw to the right of the checkbox

	Font *pfnt = gapfnt[m_ifnt];
	int cy = pfnt->GetHeight();
	Size siz;
	ptbm->GetSize(&siz);
	ptbm->BltTo(pbm, m_rc.left + rcForm.left, m_rc.top + (cy - siz.cy) / 2 + rcForm.top - 1);
	gapfnt[m_ifnt]->DrawText(pbm, m_szLabel, m_rc.left + rcForm.left + siz.cx, m_rc.top + rcForm.top);
}
开发者ID:spiffcode,项目名称:hostile-takeover,代码行数:24,代码来源:misccontrols.cpp

示例9: LoadImgByUrl

/**
 * 从profile中读取大头像, 如果本地没有则进行下载
 *
 * \param pApp
 * \param ResponseInfoPhoto
 *
 * \return 
 */
Boolean TPhotosGetAlbumsForm::_UpdateProfilePhoto(TApplication* pApp, tResponseUsersGetInfo* ResponseInfoPhoto)
{

	if(ResponseInfoPhoto == NULL)
		return FALSE;
	
	if(ResponseInfoPhoto->nArraySize > 0)
	{
		TBitmap* pDownLoadBitmap = NULL;
		pDownLoadBitmap = LoadImgByUrl(ResponseInfoPhoto->Array[0].headurl);						
		if(pDownLoadBitmap == NULL)
		{
			RenRenAPICommon_DownloadPhoto(ResponseInfoPhoto->Array[0].headurl, this->GetWindowHwndId(), FEED_PROFILE_IMAGE_INDEX);	
		}
		else
		{
			TMaskButton* pLogo = NULL;
			pLogo = static_cast<TMaskButton*>(GetControlPtr(m_ProfileImageID));
			if(pLogo)
			{
				TRectangle rc;
				TBitmap * pProfileImageTmp = NULL;	//Profile的头像

				pLogo->GetBounds(&rc);
				
				pProfileImageTmp = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth());
				pProfileImageTmp->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255));
				pLogo->SetCaption(TUSTR_Re_NULL,0,0);
				pLogo->SetImage(pProfileImageTmp, (rc.Width()-pProfileImageTmp->GetWidth())/2, (rc.Height()-pProfileImageTmp->GetHeight())/2);
				pLogo->Draw();

				//如果先Desroy,则会崩溃,很奇怪,原因不明,暂时这么处理
				if( pProfileImage != NULL)
				{
					pProfileImage->Destroy();
					pProfileImage = NULL; 							
				}
				pProfileImage = pProfileImageTmp;
				
			}

			//释放图片
			pDownLoadBitmap->Destroy();
			pDownLoadBitmap = NULL; 	
		}
	}

	return TRUE;
}
开发者ID:pengjohn,项目名称:RenRen,代码行数:57,代码来源:RenRenForm_PhotosGetAlbums.cpp

示例10: SetAppTitleButton

Boolean TPagesGetListForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent)
{
	int iRet = eFailed;
	tResponsePagesGetList* Response = NULL;
	
	//m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_Refresh,TITLE_BUTTON_LEFT);
	m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT);
	SetAppTilte(this, APP_RE_ID_STRING_Pages);

	//从对应Json中获取数据,用于更新UI
	iRet = RenRenAPI_JsonParse(RR_PagesGetList, (void **)&Response);	

	//:TODO:
	//Panel -> CoolBarList->pRowList->pBarRow->pListItem

	TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList));
	if (pCoolBarList)
	{
		TBarRowList* pRowList = NULL;
		TBarRow* pBarRow = NULL;
		TBarListItem* pListItem = NULL;
		//背景设置为白色底色
		pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE);

		pRowList = pCoolBarList->Rows();
		if (pRowList)
		{
			pRowList->BeginUpdate();
			pRowList->Clear();
			pBarRow = pRowList->AppendRow();

			//数量统计
			{
				TBarListItem* lpItem = NULL;
				TUChar pszTitle[64] = {0};
				lpItem = pBarRow->AppendItem();
				if (lpItem)
				{
					Int32 StringWidth = 0;
					TUString::StrPrintF(pszTitle, TResource::LoadConstString(APP_RE_ID_STRING_PagesCount), Response->nArraySize);
					StringWidth = GetShowAllStringWidth(pszTitle, FONT_MIDDLE) + 5;	//多预留一些
					CtrlAddItemToCoolBarList_Lable(this, lpItem, (COOLBARLIST_WIDTH-StringWidth)/2, 10, StringWidth, FONT_MIDDLE, pszTitle);
					lpItem->SetHeight(10*2+FONT_MIDDLE);
					lpItem->SetEnabled(FALSE);
				}
			}
				
			//以下为增加列表项
			for (int i = 0; i < Response->nArraySize; i++)
			{
				TUChar pszString[4096] = {0};
				Coord nHeight = 0;
				Int32 nItemHeight = 0;
				
				pListItem = pBarRow->AppendItem();
				if (pListItem)
				{
					//属性设置
					pListItem->SetTitle(NULL);
					pListItem->SetCaption(NULL);       
					pListItem->SetIndicatorType(itNone);

					//头像,需要做缩放
					//先读取磁盘cache, 无文件再下载
					TBitmap* pDownLoadBitmap = NULL;
					pDownLoadBitmap = LoadImgByUrl(Response->Array[i].headurl);
					if(  pDownLoadBitmap != NULL)
					{
						gItemData[i].pBmp = pDownLoadBitmap->Create(HEADPHOTO_W, HEADPHOTO_H, 32);
						gItemData[i].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0);
						gItemData[i].MaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem,  HEADMASK_X,  HEADMASK_Y,  HEADMASKBUTTON_W, HEADMASKBUTTON_H, gItemData[i].pBmp,(TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1));

						//释放图片
						pDownLoadBitmap->Destroy();
						pDownLoadBitmap = NULL;
					}
					else
					{
						gItemData[i].MaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem,  HEADMASK_X,  HEADMASK_Y,  HEADMASKBUTTON_W,  HEADMASKBUTTON_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default),(TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1));
						//因为第一项为数据统计, 所以参数需要+1
						RenRenAPICommon_DownloadPhoto(Response->Array[i].headurl, this->GetWindowHwndId(), i );
					}


					#if 1
					TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].name);
					CtrlAddItemToCoolBarList_Lable(this , pListItem ,  NAME_X, NAME_Y, 0, FONT_NORMAL,pszString, RGB_COLOR_LIGHTBLUE);

					TUString::StrPrintF(pszString , TResource::LoadConstString(APP_RE_ID_STRING_FriendNumFormat), Response->Array[i].fans_count);
					CtrlAddItemToCoolBarList_Lable(this, pListItem, COUNT_INFO_X,  COUNT_INFO_Y, 0, FONT_SMALL, pszString, RGB_COLOR_GRAY);	
				
					pListItem->SetHeight(COOLBARLIST_HEIGHT);
					#else	//带描述的布局
					//姓名
					TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].name);
					CtrlAddItemToCoolBarList_RichView(this , pListItem ,  65, 5, 240, &nHeight, FONT_NORMAL,pszString, RGB_COLOR_LIGHTBLUE);
					nItemHeight = 5 + nHeight;
			
					//描述
					TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].desc);
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:RenRen,代码行数:101,代码来源:RenRenForm_PagesGetList.cpp

示例11: SetAppTilte

// 窗口初始化
Boolean TMessageGetsForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent)
{
	int iRet = eFailed;
	tResponseMessageGets* Response = NULL;

	if(nMessageBoxType == MESSAGE_TYPE_INBOX )
	{
		SetAppTilte(this, APP_RE_ID_STRING_MessagesInBox);
		//m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_OutBox,TITLE_BUTTON_LEFT);
		m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_write_but, APP_RE_ID_BITMAP_write_but_over);
	}
	else
	{
		SetAppTilte(this, APP_RE_ID_STRING_MessagesOutBox);
		//m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_InBox,TITLE_BUTTON_LEFT);
		m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_write_but, APP_RE_ID_BITMAP_write_but_over);
	}
	m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT);

	//从对应Json中获取数据,用于更新UI
	iRet = RenRenAPI_JsonParse(RR_MessageGets, (void **)&Response);	

	//:TODO:
	//Panel -> CoolBarList->pRowList->pBarRow->pListItem
	TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList));
	if(pCoolBarList)
	{
		TBarRowList* pRowList = NULL;
		TBarRow* pBarRow = NULL;
		TBarListItem* pListItem = NULL;
		//背景设置为白色底色
		pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE);
		pRowList = pCoolBarList->Rows();
		if (pRowList)
		{
			pRowList->BeginUpdate();
			pRowList->Clear();
			pBarRow = pRowList->AppendRow();
			if(pBarRow)
			{

				//数量统计
				{
					TBarListItem* lpItem = NULL;
					TUChar pszTitle[64] = {0};
					lpItem = pBarRow->AppendItem();
					if (lpItem)
					{
						Int32 StringWidth = 0;
						TUString::StrPrintF(pszTitle, TResource::LoadConstString(APP_RE_ID_STRING_MessageCount), Response->count);
						StringWidth = GetShowAllStringWidth(pszTitle, FONT_MIDDLE) + 8;	//多预留一些
						CtrlAddItemToCoolBarList_Lable(this, lpItem, (COOLBARLIST_WIDTH-StringWidth)/2, NAME_Y, 0, FONT_MIDDLE, pszTitle);
						lpItem->SetHeight(NAME_Y*2+FONT_MIDDLE);
						lpItem->SetEnabled(FALSE);
					}
				}
				
				//以下为增加列表项自定义项
				for (int i = 0; i < Response->nSize_messages; i++)
				{
					TUChar pszString[4096] = {0};
					pListItem = pBarRow->AppendItem();

					if (pListItem)
					{
						//属性设置
						pListItem->SetHeight(COOLBARLIST_HEIGHT);
						pListItem->SetTitle(NULL);
						pListItem->SetCaption(NULL);       
						pListItem->SetIndicatorType(itNone);

						//头像,先读取磁盘cache, 无文件再下载
						TBitmap* pDownLoadBitmap = NULL;
						pDownLoadBitmap = LoadImgByUrl(Response->messages[i].head_url);
						if(  pDownLoadBitmap != NULL)
						{
							gItemData[i].pBmp = pDownLoadBitmap->Create(HEADPHOTO_W, HEADPHOTO_H, 32);
							gItemData[i].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0);
							gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, gItemData[i].pBmp, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1));					

							//释放图片
							pDownLoadBitmap->Destroy();
							pDownLoadBitmap = NULL; 						
						}
						else
						{
							gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default), (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1));
							RenRenAPICommon_DownloadPhoto(Response->messages[i].head_url, this->GetWindowHwndId(), i );
						}
						//姓名
						TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->messages[i].name);
						CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X, NAME_Y, 0, FONT_MIDDLE, pszString);
						//时间
						TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->messages[i].time);
						CtrlAddItemToCoolBarList_Lable(this, pListItem, TIME_X, TIME_Y, 0, FONT_SMALL, pszString, RGB_COLOR_LIGHTBLUE);
						//标题,新消息显示为红色
						//一个小技巧,一个消息显示为两种(已读和未读), 然后根据情况隐藏一个
						TUChar pszStringTemp[4096] = {0};
						TUString::StrUtf8ToStrUnicode(pszStringTemp , (const Char *)Response->messages[i].title);
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:RenRen,代码行数:101,代码来源:RenRenForm_MessageGets.cpp

示例12: SetAppTilte

// 窗口初始化
Boolean TPhotosGetAlbumsForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent)
{
	int nErrorCode = eFailed;
	Int32 Height_Panel = 0;		//Panel高度		

	//m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_Comment,TITLE_BUTTON_LEFT);

	//显示不同的title
	if(m_FormMode == FORM_MODE_NORMAL)
	{
		SetAppTilte(this, APP_RE_ID_STRING_Album);
		m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT);

		char* uid = NULL;
		uid = Get_Url_Params(RR_PhotosGetAlbums, "uid");
		if( strcmp(uid, RenRenUserInfo.szuid) == 0)
		{
			m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_take_photo, APP_RE_ID_BITMAP_take_photo);
		}
	}
	else if(m_FormMode == FORM_MODE_MYHOME)
	{
		tResponseProfile* ResponseProfile;
		nErrorCode = RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile);
		if(ResponseProfile != NULL)
		{
			if(ResponseProfile->uid == RenRenUserInfo.uid)
			{
				SetAppTilte(this, APP_RE_ID_STRING_MyNews);
				m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Home, TITLE_BUTTON_RIGHT);
				m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_take_photo, APP_RE_ID_BITMAP_take_photo);
			}
			else
			{
				//姓名
				TUChar  pszFName[64] = {0};
				TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name);
				SetAppTilte(this, 0, pszFName);
				m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT);
			}
			delete ResponseProfile;
			ResponseProfile = NULL;
		}		
		
	}

	//设置panel高度
	TPanel* pTPanel = static_cast<TPanel*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonPanel));	
	TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList));	
	
	if(pTPanel)
	{
		TRectangle rect;
		
		Height_Panel = SCR_H - STATUSBAR_H - TITLEBAR_H;
		if(m_FormMode == FORM_MODE_MYHOME)
			Height_Panel -= BOTTOM_TAB_H;
			
		pTPanel->GetBounds(&rect);
		rect.SetHeight(Height_Panel);
		pTPanel->SetBounds(&rect);
	}

	if(m_FormMode == FORM_MODE_MYHOME)
		CreateProfileBottomTab(this, &BottomTabCtrID, 2);

	//显示个人信息
	if(m_FormMode == FORM_MODE_MYHOME)
	{
		Int32 Height_Top = 0;			//CoolBarList上面信息的高度
		Int32 Height_CoolBarList = 0;	//CoolBarList高度	
		tResponseProfile* ResponseProfile;
		nErrorCode = RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile);
		if(ResponseProfile != NULL)
		{
			//头像
			TBitmap* pDownLoadBitmap = NULL;
			pDownLoadBitmap = LoadImgByUrl(ResponseProfile->headurl);			
			//pProfileImage = LoadImgByUrl(ResponseProfile->headurl);
			const TBitmap * pImageDeault = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_DefaultLarge);
			const TBitmap * pBackImage = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_headmask_large);
			if(pDownLoadBitmap == NULL)
			{
				//RenRenAPICommon_DownloadPhoto(ResponseProfile->headurl, this->GetWindowHwndId(), FEED_PROFILE_IMAGE_INDEX);	
				m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pImageDeault, (TBitmap*)pImageDeault, (TBitmap*)pBackImage );	
				this->DisableControl(m_ProfileImageID);
			}
			else
			{
				//需要做放大
				pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth());
				pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255));				
				m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pProfileImage, (TBitmap*)pProfileImage, (TBitmap*)pBackImage );	
				this->DisableControl(m_ProfileImageID);
				
				//释放图片
				pDownLoadBitmap->Destroy();
				pDownLoadBitmap = NULL; 						
			}
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:RenRen,代码行数:101,代码来源:RenRenForm_PhotosGetAlbums.cpp

示例13: switch

// 窗口事件处理
Boolean TPhotosGetAlbumsForm::EventHandler(TApplication * pApp, EventType * pEvent)
{
	Boolean bHandled = FALSE;

	switch (pEvent->eType)
	{
		//窗口创建
	case EVENT_WinInit:
		{
			_OnWinInitEvent(pApp, pEvent);
			bHandled = TRUE;
		}
		break;

		//窗口关闭
	case EVENT_WinClose:
		{
			_OnWinClose(pApp, pEvent);
		}
		break;

		//点击控件
	case EVENT_CtrlSelect:
		{
			bHandled = _OnCtrlSelectEvent(pApp, pEvent);
		}
		break;

		//控件获取焦点
	case EVENT_CtrlSetFocus:
		{
			bHandled = _OnCtrlSetFocusEvent(pApp, pEvent);
		}
		break;

		//控件丢失焦点
	case EVENT_CtrlKillFocus :
		{
			bHandled = _OnCtrlKillFocusEvent(pApp, pEvent);
		}
		break;

		//输入框内容变化
	case EVENT_FieldChanged:
		{
			_OnFldChangedEvent(pApp, pEvent);
			bHandled = TRUE;
		}
		break;

		//窗口的背景
	case EVENT_WinEraseClient:
		{
			TDC dc(this);
			WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent );
			TRectangle rc(pEraseEvent->rc);
			dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND);
			dc.EraseRectangle(&rc, 0);
			dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT);

			if(m_FormMode == FORM_MODE_MYHOME)
				dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_Bottom_btn_bg), 0, BOTTOM_TAB_Y, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT);				
			pEraseEvent->result = 1;				
			bHandled = TRUE;
		}
		break;

		// 右软键事件 
	case EVENT_KeyCommand: 
		{ 
			if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) 
			{ 
				// 模拟标题栏右按钮选中消息 
				HitControl(m_TitleBtnRight); 
				bHandled = TRUE; 
			} 
		} 
		break;

        //下载完成事件
	case MSG_DL_THREAD_NOTIFY:
		{
			NotifyMsgDataType notifyData;
			Sys_GetMessageBody((MESSAGE_t *)pEvent, &notifyData, sizeof(NotifyMsgDataType));
			bHandled = TRUE;
			switch(notifyData.nAccessType)
			{
				case RR_PhotoDownload:
				{
					if(notifyData.nParam == FEED_PROFILE_IMAGE_INDEX)
					{	
						//下载完后更新对应的图片
						TBitmap* pDownLoadBitmap = NULL;
						pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath);

						if(pDownLoadBitmap)
						{
							TMaskButton* pLogo = NULL;
							pLogo = static_cast<TMaskButton*>(GetControlPtr(m_ProfileImageID));
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:RenRen,代码行数:101,代码来源:RenRenForm_PhotosGetAlbums.cpp

示例14: SetAppBitmapButton

// 窗口初始化
Boolean TGuestbookGetForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent)
{	
	m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_write_but, APP_RE_ID_BITMAP_write_but_over);
	//m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT);
	//SetAppTilte(this, APP_RE_ID_STRING_Guestbook);

	//显示不同的title
	if(m_FormMode == FORM_MODE_NORMAL)
	{
		SetAppTilte(this, APP_RE_ID_STRING_Guestbook);
		m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT);
	}
	else if(m_FormMode == FORM_MODE_MYHOME)
	{
		tResponseProfile* ResponseProfile;
		RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile);	
		if(ResponseProfile)
		{
			if(ResponseProfile->uid == RenRenUserInfo.uid)
			{
				SetAppTilte(this, APP_RE_ID_STRING_MyNews);
				m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Home,TITLE_BUTTON_RIGHT);
			}
			else
			{
				TUChar  pszFName[64] = {0};
				TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name);			
				SetAppTilte(this, 0, pszFName);
				m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT);
			}

			delete ResponseProfile;
			ResponseProfile = NULL;	
		}
	}
	
	//设置panel高度
	TPanel* pTPanel = static_cast<TPanel*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonPanel));	
	TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList));

	if( (pTPanel == NULL) || (pCoolBarList == NULL) )
		return FALSE;
	
	//调整Panel高度
	{
		TRectangle rect;
		Int32 Height_Panel = 0;		//Panel高度		
		
		Height_Panel = SCR_H - STATUSBAR_H - TITLEBAR_H;
		if(m_FormMode == FORM_MODE_MYHOME)
			Height_Panel -= BOTTOM_TAB_H;
			
		pTPanel->GetBounds(&rect);
		rect.SetHeight(Height_Panel);
		pTPanel->SetBounds(&rect);
	}

	if(m_FormMode == FORM_MODE_MYHOME)
		CreateProfileBottomTab(this, &BottomTabCtrID, 4);
	
	//:TODO:

	//显示个人信息
	if(m_FormMode == FORM_MODE_MYHOME)
	{
		Int32 Height_Top = 0;			//CoolBarList上面信息的高度
		tResponseProfile* ResponseProfile;
		RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile);
		if(ResponseProfile != NULL)
		{
			//头像
			TBitmap* pDownLoadBitmap = NULL;
			pDownLoadBitmap = LoadImgByUrl(ResponseProfile->headurl);			
			//pProfileImage = LoadImgByUrl(ResponseProfile->headurl);
			const TBitmap * pImageDeault = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_DefaultLarge);
			const TBitmap * pBackImage = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_headmask_large);
			if(pDownLoadBitmap == NULL)
			{
				//RenRenAPICommon_DownloadPhoto(ResponseProfile->headurl, this->GetWindowHwndId(), FEED_PROFILE_IMAGE_INDEX);	
				m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pImageDeault, (TBitmap*)pImageDeault, (TBitmap*)pBackImage );	
				this->DisableControl(m_ProfileImageID);
			}
			else
			{
				//需要做放大
				pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth());
				pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255));				
				m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pProfileImage, (TBitmap*)pProfileImage, (TBitmap*)pBackImage );	
				this->DisableControl(m_ProfileImageID);
				
				//释放图片
				pDownLoadBitmap->Destroy();
				pDownLoadBitmap = NULL; 						
			}
			//下载大头像
			tResponseUsersGetInfo* ResponseUserInfoPhoto = NULL;
			RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&ResponseUserInfoPhoto);
			if(ResponseUserInfoPhoto)
			{
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:RenRen,代码行数:101,代码来源:RenRenForm_GuestbookGet.cpp

示例15: LoadImgByUrl

void TUserInfoDetailForm::_SetDataToCtrls(TApplication* pApp)
{
	if(this->Response && Response->nSize_friends != 0)
	{
		TFont objFontType;				
		TUChar pszState[1024] = {0};
		TUChar pszStateTime[32] = {0};	
		TUChar pszLogoPath[256] = {0};	
		TUChar pszUserName[32] = {0};	
		TRectangle Rc_Temp;
		TRectangle rect;

		TMaskButton* pUserHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_UserDetailHeadMaskButton));

		TBitmap* pDownLoadBitmap = NULL;
		//Photo, 先读取磁盘cache
		pDownLoadBitmap = LoadImgByUrl(Response->friends[0].flogo90);
		//磁盘cache无文件,再下载
		if( pDownLoadBitmap == NULL)
		{
			TRectangle rc;

			KaiXinAPICommon_DownloadPhoto(Response->friends[0].flogo90, this->GetWindowHwndId(), 0 );	
			const TBitmap * pBmp = TResource::LoadConstBitmap(APP_KA_ID_BITMAP_Default);
			pUserHeadMBtn->GetBounds(&rc);
			pUserHeadMBtn->SetEnabled(FALSE);
			pUserHeadMBtn->SetCaption(TUSTR_Kx_NULL,0,0);
			pUserHeadMBtn->SetImage(pBmp,(rc.Width()-pBmp->GetWidth())/2, (rc.Height()-pBmp->GetHeight())/2);			
		}
		else
		{
			TRectangle rc;				
			pUserHeadMBtn->GetBounds(&rc);
			pUserHeadMBtn->SetEnabled(FALSE);
			pUserHeadMBtn->SetCaption(TUSTR_Kx_NULL,0,0);

			pPhotoBmp = TBitmap::Create(PHOTO_W, PHOTO_H, pDownLoadBitmap->GetDepth());
			pPhotoBmp->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255));	

			pUserHeadMBtn->SetImage(pPhotoBmp,(rc.Width()-pPhotoBmp->GetWidth())/2, (rc.Height()-pPhotoBmp->GetHeight())/2);			

			//释放图片
			pDownLoadBitmap->Destroy();
			pDownLoadBitmap = NULL;			
		}


		//用户名
		TRichView *pUserName = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_NameLbl));
		if(pUserName)
		{
			TUString::StrUtf8ToStrUnicode(pszUserName , (const Char *)Response->friends[0].fname);			
			objFontType = pUserName->GetFont();
			objFontType.Create(FONT_LARGE_NAME, FONT_LARGE_NAME);
			pUserName->SetFont(objFontType);
			pUserName->SetColor(CTL_COLOR_TYPE_FORE, RGB(67, 67, 135));
			pUserName->SetTransparent(TRUE);
			pUserName->SetCaption(pszUserName, FALSE);
			pUserName->SetEnabled(TRUE);			
		}

		//用户状态
		TPanel*pPanel = static_cast<TPanel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_StateContPanel));
		TRichView* pRichView = new TRichView();
		Int32 nRichViewId = 0;
		if(pRichView->Create(pPanel))	
		{
			TRectangle obBtnRec(0,0,0,0);
			pPanel->GetBounds(&obBtnRec);
			obBtnRec.SetX(0);
			obBtnRec.SetY(0);
			pRichView->SetBounds(&obBtnRec);
		
			TUString::StrUtf8ToStrUnicode(pszState, (Char*)Response->friends[0].state);
			objFontType = pRichView->GetFont();
			objFontType.Create(FONT_STATE, FONT_STATE);
			pRichView->SetFont(objFontType);
			pRichView->SetCaption(pszState,FALSE);

			pRichView->SetEnabled(FALSE);
			pRichView->SetWordWrapAttr(TRUE);
			pRichView->SetTransparent(TRUE);
			pRichView->SetScrollBarMode(CTL_SCL_MODE_NONE);
			pRichView->SetUnderLine(TRUE);
			Int32 nLineCount =  pRichView->GetLinesCount();
			if(nLineCount <7)
				nLineCount = 7;
		
			pRichView->SetMaxVisibleLines(nLineCount, TRUE);
		}		
		

		//状态更新时间
		TRichView* pStateTime = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_StateTimeLbl));		
		if(pStateTime)
		{
			objFontType = pStateTime->GetFont();
			objFontType.Create(FONT_OTHER_INFO, FONT_OTHER_INFO);
			pStateTime->SetFont(objFontType); 
			pStateTime->SetColor(CTL_COLOR_TYPE_FORE, RGB_COLOR_GRAY);
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:kaixin,代码行数:101,代码来源:KaiXinAPI_UserInfoDetail.cpp


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