예제 #1
0
파일: Util.cpp 프로젝트: kimoto/mwheel_plus
BOOL LoadBitmapToDC(LPTSTR szFileName, int x, int y, HDC hdc)
{
	HBITMAP hBitmap2, hOldBitmap2;
	HPALETTE hPalette2, hOldPalette2;
	HDC hMemDC;
	BITMAP bm;

	if( LoadBitmapFromBMPFile(szFileName, &hBitmap2, &hPalette2) )
	{
		::GetObject(hBitmap2, sizeof(BITMAP), &bm);
		hMemDC = ::CreateCompatibleDC(hdc);
		hOldBitmap2 = (HBITMAP)::SelectObject(hMemDC, hBitmap2);
		hOldPalette2 = ::SelectPalette(hdc, hPalette2, FALSE);
		::RealizePalette(hdc);
			
		::BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight,
			hMemDC, 0, 0, SRCAND);

		::SelectObject(hMemDC, hOldBitmap2);
		::DeleteObject(hBitmap2);

		::SelectPalette(hdc, hOldPalette2, FALSE);
		::DeleteObject(hPalette2);
		return TRUE;
	}else{
		::OutputDebugString(L"error loading bitmap\n");
		return FALSE;
	}
}
예제 #2
0
BOOL CImage::Load(CString sFileName)
{
    Destroy();

    FILE* f = NULL;
    _TFOPEN_S(f, sFileName.GetBuffer(0), _T("rb"));
    if(f==NULL)
        return FALSE;
    if(IsBitmap(f))
    {
        fclose(f);
        return LoadBitmapFromBMPFile(sFileName.GetBuffer(0));
    }
    else if(IsPNG(f))
    {
        fclose(f);
        return LoadBitmapFromPNGFile(sFileName.GetBuffer(0));
    }
    else if(IsJPEG(f))
    {
        fclose(f);
        return LoadBitmapFromJPEGFile(sFileName.GetBuffer(0));
    }

    fclose(f);
    return FALSE;
}
예제 #3
0
void CODStaticImageImpl::DrawItem (LPDRAWITEMSTRUCT lpdis)
{
	if (!m_szImagePath.IsEmpty())
	{
		RECT rcClient;
		GetClientRect(&rcClient);
		CDCHandle dc = lpdis->hDC;
		dc.SaveDC();

		HBITMAP       hBitmap, hOldBitmap;
		HPALETTE      hPalette, hOldPalette;
		BITMAP        bm;
		if( LoadBitmapFromBMPFile( m_szImagePath.LockBuffer(), &hBitmap, &hPalette ) )
		{
			GetObject(hBitmap, sizeof(BITMAP), &bm);
			HDC hMemDC = CreateCompatibleDC(dc.m_hDC);
			hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
			hOldPalette = dc.SelectPalette(hPalette, FALSE);
			dc.RealizePalette();

			dc.StretchBlt(rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,\
				hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY );

			SelectObject(hMemDC, hOldBitmap);
			DeleteObject(hBitmap);
			dc.SelectPalette(hOldPalette, FALSE);
			DeleteObject(hPalette);
		}
		m_szImagePath.UnlockBuffer();

		dc.RestoreDC(-1);
	}
	else if (m_nBitmapId > 0)
	{
		RECT rcClient;
		GetClientRect(&rcClient);
		CDCHandle dc = lpdis->hDC;
		dc.SaveDC();

		CBitmap bitmap;
		_U_STRINGorID id (m_nBitmapId);
		bitmap.LoadBitmap(id);

		CMemDC memDC(dc, &rcClient);

		memDC.SelectBitmap(bitmap.m_hBitmap);

		dc.RestoreDC(-1);
	}

	return;
}
예제 #4
0
BOOL CID3v2Page3::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// Translations
	SetWindowText( theApp.Translate( "ID3v2Page3", "Caption" ) );
	SetDlgItemText( IDC_BUTTON_SELECT , theApp.Translate( "ID3v2Page3", "Item1" ) );
	SetDlgItemText( IDC_BUTTON_PASTE , theApp.Translate( "ID3v2Page3", "Item2" ) );

	if( m_strPictureFile != "" )
	{
		LoadBitmapFromBMPFile( m_strPictureFile, &m_hBitmap, &m_hPalette );
	}
	 
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
예제 #5
0
BOOL CID3v2Page3::LoadPicture(const char *strFilename)
{
	HBITMAP hBitmap;
	HPALETTE hPalette;

	if( LoadBitmapFromBMPFile( strFilename, &hBitmap, &hPalette ) )
	{
		if( m_hBitmap )
			::DeleteObject( m_hBitmap );
		m_hBitmap = hBitmap;

		if( m_hPalette )
			::DeleteObject( m_hPalette );
		m_hPalette = hPalette;

		Invalidate();
		UpdateWindow();
		m_strPictureFile = strFilename;
		return TRUE;
	}
	return FALSE;
}