从流中显示图像 [英] Display image from stream

查看:93
本文介绍了从流中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从流数据中显示图像。

但是从流中获取image ::时没有图像。

它是'我的源代码:

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!

推荐答案

检查收到的数据是否是正确的图像数据并且它与您的数据兼容输出。发送一些已知图片数据并请求输出。图像大小等。
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.


重新发布 http ://www.codeproject.com/Messages/4503709/Displaying-Image-from-stream.aspx [ ^ ]。请选择一个论坛并坚持下去。
Repost of http://www.codeproject.com/Messages/4503709/Displaying-Image-from-stream.aspx[^]. Please choose one forum and stick to it.


我已经使用IStream和GDI +解决了这个问题。
I''ve solved this using IStream and GDI+.


这篇关于从流中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆