Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C++/CLI C
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:
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 24-Feb-13 18:17pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
toms from newdelhi at 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 at 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)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Repost of http://www.codeproject.com/Messages/4503709/Displaying-Image-from-stream.aspx[^]. Please choose one forum and stick to it.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I've solved this using IStream and GDI+.
  Permalink  

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

  Print Answers RSS
0 CPallini 365
1 Sergey Alexandrovich Kryukov 242
2 OriginalGriff 165
3 George Jonsson 159
4 Richard MacCutchan 110
0 OriginalGriff 6,344
1 Sergey Alexandrovich Kryukov 5,860
2 CPallini 5,135
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100