Click here to Skip to main content
15,892,643 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: parsing bitmap files (2) Pin
leon de boer15-Mar-20 0:25
leon de boer15-Mar-20 0:25 
AnswerRe: parsing bitmap files (2) Pin
Calin Negru15-Mar-20 1:59
Calin Negru15-Mar-20 1:59 
Questionc libraries needed to deal with bitmaps Pin
Calin Negru11-Mar-20 6:59
Calin Negru11-Mar-20 6:59 
AnswerRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan11-Mar-20 7:44
mveRichard MacCutchan11-Mar-20 7:44 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru11-Mar-20 9:49
Calin Negru11-Mar-20 9:49 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru11-Mar-20 21:51
Calin Negru11-Mar-20 21:51 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan11-Mar-20 22:35
mveRichard MacCutchan11-Mar-20 22:35 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru11-Mar-20 23:27
Calin Negru11-Mar-20 23:27 
here is my code

StringCchPrintfA(pszFilename,1024,"hello.bmp");
	// Attempt to open the Dib file for reading.
	if( !cf.Open( pszFilename, CFile::modeRead ) )
	{
		StringCchPrintfA(message,1024,"error reading file");
		MessageBox(NULL, message, "Textures.exe", MB_OK);
		return( FALSE );
	}
		

	// Get the size of the file and store
	// in a local variable. Subtract the
	// size of the BITMAPFILEHEADER structure
	// since we won't keep that in memory.
	DWORD dwDibSize= cf.GetLength() - sizeof( BITMAPFILEHEADER );
	int bsize =0;
	//dwDibSize =
	bsize=	cf.GetLength() - sizeof( BITMAPFILEHEADER );
	StringCchPrintfA(message,1024,"bitmap size  %d",bsize);
	MessageBox(NULL, message, "Textures.exe", MB_OK);

	// Attempt to allocate the Dib memory.
	unsigned char *pDib;
	pDib = new unsigned char [dwDibSize];
	if( pDib == NULL )
	{
			StringCchPrintfA(message,1024,"error allocating array ");
				MessageBox(NULL, message, "Textures.exe", MB_OK);
				return( FALSE );
	}
		

	BITMAPFILEHEADER BFH;

	// Read in the Dib header and data.
	try{

		// Did we read in the entire BITMAPFILEHEADER?
		if( cf.Read( &BFH, sizeof( BITMAPFILEHEADER ) )
			!= sizeof( BITMAPFILEHEADER ) ||

			// Is the type 'MB'?
			BFH.bfType != 'MB' ||

			// Did we read in the remaining data?
			cf.Read( pDib, dwDibSize ) != dwDibSize )
			{
				StringCchPrintfA(message,1024,"error processing the file ");
				MessageBox(NULL, message, "Textures.exe", MB_OK);
			// Delete the memory if we had any
			// errors and return FALSE.
			delete [] pDib;
			return( FALSE );
			}
		}


modified 12-Mar-20 8:41am.

GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan11-Mar-20 23:36
mveRichard MacCutchan11-Mar-20 23:36 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru12-Mar-20 0:18
Calin Negru12-Mar-20 0:18 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan12-Mar-20 2:31
mveRichard MacCutchan12-Mar-20 2:31 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru12-Mar-20 4:40
Calin Negru12-Mar-20 4:40 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan12-Mar-20 5:10
mveRichard MacCutchan12-Mar-20 5:10 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru13-Mar-20 3:22
Calin Negru13-Mar-20 3:22 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan13-Mar-20 4:22
mveRichard MacCutchan13-Mar-20 4:22 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru13-Mar-20 7:50
Calin Negru13-Mar-20 7:50 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan13-Mar-20 8:07
mveRichard MacCutchan13-Mar-20 8:07 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru13-Mar-20 21:07
Calin Negru13-Mar-20 21:07 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan13-Mar-20 23:04
mveRichard MacCutchan13-Mar-20 23:04 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru14-Mar-20 3:30
Calin Negru14-Mar-20 3:30 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan14-Mar-20 3:47
mveRichard MacCutchan14-Mar-20 3:47 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru14-Mar-20 7:11
Calin Negru14-Mar-20 7:11 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan14-Mar-20 7:13
mveRichard MacCutchan14-Mar-20 7:13 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru14-Mar-20 8:18
Calin Negru14-Mar-20 8:18 
GeneralRe: c libraries needed to deal with bitmaps Pin
phil.o14-Mar-20 8:37
professionalphil.o14-Mar-20 8:37 

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.