当前位置: 首页>>代码示例>>C++>>正文


C++ IStream类代码示例

本文整理汇总了C++中IStream的典型用法代码示例。如果您正苦于以下问题:C++ IStream类的具体用法?C++ IStream怎么用?C++ IStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateFile

bool CLotteryDlg::_loadPic(CString strFullPath, PicInfo* picInfo)
{
	try
	{
		HANDLE hFile = CreateFile(strFullPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if (hFile == INVALID_HANDLE_VALUE)
			return false;
		DWORD dwFileSize = GetFileSize(hFile, NULL);
		if (-1 == dwFileSize)
			return false;

		picInfo->_hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
		if (picInfo->_hGlobal == NULL)
			return false;

		void * pImageMemory = GlobalLock(picInfo->_hGlobal);
		DWORD dwReadedSize;//保存实际读取的文件的大小
		ReadFile(hFile, pImageMemory, dwFileSize, &dwReadedSize, NULL);
		GlobalUnlock(picInfo->_hGlobal);
		CloseHandle(hFile);
		IStream* pIStream;//创建一个ISTream接口指针,保存图片流
		IPicture* pIPicture;//创建一个IPicture接口指针,表示图片对象
		if (S_OK != CreateStreamOnHGlobal(picInfo->_hGlobal, false, &pIStream))//用全局内存初始化IStream接口指针
			return false;
		if (S_OK != OleLoadPicture(pIStream, 0, false, IID_IPicture, (LPVOID*)&(pIPicture)))//用OleLoadPicture获得IPicture接口指针
		{
			::GlobalFree(picInfo->_hGlobal);
			pIStream->Release();
			return false;
		}
		//得到IPicture COM接口对象后,就可以进行获得图片信息,显示图片等操作
		pIPicture->get_Width(&picInfo->_cx);
		pIPicture->get_Height(&picInfo->_cy);

		picInfo->_iStream = pIStream;
		picInfo->_iPic = pIPicture;
		picInfo->_x = picInfo->_y = 0;
		picInfo->_strFilePath = strFullPath;
	}
	catch (...)
	{
		return false;
	}
	return true;
}
开发者ID:u-stone,项目名称:code-database,代码行数:45,代码来源:LotteryDlg.cpp

示例2: GlobalAlloc

IPicture* CEnBitmap::LoadFromBuffer(BYTE* pBuff, int nSize)
{
	HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, nSize);
	void* pData = GlobalLock(hGlobal);
	memcpy2(pData, pBuff, nSize);
	GlobalUnlock(hGlobal);

	IStream* pStream = NULL;
	IPicture* pPicture = NULL;

	if (CreateStreamOnHGlobal(hGlobal, TRUE, &pStream) == S_OK)
	{
		OleLoadPicture(pStream, nSize, FALSE, IID_IPicture, (LPVOID *)&pPicture);
		pStream->Release();
	}

	return pPicture; // caller releases
}
开发者ID:rusingineer,项目名称:EmulePlus,代码行数:18,代码来源:EnBitmap.cpp

示例3: SavePropertyStoreToString

HRESULT SavePropertyStoreToString(IPropertyStore *pps, PWSTR *ppszBase64)
{
    *ppszBase64 = NULL;

    IStream *pstm;
    HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &pstm);
    if (SUCCEEDED(hr))
    {
        hr = SavePropertyStoreToStream(pps, pstm);
        if (SUCCEEDED(hr))
        {
            IStream_Reset(pstm);
            hr = GetBase64StringFromStream(pstm, ppszBase64);
        }
        pstm->Release();
    }
    return hr;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:18,代码来源:PropertyStoreHelpers.cpp

示例4: WriteFileHelper

bool FileStorage::SaveFile(FileEntry& fileEntry, const IStream& sourceStream)
{
	IStream* stream = WriteFileHelper(fileEntry, FileOpenMode::DestoryWriteOrCreate, FileDataType::Binary);
	RETURN_FALSE_IF_NULL(stream);
	sourceStream.CopyTo(*stream);
	SAFE_RELEASE(stream);

	return true;
}
开发者ID:johndpope,项目名称:Medusa,代码行数:9,代码来源:FileStorage.cpp

示例5: LoadGdiplusImage

	inline void LoadGdiplusImage(const void *mem, size_t len, const FuncT &func)
	{
		HGLOBAL hGlobal = ::GlobalAlloc(GMEM_MOVEABLE, len);
		void *pData = ::GlobalLock(hGlobal);
		memcpy(pData, mem, len);
		::GlobalUnlock(hGlobal);

		IStream *pStream = NULL;
		if( ::CreateStreamOnHGlobal(hGlobal,TRUE, &pStream) == S_OK )
		{
			std::auto_ptr<Bitmap> bm(Bitmap::FromStream(pStream));
			func(bm.get());

			pStream->Release();
		}

		::GlobalFree(hGlobal);
	}
开发者ID:corefan,项目名称:my-crawler-engine,代码行数:18,代码来源:ImageHelpers.cpp

示例6: ASSERT

BOOL GdiPlusPicDrawer::CreateImageFromHGlobal(HGLOBAL hBuffer)
{
	ASSERT(hBuffer != NULL);
	IStream* pStream = NULL;
	if (::CreateStreamOnHGlobal(hBuffer, FALSE, &pStream) == S_OK)
	{
		m_pImage = Gdiplus::Bitmap::FromStream(pStream);
		Status lastStatus = m_pImage->GetLastStatus();
		pStream->Release();
		if (m_pImage != NULL && lastStatus == Ok)
			return TRUE;
		TRACE(_T("@1 GdiPlusPicDrawer::CreateImageFromHGlobal. Bitmap::FromStream failed :%d\r\n"), lastStatus);
	}
	else
		TRACE(_T("@1 GdiPlusPicDrawer::CreateImageFromHGlobal. CreateStreamOnHGlobal failed\r\n"));
	Destroy();
	return FALSE;
}
开发者ID:KurzedMetal,项目名称:Jaangle,代码行数:18,代码来源:GdiPlusPicDrawer.cpp

示例7: applyPatchfile

void applyPatchfile(string fname) {
	IStream *f = new IFStream(fname);
	Injectable_IStream f2(*f);
	if (((IFStream*)f)->bad()) {
		fprintf(stderr, "file is missing: %s\n", fname.c_str()); 
		exit(1);
	}
	unsigned type = determine_filetype(f2);
	delete f;
	switch (type) {
		case GZIP: f = new GZ_IFStream(fname); break;
		case BZIP2: f = new BZ_IFStream(fname); break;
		case DTU: f = new IFStream(fname); break;
		case UNKNOWN_FMT: fprintf(stderr, "cannot read file %s\n", fname.c_str()); exit(1);
		case TARBALL :
			f = new IFStream(fname);
			unsigned zero_count;
			zero_count = 0;
			char tarheader[512];
			do {
				f->read(tarheader, 512);
				if (tarheader[0]==0) ++zero_count;
				int size = read_ascii_octal(tarheader+124);
				if (size) {
					string fileName = getTmpFilename();
					{
						OFStream o(fileName);
						copy_bytes_to_file(*f, o, size);
					} 
					applyPatchfile(fileName);
					doneTmpFile(fileName);

					unsigned lastblocksize = size % 512;
					if (lastblocksize==0) lastblocksize=512;
					f->read(tarheader, 512 - lastblocksize);
				}
			} while (zero_count < 2);
			return;
	}
	Injectable_IStream infile(*f);
	type = determine_filetype(infile);
	if (type==DTU) patchPackage(infile); else 
		applyPatchfile(infile);
}
开发者ID:jjwhitney,项目名称:Deltup,代码行数:44,代码来源:deltup.cpp

示例8: StopStreaming

HRESULT CWavDestFilter::StopStreaming()
{
    IStream* pStream;
    if (m_pOutput->IsConnected() == FALSE) {
        return E_FAIL;
    }

    IPin* pDwnstrmInputPin = m_pOutput->GetConnected();

    if (!pDwnstrmInputPin) {
        return E_FAIL;
    }

    HRESULT hr = ((IMemInputPin*) pDwnstrmInputPin)->QueryInterface(IID_IStream, (void**)&pStream);
    if (SUCCEEDED(hr)) {
        BYTE* pb = (BYTE*)_alloca(m_cbHeader);

        RIFFLIST* pRiffWave = (RIFFLIST*)pb;
        RIFFCHUNK* pRiffFmt = (RIFFCHUNK*)(pRiffWave + 1);
        RIFFCHUNK* pRiffData = (RIFFCHUNK*)(((BYTE*)(pRiffFmt + 1)) + m_pInput->CurrentMediaType().FormatLength());

        pRiffData->fcc = FCC('data');
        pRiffData->cb = m_cbWavData;

        pRiffFmt->fcc = FCC('fmt ');
        pRiffFmt->cb = m_pInput->CurrentMediaType().FormatLength();
        CopyMemory(pRiffFmt + 1, m_pInput->CurrentMediaType().Format(), pRiffFmt->cb);

        pRiffWave->fcc = FCC('RIFF');
        pRiffWave->cb = m_cbWavData + m_cbHeader - sizeof(RIFFCHUNK);
        pRiffWave->fccListType = FCC('WAVE');

        LARGE_INTEGER li;
        ZeroMemory(&li, sizeof(li));

        hr = pStream->Seek(li, STREAM_SEEK_SET, 0);
        if (SUCCEEDED(hr)) {
            hr = pStream->Write(pb, m_cbHeader, 0);
        }
        pStream->Release();
    }

    return hr;
}
开发者ID:Gongong,项目名称:mpc-hc,代码行数:44,代码来源:WavDest.cpp

示例9: NewGUI_ExtractVistaIcon

bool NewGUI_ExtractVistaIcon(const std::vector<BYTE>& v, Bitmap** pOutBmp)
{
	if(pOutBmp == NULL) { ASSERT(FALSE); return false; }
	*pOutBmp = NULL;

	const size_t SizeICONDIR = 6;
	const size_t SizeICONDIRENTRY = 16;
	if(v.size() < SizeICONDIR) { ASSERT(FALSE); return false; }

	const size_t cImages = *(WORD *)&v[4];
	for(size_t i = 0; i < cImages; ++i)
	{
		const BYTE bWidth = v[SizeICONDIR + (i * SizeICONDIRENTRY)];
		const BYTE bHeight = v[SizeICONDIR + (i * SizeICONDIRENTRY) + 1];
		const WORD wBitCount = *(WORD *)&v[SizeICONDIR + (i *
			SizeICONDIRENTRY) + 6];

		if((bWidth == 0) && (bHeight == 0) && (wBitCount == 32))
		{
			const size_t uSize = *(size_t *)&v[SizeICONDIR + (i *
				SizeICONDIRENTRY) + 8];
			const size_t uOffset = *(size_t *)&v[SizeICONDIR + (i *
				SizeICONDIRENTRY) + 12];

			IStream* pStream = NULL;
			if(FAILED(CreateStreamOnHGlobal(NULL, TRUE, &pStream))) { ASSERT(FALSE); return false; }
			if(pStream == NULL) { ASSERT(FALSE); return false; }

			VERIFY(SUCCEEDED(pStream->Write(&v[uOffset],
				static_cast<ULONG>(uSize), NULL)));

			LARGE_INTEGER liMove;
			ZeroMemory(&liMove, sizeof(LARGE_INTEGER));
			VERIFY(SUCCEEDED(pStream->Seek(liMove, STREAM_SEEK_SET, NULL)));

			*pOutBmp = Bitmap::FromStream(pStream, FALSE);

			pStream->Release();
			return (*pOutBmp != NULL);
		}
	}

	return false;
}
开发者ID:joshuadugie,项目名称:KeePass-1.x,代码行数:44,代码来源:ImageUtilEx.cpp

示例10: NewGUI_SaveIcon

std::vector<BYTE> NewGUI_SaveIcon(HICON hIcon)
{
	std::vector<BYTE> v;
	if(hIcon == NULL) { ASSERT(FALSE); return v; }

	IStream* pStream = NULL;
	if(FAILED(CreateStreamOnHGlobal(NULL, TRUE, &pStream))) { ASSERT(FALSE); return v; }
	if(pStream == NULL) { ASSERT(FALSE); return v; }

	PICTDESC pd;
	ZeroMemory(&pd, sizeof(PICTDESC));
	pd.cbSizeofstruct = sizeof(PICTDESC);
	pd.picType = PICTYPE_ICON;
	pd.icon.hicon = hIcon;

	IPicture* pPic = NULL;
	LONG lSize = 0;
	bool bPic = SUCCEEDED(OleCreatePictureIndirect(&pd, IID_IPicture,
		FALSE, (LPVOID *)&pPic));
	bPic &= (pPic != NULL);
	if(bPic)
	{
		if(SUCCEEDED(pPic->SaveAsFile(pStream, TRUE, &lSize)))
		{
			LARGE_INTEGER liMove;
			ZeroMemory(&liMove, sizeof(LARGE_INTEGER));
			VERIFY(SUCCEEDED(pStream->Seek(liMove, STREAM_SEEK_SET, NULL)));

			v.resize(static_cast<size_t>(lSize));

			ULONG cbRead = 0;
			VERIFY(SUCCEEDED(pStream->Read(&v[0], static_cast<ULONG>(
				lSize), &cbRead)));
			if(cbRead == static_cast<ULONG>(lSize)) { } // Success
			else { ASSERT(FALSE); v.clear(); }
		}

		pPic->Release();
	}

	pStream->Release();
	return v;
}
开发者ID:joshuadugie,项目名称:KeePass-1.x,代码行数:43,代码来源:ImageUtilEx.cpp

示例11: ShowJpeg

HRESULT CPicStatic::ShowJpeg(LPVOID picData,DWORD dwFileSize,int x, int y,CDC *pDC)
{
	IStream   *pStm;
	IPicture   *pPic;
	BOOL   bResult;     
   
	HGLOBAL   hGlobal   =   GlobalAlloc(GMEM_MOVEABLE,   dwFileSize);     
	LPVOID   pvData   =   NULL;
	if (hGlobal  ==   NULL)
		return   false;
	pvData   =   GlobalLock(hGlobal);
	if ( pvData ==   NULL)  
		return   false;

	memcpy(pvData,picData,dwFileSize);
	GlobalUnlock(hGlobal);
	CreateStreamOnHGlobal(hGlobal,   TRUE,   &pStm);
	bResult=OleLoadPicture(pStm,dwFileSize,TRUE,IID_IPicture,(LPVOID*)&pPic);

	if(FAILED(bResult))
	{
//		CloseHandle(hFile);
		return   false;
	}
	OLE_XSIZE_HIMETRIC   hmWidth;
	OLE_YSIZE_HIMETRIC   hmHeight;
	pPic->get_Width(&hmWidth);     
	pPic->get_Height(&hmHeight);     
	//将图形输出到屏幕上(有点像BitBlt)     
	bResult=pPic->Render(pDC->m_hDC,0,0,x,y,0,hmHeight,hmWidth,-hmHeight,NULL);     

//	CloseHandle(hFile);
	pStm->Release();
	pPic->Release();
	if   (SUCCEEDED(bResult))     
	{
		return   S_OK;     
	}     
	else     
	{     
		return   E_FAIL;     
	}   
}
开发者ID:Halry,项目名称:ZTE-windows,代码行数:43,代码来源:PicStatic.cpp

示例12: ReleasePeer

void CInProcPlugHole::ReleasePeer()
{
	if (m_piMarshalledPeer != NULL)
	{
		IStream* piStream = m_piMarshalledPeer;
		m_piMarshalledPeer = NULL;
		m_dwVMStarterId = 0;

		::ResetEvent(m_hPeerAvailable);
		m_mapPeers.clear();

		// Unmarshall it one last time to release it
		LARGE_INTEGER pos;
		pos.QuadPart = 0;
		piStream->Seek(pos, STREAM_SEEK_SET, NULL);
		IIPDolphinPtr piPeer;
		HRESULT hr = ::CoGetInterfaceAndReleaseStream(piStream, __uuidof(IIPDolphin), reinterpret_cast<void**>(&piPeer));
	}
}
开发者ID:brunobuzzi,项目名称:DolphinVM,代码行数:19,代码来源:InProcPlugHole.cpp

示例13: GlobalAlloc

//-----------------------------------------------------------------------------
// Does:   Read The Picture Data From a Source (File / Resource)
// ~~~~    And Load It Into The Current IPicture Object In Use
//
// InPut:  Buffer Of Data Source (File / Resource) And Its Size
// ~~~~~   
//
// OutPut: Feed The IPicture Object With The Picture Data
// ~~~~~~  (Use Draw Functions To Show It On a Device Context)
//         TRUE If Succeeded...
//-----------------------------------------------------------------------------
BOOL CPicViewer::LoadPictureData(BYTE *pBuffer, int nSize)
//=============================================================================
{
    BOOL bResult = FALSE;
    
    HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, nSize);
    
    if(hGlobal == NULL)
    {
        TRACE( "Can not allocate enough memory\n" );
        // 		HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
        // 		MessageBoxEx(hWnd, "Can not allocate enough memory\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
        return(FALSE);
    }
    
    void* pData = GlobalLock(hGlobal);
    memcpy(pData, pBuffer, nSize);
    GlobalUnlock(hGlobal);
    
    IStream* pStream = NULL;
    
    if(CreateStreamOnHGlobal(hGlobal, TRUE, &pStream) == S_OK)
    {
        HRESULT hr;
        if((hr = OleLoadPicture(pStream, nSize, FALSE, IID_IPicture, (LPVOID *)&m_IPicture)) == E_NOINTERFACE)
        {
            TRACE( "IPicture interface is not supported\n" );
            // 			HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
            // 			MessageBoxEx(hWnd, "IPicture interface is not supported\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
            return(FALSE);
        }
        else // S_OK
        {
            pStream->Release();
            pStream = NULL;
            bResult = TRUE;
        }
    }
    
    FreeResource(hGlobal); // 16Bit Windows Needs This (32Bit - Automatic Release)
    
    return(bResult);
}
开发者ID:idandan,项目名称:DrawLaneDemo,代码行数:54,代码来源:picviewer.cpp

示例14: assert

BOOL CDuiImgX::LoadFromMemory( LPVOID pBuf,DWORD dwSize )
{
    assert(m_pImg==NULL);

    HGLOBAL hMem = ::GlobalAlloc(GMEM_FIXED, dwSize);
    BYTE* pMem = (BYTE*)::GlobalLock(hMem);

    memcpy(pMem, pBuf, dwSize);

    IStream* pStm = NULL;
    ::CreateStreamOnHGlobal(hMem, TRUE, &pStm);

    m_pImg = Gdiplus::Image::FromStream(pStm);

    pStm->Release();
    ::GlobalUnlock(hMem);
    // 	GlobalFree(hMem);
    return m_pImg!=NULL;
}
开发者ID:Johnny-Martin,项目名称:ComBase,代码行数:19,代码来源:duiimage.cpp

示例15: GetImageFromBase64

Bitmap* GetImageFromBase64(string encodedImage)
{
	int imageSize = int((encodedImage.length()/3)+1)*4;
	char* t=new char[imageSize];
	base64_decode(encodedImage.c_str(),encodedImage.length(), t, &imageSize); // using the base64 
	HGLOBAL hMem = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
	LPVOID pImage = ::GlobalLock(hMem);
	memcpy(pImage, t, imageSize);

	IStream* pStream = NULL;
	::CreateStreamOnHGlobal(hMem, FALSE, &pStream);

	Bitmap *img = new Bitmap(pStream);
	pStream->Release();
	GlobalUnlock(hMem);
	GlobalFree(hMem);
	delete []t;
    return img;
}
开发者ID:AlloyTeam,项目名称:webtop,代码行数:19,代码来源:system.cpp


注:本文中的IStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。