Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to display an image from a stream data.
But there is no image when getting image::from stream.
It's my source code:
C++
IStream* pstream = NULL;
	if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pstream)))
	{
		
		ULONG lreal = 0;
 
		pstream->Write(chIncomingDataBuffer, iEnd, &lreal );
		if(pstream!= NULL)
		{
		
		MessageBox(hWnd,
						" Stream is OK",
						"Connection strt",
						MB_ICONINFORMATION|MB_OK);
		
		}
		Image* image =Image::FromStream(pstream);
		if(image)
		{
		
		RECT rect;
 
			::GetWindowRect(hWnd, &rect);
			Graphics graphics(hWnd);
			graphics.DrawImage(image, 0, 0, rect.right-rect.left, rect.bottom-rect.top);
	
		}
		else
		{
		
		MessageBox(hWnd,
						"No image is written",
						"Connection strt",
						MB_ICONINFORMATION|MB_OK);
		
		
		}
		if(image)
			delete image;
		image = NULL;
		if(pstream)
			pstream->Release();
		pstream = NULL;
	
	}


There is no image from data. Can anyone help me in this?
Thanks!
Posted

check that the received data is the correct image data and it is compatible to your output. Send some known picture data and request the output. Image size and so on.
 
Share this answer
 
Comments
Sachin k Rajput 25-Feb-13 4:37am    
First I created that thing based on - Checking the data, size, write to a file, then check size, then display.
That's OK but when I tried to load it through buffer there is no image data.
KarstenK 25-Feb-13 4:57am    
What happens if you display the original data on the source side of the stream? Make a binary check (LSB-MSB)
Repost of http://www.codeproject.com/Messages/4503709/Displaying-Image-from-stream.aspx[^]. Please choose one forum and stick to it.
 
Share this answer
 
I've solved this using IStream and GDI+.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900