Click here to Skip to main content
12,622,913 members (30,729 online)
Rate this:
 
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 19: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 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)
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2016
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