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


C++ IPicture::get_Height方法代码示例

本文整理汇总了C++中IPicture::get_Height方法的典型用法代码示例。如果您正苦于以下问题:C++ IPicture::get_Height方法的具体用法?C++ IPicture::get_Height怎么用?C++ IPicture::get_Height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPicture的用法示例。


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

示例1: drawJPEG

//将jpg数据显示到界面
DWORD WINAPI drawJPEG(LPVOID param)
{
	CLiveview *dlg = (CLiveview *)param;
	dlg->fetching = true;
	while (dlg->fetching)
	{
	if (dlg->mJpegQueue.size() == 0)
	{
		continue;
	}
	IPicture *pPic = getPicFromHGlobal(dlg->mJpegQueue.front());
	dlg->mJpegQueue.pop();

	if (pPic == NULL)
		break;

		OLE_XSIZE_HIMETRIC hmWidth;
		OLE_YSIZE_HIMETRIC hmHeight;
		pPic->get_Width(&hmWidth);
		pPic->get_Height(&hmHeight);
		double fX, fY;
		CRect rect;
		GetClientRect(dlg->m_Liveview.m_hWnd, rect);
		fX = rect.Width();
		fY = rect.Height();
		HDC *pDC = &dlg->m_Liveview.GetDC()->m_hDC;
		pPic->Render(*pDC, 0, 0, (DWORD)fX, (DWORD)fY, 0, hmHeight, hmWidth, -hmHeight, NULL);
		pPic->Release();
	}
	dlg->fetching = false;
	dlg->FreshUI();
	return -1;
}
开发者ID:zkq,项目名称:SonyRemoteControlCamera,代码行数:34,代码来源:Liveview.cpp

示例2: OnBnClickedBtnpic

//拍摄照片按钮
void CLiveview::OnBnClickedBtnpic()
{
	Document d;
	//发送拍照请求
	d = indevice->actTakePicture();
	if (indevice->isJsonOk(d))
	{
		//请求成功就解析照片地址  继续获取
		CString pictureurl = d["result"].GetArray()[0].GetArray()[0].GetString();
		ULONG size = 0;
		PUCHAR picture = HttpClient::getData(pictureurl, size);
		if (size <= 0)
		{
			return;
		}
		//将图片数据存储为文件
		FILE *file = fopen("d:\\picture.jpg", "wb");
		if (file)
		{
			fwrite(picture, size, 1, file);
			fclose(file);
		}
		//将获取的数据解码为照片并显示
		HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
		LPVOID pData = GlobalLock(hGlobal);
		memcpy(pData, picture, size);
		GlobalUnlock(hGlobal);
		delete[] picture;
		IPicture *pPic = getPicFromHGlobal(hGlobal);

		if (pPic == NULL)
			return;



		OLE_XSIZE_HIMETRIC hmWidth;
		OLE_YSIZE_HIMETRIC hmHeight;
		pPic->get_Width(&hmWidth);
		pPic->get_Height(&hmHeight);
		double fX, fY;
		CRect rect;
		mPic.GetWindowRect(&rect);
		fX = rect.Width();
		fY = rect.Height();
		HDC *pDC = &mPic.GetDC()->m_hDC;
		pPic->Render(*pDC, 0, 0, (DWORD)fX, (DWORD)fY, 0, hmHeight, hmWidth, -hmHeight, NULL);
		pPic->Release();
	}
}
开发者ID:zkq,项目名称:SonyRemoteControlCamera,代码行数:50,代码来源:Liveview.cpp

示例3: _loadPic

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

示例4: 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

示例5: DrawFaceImageMin

void CCommon::DrawFaceImageMin(CStatic *m_picBox,unsigned char *image,unsigned long int size)
{
	CRect rect; 
	m_picBox->GetClientRect(&rect);//获得pictrue控件所在的举行区域
	CDC *pDC=m_picBox->GetDC();//获得pictrue控件的DC 

	IPicture *pPic;//定义显示图片的接口(可显示jpg格式图片)

	HGLOBAL hGlobal=GlobalAlloc(GMEM_MOVEABLE,size);//分配内存空间
	void *pData=GlobalLock(hGlobal);//定义图象数据指针
	memcpy(pData,image,size); 
	GlobalUnlock(hGlobal);//释放内存空间
	IStream *pStream=NULL;//定义数据流指针
	//创建数据流
	if(CreateStreamOnHGlobal(hGlobal,TRUE,&pStream)==S_OK) 
	{ 
		//装载图象文件
		if(SUCCEEDED(OleLoadPicture(pStream,size,TRUE,IID_IPicture,(LPVOID*)&pPic))) 
		{  
			OLE_XSIZE_HIMETRIC hmWidth; 
			OLE_XSIZE_HIMETRIC hmHeight; 
			pPic->get_Width(&hmWidth);//获得图象真实宽度
			pPic->get_Height(&hmHeight);//获得图象真实高度
	
			//在控件上显示图片
			pPic->Render(*pDC,4,4,rect.Width()-8,rect.Height()-8,0,hmHeight,hmWidth,-hmHeight,NULL); 
			pPic->Release(); 
			pStream->Release();//释放数据流
		
		}  
	}

	if(hGlobal)
	{
		GlobalFree(hGlobal);
		hGlobal = NULL;
	}
	m_picBox-> ReleaseDC(pDC);
}
开发者ID:dulton,项目名称:brpj,代码行数:39,代码来源:Common.cpp

示例6: loadPicture

bool Bitmap::loadPicture(LPCTSTR pszFilename)
{
    // Loads an image using the IPicture COM interface.
    // Supported image formats: BMP, EMF, GIF, ICO, JPG, WMF, TGA.
    //
    // Based on code from MSDN Magazine, October 2001.
    // http://msdn.microsoft.com/msdnmag/issues/01/10/c/default.aspx

    // IPicture interface doesn't support TGA files.
    if (_tcsstr(pszFilename, _T(".TGA")) || _tcsstr(pszFilename, _T(".tga")))
        return loadTarga(pszFilename);

    HRESULT hr = 0;
    HANDLE hFile = 0;
    HGLOBAL hGlobal = 0;
    IStream *pIStream = 0;
    IPicture *pIPicture = 0;
    BYTE *pBuffer = 0;
    DWORD dwFileSize = 0;
    DWORD dwBytesRead = 0;
    LONG lWidth = 0;
    LONG lHeight = 0;

    if (!m_logpixelsx && !m_logpixelsy)
    {
        HDC hScreenDC = CreateCompatibleDC(GetDC(0));

        if (!hScreenDC)
            return false;

        m_logpixelsx = GetDeviceCaps(hScreenDC, LOGPIXELSX);
        m_logpixelsy = GetDeviceCaps(hScreenDC, LOGPIXELSY);
        DeleteDC(hScreenDC);
    }

    hFile = CreateFile(pszFilename, FILE_READ_DATA, FILE_SHARE_READ, 0,
                       OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

    if (hFile == INVALID_HANDLE_VALUE)
        return false;

    if (!(dwFileSize = GetFileSize(hFile, 0)))
    {
        CloseHandle(hFile);
        return false;
    }

    if (!(hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD, dwFileSize)))
    {
        CloseHandle(hFile);
        return false;
    }

    if (!(pBuffer = reinterpret_cast<BYTE*>(GlobalLock(hGlobal))))
    {
        GlobalFree(hGlobal);
        CloseHandle(hFile);
        return false;
    }

    if (!ReadFile(hFile, pBuffer, dwFileSize, &dwBytesRead, 0))
    {
        GlobalUnlock(hGlobal);
        GlobalFree(hGlobal);
        CloseHandle(hFile);
        return false;
    }

    GlobalUnlock(hGlobal);
    CloseHandle(hFile);

    if (FAILED(CreateStreamOnHGlobal(hGlobal, FALSE, &pIStream)))
    {
        GlobalFree(hGlobal);
        return false;
    }

    if (FAILED(OleLoadPicture(pIStream, 0, FALSE, IID_IPicture,
                              reinterpret_cast<LPVOID*>(&pIPicture))))
    {
        pIStream->Release();
        GlobalFree(hGlobal);
        return false;
    }

    pIStream->Release();
    GlobalFree(hGlobal);

    pIPicture->get_Width(&lWidth);
    pIPicture->get_Height(&lHeight);

    width = MulDiv(lWidth, m_logpixelsx, HIMETRIC_INCH);
    height = MulDiv(lHeight, m_logpixelsy, HIMETRIC_INCH);

    if (!create(width, height))
    {
        pIPicture->Release();
        return false;
    }

//.........这里部分代码省略.........
开发者ID:tuannsofta,项目名称:kinect4bag,代码行数:101,代码来源:bitmap.cpp

示例7: GDIconvertGraphic

  //
  // Entry point for conversion
  //
UT_Error IE_ImpGraphic_Win32Native::_convertGraphic(UT_ByteBuf * pBB, std::string& mimetype)
{	
    IPicture* pPicture = NULL;
    IStream* stream;	
    HGLOBAL hG;		
    HBITMAP hBitmap;
    OLE_HANDLE* hB;
    PBITMAPINFO	bi;
    UT_ByteBuf bBufBMP;
    UT_Error err;	

	/* If the system has GDI+, use it*/
	if (isGDIPlusAvailable())
	{
		m_pBB = new UT_ByteBuf();
		return GDIconvertGraphic(pBB, m_pBB, mimetype);		
	}

	// the code below always writes out PNG's for now; we could update it to support
	// native JPEG images as well, or just delete it and always use GDI+.
	mimetype = "image/png";

    // We need to store the incoming bytebuffer in a Windows global heap	
    size_t nBlockLen = pBB->getLength();   	
    hG = GlobalAlloc(GPTR, nBlockLen);
    if (!hG) 
		return UT_IE_NOMEMORY;	
    
    CopyMemory(hG, pBB->getPointer(0), nBlockLen);   	
    
    // Create a stream from heap
    HRESULT hr = CreateStreamOnHGlobal(hG,false,&stream);
    if (!SUCCEEDED(hr) || !stream)
	{
		GlobalFree(hG);
		return UT_IE_NOMEMORY;
	}
    
    hr = OleLoadPicture(stream,0,false,IID_IPicture,(void**)&pPicture);	

    stream->Release();
    GlobalFree(hG);
    
    if (!SUCCEEDED(hr) || !pPicture)
	{
		return UT_IE_UNKNOWNTYPE;
	}

    pPicture->get_Handle((unsigned int*)&hB);
    
    hBitmap = (HBITMAP)CopyImage(hB,IMAGE_BITMAP,0,0,LR_COPYRETURNORG);
    
    HWND hWnd = GetDesktopWindow();
    
    // Create a BMP file from a BITMAP	
    bi = CreateBitmapInfoStruct(hBitmap);						
    CreateBMPFile(hWnd, bBufBMP, bi, hBitmap, GetDC(hWnd));
    LocalFree ((HLOCAL)bi);
    
    InitializePrivateClassData();
    
    /* Read Header Data */
    err = Read_BMP_Header(&bBufBMP);
	
	/* 
	   It's not a bitmap, then we have to rendered it into a device
	   context and get a bitmap from there. Case wmf graphics
	*/
	if (err) 
	{
		if (err!=UT_IE_BOGUSDOCUMENT) 
		{
			pPicture->Release();
			return err;		
		}
		
        long nWidth  = 0;
        long nHeight = 0;
		long nScaleToWidth= 500;
		long nScaleToHeight= 500;		
		RECT rc, rect;				
		BYTE *imagedata;
		HBITMAP hBit;
		HBITMAP hOld;
		BITMAPINFO bmi; 		
		HDC hWndDC = GetDC(hWnd);
		HDC	hMemDC = CreateCompatibleDC(hWndDC);
		HBRUSH hBrush = (HBRUSH)GetCurrentObject(hMemDC, OBJ_BRUSH);
		
		pPicture->get_Width (&nWidth);
		pPicture->get_Height(&nHeight);

		bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 	
		bmi.bmiHeader.biWidth = nScaleToWidth;
		bmi.bmiHeader.biHeight = nScaleToHeight;
		bmi.bmiHeader.biPlanes = 1; 
		bmi.bmiHeader.biBitCount = 24; // as we want true-color
//.........这里部分代码省略.........
开发者ID:monkeyiq,项目名称:odf-2011-track-changes-git-svn,代码行数:101,代码来源:ie_impGraphic_Win32Native.cpp

示例8: LoadPictureIPicture

//====================================================================================
//=
//= Function Name: LoadPictureIPicture
//= 
//= Parameters   : pcImage   - the descriptor to load the image into
//=                szFilename      - the path of the image file to load from
//= 
//= Returns      : TRUE if successful, FALSE otherwise
//=
//= Description  : Loads BMP, EMF, JPG, ICO, WMF, GIF files into a texture descriptor
//=                by leveraging the power of Windows IPicture routines and OLE
//=
//====================================================================================
BOOL LoadPictureIPicture(CImage *pcImage, char *szFilename)	
{
	HDC			hdcTemp;												// The DC To Hold Our Bitmap
	HBITMAP		hbmpTemp;												// Holds The Bitmap Temporarily
	IPicture	*pPicture;												// IPicture Interface
	OLECHAR		wszPath[MAX_PATH + 1];									// Full Path To Picture (WCHAR)
	long		lWidth;													// Width In Logical Units
	long		lHeight;												// Height In Logical Units
	long		lWidthPixels;											// Width In Pixels
	long		lHeightPixels;											// Height In Pixels
	HRESULT     hr;
	short		sType;
	DWORD		dwAttributes;
	
	//----------------------------------------------------------------------------------------
	// Convert From ASCII To Unicode and load the picture path
	//----------------------------------------------------------------------------------------
	MultiByteToWideChar(CP_ACP, 0, szFilename, -1, wszPath, MAX_PATH);	
	hr = OleLoadPicturePath(wszPath, 0, 0, 0, IID_IPicture, (void**)&pPicture);
	
	if(FAILED(hr))	
	{
		return FALSE;													
	}
	hdcTemp = CreateCompatibleDC(GetDC(0));								
	if(!hdcTemp)														
	{
		pPicture->Release();											
		return FALSE;													
	}
	
	//----------------------------------------------------------------------------------------
	// get the pixel dimensions of the image
	//----------------------------------------------------------------------------------------
	pPicture->get_Attributes(&dwAttributes);
	pPicture->get_Type(&sType);
	pPicture->get_Width(&lWidth);									
	lWidthPixels	= MulDiv(lWidth, GetDeviceCaps(hdcTemp, LOGPIXELSX), 2540);
	pPicture->get_Height(&lHeight);									
	lHeightPixels	= MulDiv(lHeight, GetDeviceCaps(hdcTemp, LOGPIXELSY), 2540);

	//----------------------------------------------------------------------------------------
	//	Create A Temporary Bitmap
	//----------------------------------------------------------------------------------------
	BITMAPINFO		bi = {0};												// The Type Of Bitmap We Request
	unsigned int*	pBits = NULL;												// Pointer To The Bitmap Bits
	
	bi.bmiHeader.biSize			= sizeof(BITMAPINFOHEADER);				// Set Structure Size
	bi.bmiHeader.biBitCount		= 32;									// 32 Bit
	bi.bmiHeader.biWidth		= lWidthPixels;							// Power Of Two Width
	bi.bmiHeader.biHeight		= lHeightPixels;						// Make Image Top Up (Positive Y-Axis)
	bi.bmiHeader.biCompression	= BI_RGB;								// RGB Encoding
	bi.bmiHeader.biPlanes		= 1;									// 1 Bitplane
	hbmpTemp = CreateDIBSection(hdcTemp, &bi, DIB_RGB_COLORS, (void**)&pBits, 0, 0);
	
	if(!hbmpTemp)														// Did Creation Fail?
	{
		DeleteDC(hdcTemp);												// Delete The Device Context
		pPicture->Release();											// Decrements IPicture Reference Count
		return FALSE;													// Return False (Failure)
	}

	SelectObject(hdcTemp, hbmpTemp);									// Select Handle To Our Temp DC And Our Temp Bitmap Object

	//----------------------------------------------------------------------------------------
	// Render The IPicture On To The Bitmap
	//----------------------------------------------------------------------------------------
	pPicture->Render(hdcTemp, 0, 0, lWidthPixels, lHeightPixels, 0, lHeight, lWidth, -lHeight, 0);

	//----------------------------------------------------------------------------------------
	// Copy the pixels to our texture descriptor whilst
	// Converting from BGR To RGB format and adding alpha of 255
	//----------------------------------------------------------------------------------------
	int							x, y;
	unsigned int				iAlpha;
	BOOL						bNonZeroAlpha;
	CImage						cImageImport;
	int							i;
	CImageCopier				cCopier;

	bNonZeroAlpha = FALSE;
	for (y = 0; y < lHeightPixels; y++)
	{
		for (x = 0; x < lWidthPixels; x++)
		{
			unsigned int iPixel = pBits[(x + (lHeightPixels - y - 1) * lWidthPixels)];
			iAlpha = iPixel & 0xff000000;
//.........这里部分代码省略.........
开发者ID:andrewpaterson,项目名称:Codaphela.Library,代码行数:101,代码来源:ImageReader.cpp

示例9: BuildTexture

//////////////////////////////////////////////////////////////////////////
//函数:BuildTexture()
//参数:szPathName纹理路径,纹理ID
//功能:加载纹理
//////////////////////////////////////////////////////////////////////////
bool Menu::BuildTexture(char *szPathName, GLuint &texid)
{
	HDC      hdcTemp;                        // The DC To Hold Our Bitmap
	HBITMAP    hbmpTemp;                        // Holds The Bitmap Temporarily
	IPicture  *pPicture;                        // IPicture Interface
	OLECHAR    wszPath[MAX_PATH+1];                  // Full Path To Picture (WCHAR)
	char    szPath[MAX_PATH+1];                    // Full Path To Picture
	long    lWidth;                          // Width In Logical Units
	long    lHeight;                        // Height In Logical Units
	long    lWidthPixels;                      // Width In Pixels
	long    lHeightPixels;                      // Height In Pixels
	GLint    glMaxTexDim ;                      // Holds Maximum Texture Size
	
	if (strstr(szPathName, "http://"))                  // If PathName Contains http:// Then...
	{
		strcpy(szPath, szPathName);                    // Append The PathName To szPath
	}
	else                                // Otherwise... We Are Loading From A File
	{
		GetCurrentDirectory(MAX_PATH, szPath);              // Get Our Working Directory
		strcat(szPath, "\\Image\\"); 
		//strcat(szPath, "\\");                      // Append "\" After The Working Directory
		
		strcat(szPath, szPathName);                    // Append The PathName
	}
	
	MultiByteToWideChar(CP_ACP, 0, szPath, -1, wszPath, MAX_PATH);    // Convert From ASCII To Unicode
	HRESULT hr = OleLoadPicturePath(wszPath, 0, 0, 0, IID_IPicture, (void**)&pPicture);
	
	if(FAILED(hr))                            // If Loading Failed
		return FALSE;                          // Return False
	HDC tempDC=GetDC(0);
	hdcTemp = CreateCompatibleDC(tempDC);                // Create The Windows Compatible Device Context
	if(!hdcTemp)                            // Did Creation Fail?
	{
		pPicture->Release();                      // Decrements IPicture Reference Count
		return FALSE;                          // Return False (Failure)
	}
	ReleaseDC(NULL,tempDC);
	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glMaxTexDim);          // Get Maximum Texture Size Supported
	
	pPicture->get_Width(&lWidth);                    // Get IPicture Width (Convert To Pixels)
	lWidthPixels  = MulDiv(lWidth, GetDeviceCaps(hdcTemp, LOGPIXELSX), 2540);
	pPicture->get_Height(&lHeight);                    // Get IPicture Height (Convert To Pixels)
	lHeightPixels  = MulDiv(lHeight, GetDeviceCaps(hdcTemp, LOGPIXELSY), 2540);
	
	// Resize Image To Closest Power Of Two
	if (lWidthPixels <= glMaxTexDim) // Is Image Width Less Than Or Equal To Cards Limit
		lWidthPixels = 1 << (int)floor((log((double)lWidthPixels)/log(2.0f)) + 0.5f); 
	else // Otherwise Set Width To "Max Power Of Two" That The Card Can Handle
		lWidthPixels = glMaxTexDim;
	
	if (lHeightPixels <= glMaxTexDim) // Is Image Height Greater Than Cards Limit
		lHeightPixels = 1 << (int)floor((log((double)lHeightPixels)/log(2.0f)) + 0.5f);
	else // Otherwise Set Height To "Max Power Of Two" That The Card Can Handle
		lHeightPixels = glMaxTexDim;
	
	//  Create A Temporary Bitmap
	BITMAPINFO  bi = {0};                        // The Type Of Bitmap We Request
	DWORD    *pBits = 0;                        // Pointer To The Bitmap Bits
	
	bi.bmiHeader.biSize      = sizeof(BITMAPINFOHEADER);        // Set Structure Size
	bi.bmiHeader.biBitCount    = 32;                  // 32 Bit
	bi.bmiHeader.biWidth    = lWidthPixels;              // Power Of Two Width
	bi.bmiHeader.biHeight    = lHeightPixels;            // Make Image Top Up (Positive Y-Axis)
	bi.bmiHeader.biCompression  = BI_RGB;                // RGB Encoding
	bi.bmiHeader.biPlanes    = 1;                  // 1 Bitplane
	
	//  Creating A Bitmap This Way Allows Us To Specify Color Depth And Gives Us Imediate Access To The Bits
	hbmpTemp = CreateDIBSection(hdcTemp, &bi, DIB_RGB_COLORS, (void**)&pBits, 0, 0);
	
	if(!hbmpTemp)                            // Did Creation Fail?
	{
		DeleteDC(hdcTemp);                        // Delete The Device Context
		pPicture->Release();                      // Decrements IPicture Reference Count
		return FALSE;                          // Return False (Failure)
	}
	
	HGDIOBJ old;
	old=SelectObject(hdcTemp, hbmpTemp);                  // Select Handle To Our Temp DC And Our Temp Bitmap Object
	
	// Render The IPicture On To The Bitmap
	pPicture->Render(hdcTemp, 0, 0, lWidthPixels, lHeightPixels, 0, lHeight, lWidth, -lHeight, 0);
	
	// Convert From BGR To RGB Format And Add An Alpha Value Of 255
	for(long i = 0; i < lWidthPixels * lHeightPixels; i++)        // Loop Through All Of The Pixels
	{
		BYTE* pPixel  = (BYTE*)(&pBits[i]);              // Grab The Current Pixel
		BYTE temp    = pPixel[0];                  // Store 1st Color In Temp Variable (Blue)
		pPixel[0]    = pPixel[2];                  // Move Red Value To Correct Position (1st)
		pPixel[2]    = temp;                      // Move Temp Value To Correct Blue Position (3rd)
		
		// This Will Make Any Black Pixels, Completely Transparent    (You Can Hardcode The Value If You Wish)
		if ((pPixel[0]==0) && (pPixel[1]==0) && (pPixel[2]==0))      // Is Pixel Completely Black
			pPixel[3]  = 0;                      // Set The Alpha Value To 0
//.........这里部分代码省略.........
开发者ID:fanzhidongyzby,项目名称:ManorRover,代码行数:101,代码来源:Menu.cpp

示例10: OnProceVideo

LRESULT CVideoRecvTestDlg::OnProceVideo(WPARAM wParam, LPARAM lParam)
{
	if(lParam == NULL) 
	{
		return E_FAIL;
	}
	VideoFrameData* TmpVideo = (VideoFrameData*)lParam;
	switch(TmpVideo->dwVideoType)
	{
	case VIDEO_TYPE_H264_NORMAL_I:
	case VIDEO_TYPE_H264_NORMAL_P:
		{
			CString strMsg;
			strMsg.Format("DataLen = %d, ExtInfo = %s",
			TmpVideo->dwVideoDataLen, TmpVideo->pszVideoExInfo);
			HDC TempDC = ::GetDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd());
			SetBkMode(TempDC, 3);
			SetTextColor(TempDC, RGB(0, 128, 0));
			Rectangle(TempDC, 10, 20, 700, 80);
			TextOut(TempDC, 20, 20, "H264CallBack FrameInfo:", 23);
			int ilen = strMsg.GetLength();
			CString str1 = strMsg.Left(60);
			CString str2 = strMsg.Right(ilen - 60);
			TextOut(TempDC, 20, 40, str1.GetBuffer(), str1.GetLength());
			TextOut(TempDC, 20, 60, str2.GetBuffer(), str2.GetLength());
			//TextOut(TempDC, 20, 40, strMsg.GetBuffer(), strMsg.GetLength());
			::ReleaseDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd(), TempDC);
		}
		break;
	case VIDEO_TYPE_H264_HISTORY_I:
	case VIDEO_TYPE_H264_HISTORY_P:
		{
			CString strMsg;
			strMsg.Format("DataLen = %d, ExtInfo = %s",
				TmpVideo->dwVideoDataLen, TmpVideo->pszVideoExInfo);
			HDC TempDC = ::GetDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd());
			SetBkMode(TempDC, 3);
			SetTextColor(TempDC, RGB(0, 128, 0));
			Rectangle(TempDC, 10, 20, 700, 100);
			TextOut(TempDC, 20, 20, "H264CallBack FrameInfo:", 23);
			int ilen = strMsg.GetLength();
			CString str1 = strMsg.Left(60);
			CString str2 = strMsg.Right(ilen - 60);
			TextOut(TempDC, 20, 40, str1.GetBuffer(), str1.GetLength());
			TextOut(TempDC, 20, 60, str2.GetBuffer(), str2.GetLength());
			//TextOut(TempDC, 20, 40, strMsg.GetBuffer(), strMsg.GetLength());

			char* pszTime = strstr(TmpVideo->pszVideoExInfo, "FrameTime:");
			DWORD64 dw64TimeMS = 0;
			if(pszTime)
			{
				sscanf(pszTime, "FrameTime:%I64u", &dw64TimeMS);
				CTime cFrameTime(dw64TimeMS/1000);
				strMsg = cFrameTime.Format("%Y.%m.%d_%H:%M:%S");
				TextOut(TempDC, 400, 60, strMsg.GetBuffer(), strMsg.GetLength());
			}
			::ReleaseDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd(), TempDC);
			if(((dw64TimeMS/1000) >= m_dwEndTime)&&m_realfinish == false)
			{
				::SendMessage(GetSafeHwnd(), WM_MESSAGE_GETFINISH, 0, 0);
			}
		}
		break;
	case VIDEO_TYPE_JPEG_HISTORY:
		{
			IStream* pStm = NULL;
			CreateStreamOnHGlobal(NULL, TRUE, &pStm);
			IPicture* picholder;
			LARGE_INTEGER liTempStar = {0};
			pStm->Seek(liTempStar, STREAM_SEEK_SET, NULL);
			ULONG iWritten = NULL;
			pStm->Write(TmpVideo->pVideoData, TmpVideo->dwVideoDataLen, &iWritten);
			pStm->Seek(liTempStar, STREAM_SEEK_SET, NULL);
			if(FAILED(OleLoadPicture(pStm, TmpVideo->dwVideoDataLen, TRUE, IID_IPicture, (void**)&picholder)))
			{
				pStm->Release();
				return 0;
			}

			HDC TempDC;
			TempDC = ::GetDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd());
			OLE_XSIZE_HIMETRIC hmWidth;
			OLE_YSIZE_HIMETRIC hmHeight;
			picholder->get_Width(&hmWidth);
			picholder->get_Height(&hmHeight);
			int nWidth =MulDiv(hmWidth, GetDeviceCaps(TempDC, LOGPIXELSX), 2540);
			int nHeight = MulDiv(hmHeight, GetDeviceCaps(TempDC, LOGPIXELSY), 2540);
			picholder->Render(TempDC, 0, 0, m_ShowFrameRect.right-m_ShowFrameRect.left,
				m_ShowFrameRect.bottom-m_ShowFrameRect.top,
				0, hmHeight, hmWidth, -hmHeight, NULL);
			::ReleaseDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd(), TempDC);
			picholder->Release();
			pStm->Release();

			CString strMsg;
			strMsg.Format("DataLen = %d, ExtInfo = %s",
				TmpVideo->dwVideoDataLen, TmpVideo->pszVideoExInfo);
			TempDC = ::GetDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd());
			SetBkMode(TempDC, 3);
			SetTextColor(TempDC, RGB(0, 128, 0));
//.........这里部分代码省略.........
开发者ID:fangbaolei,项目名称:EC700IR,代码行数:101,代码来源:VideoRecvTestDlg.cpp

示例11: ConnectThread


//.........这里部分代码省略.........
			//(pEnconn->m_RichEdit)->SetSel(-1,-1);
			//(pEnconn->m_RichEdit)->ReplaceSel(_T("AAC Data\n"),0);
			//printf("Recv AAC Data\n");
			if(pEnconn->saveStream==1)
			{
				if(pEnconn->Enctype==1)//ENC1200
				pEnconn->AacFile.Write((char*)pEnconn->m_cVideoBuffer+sizeof(FRAMEHEAD),nDataLen-sizeof(FRAMEHEAD));
				else
				pEnconn->AacFile.Write((char*)pEnconn->m_cVideoBuffer+1+sizeof(DataHeader),nDataLen-1-sizeof(DataHeader));
			}
			break;
		case MSG_SYSPARAMS:
			
			printf("Recv MSG_SYSPARAMS \n");
			break;
		case MSG_TRACKAUTO:
			
			printf("Recv MSG_TRACKAUTO \n");
			break;
		case MSG_DATAINFO:
			
			printf("Recv MSG_DATAINFO \n");
			break;	
		case MSG_LOW_BITRATE:
			
			printf("Recv LowStream ok \n");
			break;
		case  MSG_LOW_SCREENDATA:			
			printf("Recv LowStream Data\n");
			break;
		case MSG_PIC_DATA:					
			//memcpy(&nDataLen, &pEnconn->m_cVideoBuffer[1],sizeof(nDataLen));
			memcpy(&nDataLen, (char*)pEnconn->m_cVideoBuffer+1,sizeof(nDataLen));
			printf("PPT索引图片=%d 字节\n", nDataLen);
			//hMem = ::GlobalAlloc(GMEM_MOVEABLE,nDataLen);
			//lpBuf = ::GlobalLock(hMem);
			rcvLen = pEnconn->Recv((char*)pEnconn->m_cVideoBuffer+4, nDataLen);
			finename.Format(_T("%d.jpg"),pptindex);
			if (!(pEnconn->JpgFile.Open(finename,CFile::modeCreate | CFile::modeWrite)))
			{
				printf("open jpegFile fail! \n");
				pptindex++;
				break;
			}
			pEnconn->JpgFile.Write((char*)pEnconn->m_cVideoBuffer+4,nDataLen);
			pEnconn->JpgFile.Close();
			pptindex++;
			hMem = ::GlobalAlloc(GMEM_MOVEABLE,nDataLen);
			lpBuf = ::GlobalLock(hMem);
			memcpy(lpBuf,(char*)pEnconn->m_cVideoBuffer+4,nDataLen);
			::GlobalUnlock(hMem);
			::CreateStreamOnHGlobal(hMem, TRUE, &pStm); //装入图形文件	
			if(SUCCEEDED(OleLoadPicture(pStm,nDataLen,TRUE,IID_IPicture,(LPVOID*)&pPic)))
			{
					
				OLE_XSIZE_HIMETRIC hmWidth;
				OLE_YSIZE_HIMETRIC hmHeight;
				pPic->get_Width(&hmWidth); //用接口方法获得图片的宽和高
				pPic->get_Height(&hmHeight);				
				printf("PPTJPEG=%d=%d\n",hmWidth,hmHeight);
				//获取桌面窗口句柄
				hwnd = ::GetDesktopWindow();
				//获取桌面窗口DC
				hdc = ::GetWindowDC(hwnd);				
				CRect rect;
				CDC *pDC=CDC::FromHandle(hdc);
				//////显示原图大小/////////////////////////////////////////////////////////////
				CSize sz(hmWidth,hmHeight);
				pDC->HIMETRICtoDP(&sz); //转换MM_HIMETRIC模式单位为MM_TEXT像素单位			
				pPic->Render(hdc,80,80,sz.cx,sz.cy,0,hmHeight,hmWidth,-hmHeight,NULL);
				//按窗口尺寸显示///////////////////						  
				GetClientRect(hwnd,&rect);
				if(pPic) pPic->Release();					
				::ReleaseDC(hwnd, hdc);
				
			}				
			pStm->Release();  

			printf("Recv PPT Data\n");
			break;
		case MSG_GET_LOGOINFO:	
			printf("Recv MSG_GET_LOGOINFO \n");
			break;
		case MSG_PIC_DATAEX:	
			printf("Recv MSG_PIC_DATAEX \n");
			recvedlen=0;			
			break;
		default:
	
			break;
		}
		
	}

Exit:	
	pEnconn->Connflag=0;
	pEnconn->PostMessage(RM_DISCONN,NULL);
	return 1;

}
开发者ID:duhao,项目名称:Manager,代码行数:101,代码来源:Enconn.cpp

示例12: OnProceVideo


//.........这里部分代码省略.........
				iRedLightCount, iRedLightBufPosLen, pRedLightPosBuf, pJPEGPos, dwJPEGDataLen) != S_OK)
			{
				return E_FAIL;
			}
			if(pJPEGPos == NULL || dwJPEGDataLen <= 0)
			{
				return E_FAIL;
			}

			int iEnhanceBufLen = 0;
			PBYTE pEnhanceBuf = NULL;
			if(m_iRedLightEnhanceFlag == 1)
			{
				iEnhanceBufLen = (1024 << 10);
				pEnhanceBuf = new BYTE[iEnhanceBufLen];
				if(pEnhanceBuf)
				{
					if(HVAPIUTILS_TrafficLightEnhance(pJPEGPos, dwJPEGDataLen, iRedLightCount,
						pRedLightPosBuf, pEnhanceBuf, iEnhanceBufLen, m_iBrightness,
						m_iHueThreshold, m_CompressRate) != S_OK)
					{
						delete[] pEnhanceBuf;
						pEnhanceBuf = NULL;
						iEnhanceBufLen = 0;
					}
				}
			}

			IStream* pStm = NULL;
			CreateStreamOnHGlobal(NULL, TRUE, &pStm);
			IPicture* picholder;
			LARGE_INTEGER liTempStar = {0};
			pStm->Seek(liTempStar, STREAM_SEEK_SET, NULL);
			ULONG iWritten = NULL;
			if(pEnhanceBuf)
			pStm->Write(pEnhanceBuf, iEnhanceBufLen, &iWritten);
			else
			pStm->Write(pJPEGPos, dwJPEGDataLen, &iWritten);
			pStm->Seek(liTempStar, STREAM_SEEK_SET, NULL);
			if(pEnhanceBuf)
			{
				if(FAILED(OleLoadPicture(pStm, iEnhanceBufLen, TRUE, IID_IPicture, (void**)&picholder)))
				{
					pStm->Release();
					return E_FAIL;
				}
			}
			else
			{
				if(FAILED(OleLoadPicture(pStm, dwJPEGDataLen, TRUE, IID_IPicture, (void**)&picholder)))
				{
					pStm->Release();
					return E_FAIL;
				}
			}

			HDC TempDC;
			TempDC = ::GetDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd());
			OLE_XSIZE_HIMETRIC hmWidth;
			OLE_YSIZE_HIMETRIC hmHeight;
			picholder->get_Width(&hmWidth);
			picholder->get_Height(&hmHeight);
			int nWidth =MulDiv(hmWidth, GetDeviceCaps(TempDC, LOGPIXELSX), 2540);
			int nHeight = MulDiv(hmHeight, GetDeviceCaps(TempDC, LOGPIXELSY), 2540);
			picholder->Render(TempDC, 0, 0, m_ShowFrameRect.right-m_ShowFrameRect.left,
				m_ShowFrameRect.bottom-m_ShowFrameRect.top,
				0, hmHeight, hmWidth, -hmHeight, NULL);
			::ReleaseDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd(), TempDC);
			picholder->Release();
			pStm->Release();

			CString strMsg;
			strMsg.Format("DataLen = %d, ExtInfo = %s",
				TmpVideo->dwVideoDataLen, TmpVideo->pszVideoExInfo);
			TempDC = ::GetDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd());
			SetBkMode(TempDC, 3);
			SetTextColor(TempDC, RGB(0, 128, 0));
			Rectangle(TempDC, 10, 220, 700, 280);
			TextOut(TempDC, 20, 220, "HistoryVideoCallback JPEG FrameInfo:", 23);
			TextOut(TempDC, 20, 240, strMsg.GetBuffer(), strMsg.GetLength());
			char* pszTime = strstr(TmpVideo->pszVideoExInfo, "FrameTime:");
			DWORD64 dw64TimeMS = 0;
			if(pszTime)
			{
				sscanf(pszTime, "FrameTime:%I64u", &dw64TimeMS);
			}
			CTime cFrameTime(dw64TimeMS/1000);
			strMsg = cFrameTime.Format("%Y.%m.%d_%H:%M:%S");
			TextOut(TempDC, 20, 260, strMsg.GetBuffer(), strMsg.GetLength());
			::ReleaseDC(GetDlgItem(IDC_STATIC_VIDEO)->GetSafeHwnd(), TempDC);
			SetWindowText(strMsg.GetBuffer());
			if((dw64TimeMS/1000) >= m_dwEndTime)
			{
				::SendMessage(GetSafeHwnd(), WM_MESSAGE_GETFINISH, 0, 0);
			}
		}
		break;
	}
	return S_OK;
}
开发者ID:fangbaolei,项目名称:EC700IR,代码行数:101,代码来源:OldVideoRecvTestDlg.cpp

示例13: ConvertWMFtoPNGA

__declspec(dllexport) bool ConvertWMFtoPNGA(char *bwmfName, char *bpngName, bool eraseTransparenz)
{
	FILE 
      *wmfFile,
      *pngFile;
	HGLOBAL 
      hGlobal;
	DWORD 
      dwSize;
   IPicture 
      *image;
   int
      width, height;
   long 
      hmWidth, hmHeight;
   BYTE 
      *p1,
      *p2;
   int 
      x, 
      y;

	if (!(wmfFile = fopen(wmfName,"rb")))
		return false;

	fseek(wmfFile, 0, SEEK_END);
	dwSize = ftell(wmfFile);
	fseek(wmfFile, 0, SEEK_SET);

	hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD, dwSize);
	if (!hGlobal)
	{
		fclose(wmfFile);
		return false;
	}
	
	char *pData = reinterpret_cast<char*>(GlobalLock(hGlobal));
	if (!pData)
	{
		GlobalFree(hGlobal);
		fclose(wmfFile);
		return false;
	}

	if (fread(pData,1,dwSize,wmfFile) != dwSize)
	{
		GlobalFree(hGlobal);
		fclose(wmfFile);
		return false;
	}

	GlobalUnlock(hGlobal);
	fclose(wmfFile);

	IStream *pStream = NULL;

	if (CreateStreamOnHGlobal(hGlobal,TRUE,&pStream) != S_OK)
		return false;

	if (OleLoadPicture(pStream,dwSize,false,IID_IPicture,
		reinterpret_cast<LPVOID *>(&image)) != S_OK)
	{
		pStream->Release();
		return false;
	}

	pStream->Release();

	GlobalFree(hGlobal);
   
   image->get_Width(&hmWidth);
   image->get_Height(&hmHeight);

   width  = MulDiv(hmWidth, 96, 2540);
   height = MulDiv(hmHeight, 96, 2540);

   BITMAPINFO *bitmapInfo = (BITMAPINFO *)NULL;

   bitmapInfo = (BITMAPINFO *)LocalAlloc(LMEM_FIXED|LMEM_ZEROINIT, sizeof(BITMAPINFO) ); 
   bitmapInfo->bmiHeader.biSize          = sizeof(BITMAPINFOHEADER);
   bitmapInfo->bmiHeader.biWidth         = width;
   bitmapInfo->bmiHeader.biHeight        = height;
   bitmapInfo->bmiHeader.biPlanes        = 1;
   bitmapInfo->bmiHeader.biBitCount      = 32;
   bitmapInfo->bmiHeader.biCompression   = BI_RGB;
   bitmapInfo->bmiHeader.biSizeImage     = width * height * 4;

   PBYTE bitmapData1; 
   HDC myHdc1 =  CreateCompatibleDC(NULL);
   HBITMAP bitmap1 = CreateDIBSection(myHdc1, bitmapInfo, DIB_RGB_COLORS, (PVOID *) &bitmapData1, NULL, 0);
   SetStretchBltMode(myHdc1, HALFTONE);
   SelectObject(myHdc1, bitmap1); 
   memset(bitmapData1, 0x00ffffff, 4 * width * height);

   PBYTE bitmapData2; 
   HDC myHdc2 =  CreateCompatibleDC(NULL);
   SetStretchBltMode(myHdc2, HALFTONE);
   HBITMAP bitmap2 = CreateDIBSection(myHdc2, bitmapInfo, DIB_RGB_COLORS, (PVOID *) &bitmapData2, NULL, 0);
   SelectObject(myHdc2, bitmap2); 
   memset(bitmapData2, 0x00000000, 4 * width * height);
//.........这里部分代码省略.........
开发者ID:identity0815,项目名称:os45,代码行数:101,代码来源:ppt2lecturnity.c

示例14: LoadImageFromFile

// load an image from file. The supported filetypes depend on the plattform
bool LoadImageFromFile(const char *filename, CByteImage *pImage)
{
	HDC			hdcTemp;												// The DC To Hold Our Bitmap
	HBITMAP		hbmpTemp;												// Holds The Bitmap Temporarily
	IPicture	*pPicture;												// IPicture Interface
	OLECHAR		wszPath[MAX_PATH+1];									// Full Path To Picture (WCHAR)
	long		lWidth;													// Width In Logical Units
	long		lHeight;												// Height In Logical Units
	long		lWidthPixels;											// Width In Pixels
	long		lHeightPixels;											// Height In Pixels

	MultiByteToWideChar(CP_ACP, 0, filename, -1, wszPath, MAX_PATH);	// Convert From ASCII To Unicode
	HRESULT hr = OleLoadPicturePath(wszPath, 0, 0, 0, IID_IPicture, (void**)&pPicture);

	if(FAILED(hr))														// If Loading Failed
		return false;													// Return False

	hdcTemp = CreateCompatibleDC(GetDC(0));								// Create The Windows Compatible Device Context
	if(!hdcTemp)														// Did Creation Fail?
	{
		pPicture->Release();											// Decrements IPicture Reference Count
		return false;													// Return False (Failure)
	}
	
	pPicture->get_Width(&lWidth);										// Get IPicture Width (Convert To Pixels)
	lWidthPixels	= MulDiv(lWidth, GetDeviceCaps(hdcTemp, LOGPIXELSX), 2540);
	pPicture->get_Height(&lHeight);										// Get IPicture Height (Convert To Pixels)
	lHeightPixels	= MulDiv(lHeight, GetDeviceCaps(hdcTemp, LOGPIXELSY), 2540);
	
	//	Create A Temporary Bitmap
	BITMAPINFO	bi = {0};												// The Type Of Bitmap We Request
	DWORD		*pBits = 0;												// Pointer To The Bitmap Bits

	bi.bmiHeader.biSize			= sizeof(BITMAPINFOHEADER);				// Set Structure Size
	bi.bmiHeader.biBitCount		= 32;									// 32 Bit
	bi.bmiHeader.biWidth		= lWidthPixels;							// Power Of Two Width
	bi.bmiHeader.biHeight		= lHeightPixels;						// Make Image Top Up (Positive Y-Axis)
	bi.bmiHeader.biCompression	= BI_RGB;								// RGB Encoding
	bi.bmiHeader.biPlanes		= 1;									// 1 Bitplane

	//	Creating A Bitmap This Way Allows Us To Specify Color Depth And Gives Us Imediate Access To The Bits
	hbmpTemp = CreateDIBSection(hdcTemp, &bi, DIB_RGB_COLORS, (void**)&pBits, 0, 0);
	
	if(!hbmpTemp)														// Did Creation Fail?
	{
		DeleteDC(hdcTemp);												// Delete The Device Context
		pPicture->Release();											// Decrements IPicture Reference Count
		return false;													// Return False (Failure)
	}

	SelectObject(hdcTemp, hbmpTemp);									// Select Handle To Our Temp DC And Our Temp Bitmap Object

	// Render The IPicture On To The Bitmap
	pPicture->Render(hdcTemp, 0, 0, lWidthPixels, lHeightPixels, 0, 0, lWidth, lHeight, 0);

	
	if (pImage->m_bOwnMemory)
		delete [] pImage->pixels;
	
	pImage->width = lWidthPixels;
	pImage->height = lHeightPixels;
	pImage->bytesPerPixel = 3;
	pImage->type = CByteImage::eRGB24;
	pImage->pixels = new unsigned char[pImage->bytesPerPixel * lWidthPixels*lHeightPixels];
	pImage->m_bOwnMemory = true;

	unsigned char *output = pImage->pixels;

	// Convert From BGR To RGB Format And Add An Alpha Value Of 255
	for(long i = 0; i < lWidthPixels * lHeightPixels; i++)				// Loop Through All Of The Pixels
	{
		BYTE* pPixel	= (BYTE*)(&pBits[i]);							// Grab The Current Pixel
		output[3*i]		= pPixel[2];									// Store 1st Color In Temp Variable (Blue)
		output[3*i + 1]	= pPixel[1];									// Move Red Value To Correct Position (1st)
		output[3*i + 2]	= pPixel[0];									// Move Temp Value To Correct Blue Position (3rd)
	}

	DeleteObject(hbmpTemp);												// Delete The Object
	DeleteDC(hdcTemp);													// Delete The Device Context

	pPicture->Release();												// Decrements IPicture Reference Count

	return true;
}
开发者ID:junaidnaseer,项目名称:ivt,代码行数:85,代码来源:GUIFactory.cpp

示例15: PaintImage

bool CPlugin::PaintImage(HDC hPaintDC)
{
	if (!m_hImageMemory)
		return false;

	// Create an IStream from the file in memory
	IStream* pStreamIn = NULL;
	HRESULT hr = ::CreateStreamOnHGlobal(m_hImageMemory, false/*fDeleteOnRelease*/, &pStreamIn);
	if (FAILED(hr) || !pStreamIn)
		return false;

	// Create an IPicture from the IStream; the function opens JPEG's, BMP's, GIF's, WMF's, EMF's, and ICO's!!
	DWORD dwSize = ::GlobalSize(m_hImageMemory);
	IPicture* pPicture = NULL;
	hr = ::OleLoadPicture(pStreamIn, dwSize, false, IID_IPicture, (void**)&pPicture);

	// Either way we are done with the IStream and the memory
	pStreamIn->Release();

	if (FAILED(hr) || !pPicture)
		return false;

	// Get the screen dimensions for the HIMETRIC conversion
	HDC hDC = ::CreateIC("DISPLAY", NULL, NULL, NULL);
	long lResolutionX = GetDeviceCaps(hDC, LOGPIXELSX);
	long lResolutionY = GetDeviceCaps(hDC, LOGPIXELSY);
	::DeleteDC(hDC);

	// Get width and height of the picture
	#define HIMETRIC_INCH 2540

	long hmWidth = 0;
	hr = pPicture->get_Width(&hmWidth);
	int bmWidth	= ::MulDiv(hmWidth, lResolutionX, HIMETRIC_INCH);

	long hmHeight = 0;
	hr = pPicture->get_Height(&hmHeight);
	int bmHeight	= ::MulDiv(hmHeight, lResolutionY, HIMETRIC_INCH);

	RECT rect;
	::GetClientRect(m_hWnd, &rect);
	m_HotRect.left   = ((rect.right - rect.left) - bmWidth) / 2;
	m_HotRect.top    = ((rect.bottom - rect.top) - bmHeight) / 2;
	m_HotRect.right  = m_HotRect.left + bmWidth;
	m_HotRect.bottom = m_HotRect.top + bmHeight;

	// Render the picture into the DC
	hr = pPicture->Render(
		hPaintDC,		// HDC the device context on which to render the image
		m_HotRect.left,	// long left position of destination in HDC
		m_HotRect.top,	// long top position of destination in HDC
		bmWidth,		// long width of destination in HDC
		bmHeight,		// long height of destination in HDC
		0,				// OLE_XPOS_HIMETRIC left position in source picture
		hmHeight,		// OLE_YPOS_HIMETRIC top position in source picture
		hmWidth,		// OLE_XSIZE_HIMETRIC width in source picture
		-hmHeight,		// OLE_YSIZE_HIMETRIC height in source picture
		NULL			// LPCRECT pointer to destination for a metafile hdc
	);

	pPicture->Release();
	return SUCCEEDED(hr);
}
开发者ID:jimmccurdy,项目名称:ArchiveGit,代码行数:63,代码来源:Plugin.cpp


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