GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Mar-2006, 02:09
katmayes katmayes is offline
New Member
 
Join Date: Mar 2006
Location: Switzerland
Posts: 6
katmayes is on a distinguished road

Can not display bmp in my picture control


Hye,

first of all...excuse me for my bad english, i come frome Switzerland

Well, i've got a problem with my MFC application.
I would like to display an image who come from my framgrabber buffer...
I 've verified that the image buffer was good, and it is, i can save the image on a file toto.bmp.
But, when i want to display my buffer image in the picture control....i can't.

Here is my code :
CPP / C++ / C Code:
void CFastFace_InterfaceDlg::OnInitializeCam() 
{
	Falconscr = new FalconSource(BOARD_NUMBER,INPUT,IMG_WIDTH,IMG_HEIGHT);
	Cbmp_frame= new CBitmap();
	CDC_Mem = new CDC();
	m_Picture = new CPicture();
	m_VideoNotModifiedDC=m_VideoNotModified.GetDC();		
	CDC_Mem->CreateCompatibleDC(m_VideoNotModifiedDC);	
}

#define DELETE_OBJ(oBJ) {if(oBJ!=NULL){delete oBJ; oBJ = NULL;}}
void CFastFace_InterfaceDlg::OnStartCapture() 
{
		
	while (NoStop)
	{
		imgBuffer=(unsigned char*)malloc(Falconscr->GetHeight()*Falconscr->GetWidth()*3*sizeof(char));
		Falconscr->Capture();
		Falconscr->GetImage(&imgBuffer);
		Falconscr->PumpMessages();	
		is_SaveImageMem(Falconscr->Gethandle(), "C:\\toto.bmp",(char*)imgBuffer,0);
		Cbmp_frame->CreateBitmap(Falconscr->GetWidth(),Falconscr->GetHeight(),1,3,imgBuffer);
		CDC_Mem->SelectObject(Cbmp_frame);
		m_VideoNotModifiedDC->BitBlt(0,0,Falconscr->GetWidth(),Falconscr->GetHeight(),CDC_Mem,0,0,SRCCOPY);
		Cbmp_frame->DeleteObject();
		free(imgBuffer);
	}
		
}

Here it is for the part who make this...
Someone know where is the mistake ?????

Thank you for your precious help

Greg
Last edited by LuciWiz : 10-Mar-2006 at 10:06. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #2  
Old 10-Mar-2006, 06:01
TurboPT's Avatar
TurboPT TurboPT is offline
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 958
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Can not display bmp in my picture control


With a quick glance, if m_Picture is the source to the picture control, it does not appear that m_Picture is given anything to display. Basically, the CPicture object is declared, but not used.
  #3  
Old 10-Mar-2006, 06:43
katmayes katmayes is offline
New Member
 
Join Date: Mar 2006
Location: Switzerland
Posts: 6
katmayes is on a distinguished road

Re: Can not display bmp in my picture control


I don't understand...
the source to my picture Control is m_VideoNotModifiedDC

like is declared here :

CPP / C++ / C Code:
void CFastFace_InterfaceDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFastFace_InterfaceDlg)
	DDX_Control(pDX, IDC_VIDEOMODIFIED, m_VideoModified);
	DDX_Control(pDX, IDC_VIDEONOTMODIFIED, m_VideoNotModified);
	//}}AFX_DATA_MAP
}

that's right...???
Last edited by LuciWiz : 10-Mar-2006 at 10:17. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #4  
Old 10-Mar-2006, 07:37
TurboPT's Avatar
TurboPT TurboPT is offline
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 958
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Can not display bmp in my picture control


What is the intention of this line in OnInitializeCam()?

CPP / C++ / C Code:
   m_Picture = new CPicture();

Based on that first listing, I don't know what type 'm_VideoNotModified' has.
Should m_Picture possibly be m_VideoNotModified instead?
  #5  
Old 10-Mar-2006, 08:26
katmayes katmayes is offline
New Member
 
Join Date: Mar 2006
Location: Switzerland
Posts: 6
katmayes is on a distinguished road

Re: Can not display bmp in my picture control


Oh yes ...euh. .in fact.. i don't use it
do not pay attention about that....

m_VideoNotModified is declared as Control CStatic
DC_VIDEONOTMODIFIED is of type Bitmap
  #6  
Old 10-Mar-2006, 11:57
TurboPT's Avatar
TurboPT TurboPT is offline
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 958
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Can not display bmp in my picture control


I'm not 100% sure, but do you possibly need to call UpdateData() to update the dialog?
  #7  
Old 11-Mar-2006, 06:35
katmayes katmayes is offline
New Member
 
Join Date: Mar 2006
Location: Switzerland
Posts: 6
katmayes is on a distinguished road

Re: Can not display bmp in my picture control


Well,

i 've seen that on this call :

Code:
CDC_Mem->SelectObject(Cbmp_frame);

i should have an CBitmap pointer...
I 've made this to test:

Code:
CBitmap *pBitmap=CDC_Mem->SelectObject(Cbmp_frame);

But ... pBitmap return value is.... NULL... so there is a real problem here... but why SelectOBject doesn't return a good value... i don't know at all because as seen on my code... Cbmp_frame return a good BItmap image (as i've tested)....so the problem come with CDC_Mem....
  #8  
Old 11-Mar-2006, 07:45
TurboPT's Avatar
TurboPT TurboPT is offline
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 958
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Can not display bmp in my picture control


I noticed there are two CreateBitmap functions.

One returns BOOL (from the CBitmap class), and
the other (a GDI function) returns a handle to the bitmap.

Since you call the CBitmap version, the MSDN says that operator HBITMAP() must be called to get the handle from CBitmap class.

Here's the MSDN text:
Quote:
MFC Library Reference
CBitmap:: operator HBITMAP

Use this operator to get the attached Windows GDI handle of the
CBitmap object.

operator HBITMAP( ) const;
(I found this info here: http://msdn2.microsoft.com/en-us/lib.../25kc2k5s.aspx )

See if this possibly helps.

Also, this might be easier...
I see that you pre-save the image to file: "C:\\toto.bmp"

instead of all this: ( after is_SaveImageMem() )
CPP / C++ / C Code:
Cbmp_frame->CreateBitmap(Falconscr->GetWidth(),Falconscr->GetHeight(),1,3,imgBuffer);
CDC_Mem->SelectObject(Cbmp_frame);
m_VideoNotModifiedDC->BitBlt(0,0,Falconscr->GetWidth(),Falconscr->GetHeight(),CDC_Mem,0,0,SRCCOPY);
Cbmp_frame->DeleteObject();

why not just
CPP / C++ / C Code:
m_VideoNotModifed.LoadBitmap( "C:\\toto.bmp" );

// or: m_VideoNotModifedDC.LoadBitmap( "C:\\toto.bmp" );

I'm not sure what the difference is between your m_VideoNotModified and m_VideoNotModifiedDC variables.
  #9  
Old 12-Mar-2006, 07:53
katmayes katmayes is offline
New Member
 
Join Date: Mar 2006
Location: Switzerland
Posts: 6
katmayes is on a distinguished road

Re: Can not display bmp in my picture control


Well, the line where i save the bitmap file was just for a test in fact...
And i can't use it for my application because it's for high security...
m_VideoNotModifiedDC is just the DC pointer to m_VideoNotModified
  #10  
Old 13-Mar-2006, 08:12
Dominic Dominic is offline
Member
 
Join Date: Aug 2005
Posts: 123
Dominic will become famous soon enough

Re: Can not display bmp in my picture control


If you are still having trouble, I learnt this from a previous posting:

Just a thought, but are you using Invadate() to cause the next update, and if so, you may need code something like this :
CPP / C++ / C Code:
	CRgn Region; 
	Region.CreateRectRgnIndirect(&ImagePosition);
	Display::InvalidateRgn(&Region,FALSE );


where ImagePosition is a rectangle of where you want to put the image, and the InvalidateRgn() function will cause the frame to process the OnPaint() function. Display is my class, based on CFrameWnd ( Display : public CFrameWnd) which has an OnPaint function that will be called when the region is invalidated.


Now in the OnPaint() function you need to perform your BitBlt, like so:
CPP / C++ / C Code:
	CPaintDC dc(this); // device context for painting
	int y = dc.BitBlt(	.... )


Thus it is the DC of the OnPaint() function of the instance of the window which is being used and not one that was created at initialisation.

Hope this might help. I will try to dig out the previous post that gave a good example of how to do this.


Here are the limks i used. If it works for you, then we have Paramesh to thank again.
hi...
you can find more information by visiting this link

http://www.functionx.com/visualc/gdi/displaybitmap.htm

or

http://cma.zdnet.com/book/visualc/ch15/ch15.htm
 
 

Recent GIDBlogToyota - 2008 September Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about MFC activeX control pcxgamer MS Visual C++ / MFC Forum 0 18-Jan-2006 17:16
fedora display problem machinated Computer Software Forum - Linux 1 22-Aug-2005 21:03
[winapi] edit control is lying to me... ubergeek C Programming Language 8 15-May-2005 18:02
Help! Some basal questions about MFC xutingnjupt MS Visual C++ / MFC Forum 1 05-Dec-2004 03:38
Detecting a mouse click outside of control arran.s MS Visual C++ / MFC Forum 1 27-Oct-2004 06:01

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:44.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.