Click here to Skip to main content
15,924,901 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Maximum value of unsigned long Pin
Michael Dunn29-May-02 17:52
sitebuilderMichael Dunn29-May-02 17:52 
GeneralRe: Maximum value of unsigned long Pin
Joaquín M López Muñoz29-May-02 19:59
Joaquín M López Muñoz29-May-02 19:59 
GeneralRe: Maximum value of unsigned long Pin
Michael Dunn29-May-02 20:24
sitebuilderMichael Dunn29-May-02 20:24 
GeneralRe: Maximum value of unsigned long Pin
Joaquín M López Muñoz29-May-02 21:52
Joaquín M López Muñoz29-May-02 21:52 
GeneralRe: Maximum value of unsigned long Pin
Mike Nordell1-Jun-02 0:54
Mike Nordell1-Jun-02 0:54 
GeneralRe: Maximum value of unsigned long Pin
Michael Dunn1-Jun-02 6:22
sitebuilderMichael Dunn1-Jun-02 6:22 
GeneralRe: Maximum value of unsigned long Pin
Mike Nordell1-Jun-02 7:57
Mike Nordell1-Jun-02 7:57 
GeneralCreate a bitmap file Pin
Francis B.29-May-02 8:36
Francis B.29-May-02 8:36 
I'm trying to create a bitmap file from a memory device context but the only thing I create is a complete white bitmap. Dead | X|

Here my code:
MyFunction()
{
         CClientDC dc(this); //dc of dialog
	CRect rectBF(0,0,450,450);
	CBitmap bmp, *poldbmp;
         CDC memdc;

         // Load the bitmap resource
         bmp.CreateCompatibleBitmap(&dc, 450, 450);

         // Create a compatible memory DC
         memdc.CreateCompatibleDC( &dc );
	
			 
         // Select the bitmap into the DC
         poldbmp = memdc.SelectObject( &bmp );
         //CGraphWnd was created by Paul Barvinko - <A HREF="http://www.codeproject.com/miscctrl/graph2d.asp">A 2D data visualisation class
</A>
	m_ctlGraphWnd.DrawGraphToDC(&memdc, rectBF); //Copy graph to DC

         memdc.SelectObject(poldbmp);

	CPalette palette;

         //Initialize palette
	if( dc.GetDeviceCaps(RASTERCAPS) & RC_PALETTE )
	{
		UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 256);
		LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
		pLP->palVersion = 0x300;

		pLP->palNumEntries = 
				GetSystemPaletteEntries( dc, 0, 255, pLP->palPalEntry );

		// Create the palette
		palette.CreatePalette( pLP );

		delete[] pLP;
	}

This code above works correctly. The graph was drawn in memdc.
         //Function was created by Zafir Anjum - <A HREF="http://www.codeguru.com/bitmap/ddb_to_dib.shtml">Converting DDB to DIB</A>
	HANDLE hDIB = DDBToDIB(bmp, BI_RGB, &palette);

	if( hDIB == NULL )
		return ;

         //Function was created by Zafir Anjum - <A HREF="http://www.codeguru.com/bitmap/bitmap_to_file.shtml">Writing a bitmap to a BMP file</A>
	WriteDIB(_T("graph.bmp"), hDIB);

	GlobalFree( hDIB );
}

I don't know why but operations done on memdc aren't reflected in CBitmap bmp.

Thanks in advance!
GeneralChange Font to the Default Printer! Pin
29-May-02 7:51
suss29-May-02 7:51 
GeneralEvery other letter Pin
Nnamdi Onyeyiri29-May-02 7:30
Nnamdi Onyeyiri29-May-02 7:30 
GeneralRe: Every other letter Pin
Nish Nishant29-May-02 8:04
sitebuilderNish Nishant29-May-02 8:04 
GeneralRe: Every other letter Pin
PJ Arends29-May-02 8:18
professionalPJ Arends29-May-02 8:18 
Generalconvert a CString to a char Pin
Nnamdi Onyeyiri29-May-02 7:14
Nnamdi Onyeyiri29-May-02 7:14 
GeneralRe: convert a CString to a char Pin
Lucky the code machine29-May-02 7:15
Lucky the code machine29-May-02 7:15 
GeneralRe: convert a CString to a char Pin
ed987129-May-02 7:17
ed987129-May-02 7:17 
GeneralRe: convert a CString to a char Pin
Martin Ziacek29-May-02 7:23
Martin Ziacek29-May-02 7:23 
GeneralRead / Write Registry Pin
Lucky the code machine29-May-02 7:08
Lucky the code machine29-May-02 7:08 
GeneralRe: Read / Write Registry Pin
Martin Ziacek29-May-02 7:19
Martin Ziacek29-May-02 7:19 
GeneralRe: Read / Write Registry Pin
Lucky the code machine29-May-02 7:17
Lucky the code machine29-May-02 7:17 
GeneralRe: Read / Write Registry Pin
Martin Ziacek29-May-02 7:28
Martin Ziacek29-May-02 7:28 
GeneralRe: Read / Write Registry Pin
Lucky the code machine30-May-02 2:15
Lucky the code machine30-May-02 2:15 
GeneralRe: Read / Write Registry Pin
Martin Ziacek29-May-02 7:31
Martin Ziacek29-May-02 7:31 
GeneralRe: Read / Write Registry Pin
Lucky the code machine29-May-02 7:29
Lucky the code machine29-May-02 7:29 
GeneralWindow Programming (Saving Results) Pin
29-May-02 7:01
suss29-May-02 7:01 
GeneralRe: Window Programming (Saving Results) Pin
Nish Nishant29-May-02 7:02
sitebuilderNish Nishant29-May-02 7:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.