Click here to Skip to main content
15,920,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DLLs: conceptual questions Pin
Mike Burston25-Sep-01 12:32
Mike Burston25-Sep-01 12:32 
GeneralThanks! It looks really useful Pin
Stephen Wilson25-Sep-01 13:02
Stephen Wilson25-Sep-01 13:02 
GeneralRe: Thanks! It looks really useful Pin
Mike Burston25-Sep-01 14:31
Mike Burston25-Sep-01 14:31 
GeneralCFindAndReplace Dialog Pin
25-Sep-01 8:33
suss25-Sep-01 8:33 
Generalaccessing adressbar of IE Pin
25-Sep-01 7:06
suss25-Sep-01 7:06 
QuestionHow do I access individual bits? Pin
Craig Miller25-Sep-01 6:42
Craig Miller25-Sep-01 6:42 
AnswerRe: How do I access individual bits? Pin
Chris Losinger25-Sep-01 6:58
professionalChris Losinger25-Sep-01 6:58 
GeneralRe: How do I access individual bits? Pin
Craig Miller26-Sep-01 8:16
Craig Miller26-Sep-01 8:16 
Chris,

Thanks for the reply. I tried pretty much all day yesterday to get this to work for my situation and was unsuccessful. I ended up doing something real slow and at I'm sure a VERY beginners level but I got it to work. I was wondering if you could take a look and tell me if there is a way to optimize it at all. Following is the code that I'm using:
//Now start reading in the scan lines
//Start at the beginning of the bitmap data
//file is a CFile containing the entire bitmap
file.SeekToBegin();

//pbmih is a valid BITMAPINFOHEADER*	
int scanLine = 4 * ((pbmih->biWidth * pbmih->biBitCount + 31) / 32);
BYTE* buffer = new BYTE[scanLine];	
int bytesread;

//hdr is a valid BITMAPFILEHEADER	
file.Seek(hdr.bfOffBits, 0);
	
FILE* output;
output  = fopen( "..\\images\\output.txt", "a+" );
fclose(output);
bytesread = file.Read(buffer, scanLine);

CString strOut;

while(bytesread)
{
	int arrayBytes[8];
	for (int ff=0;ff<8;ff++)
		arrayBytes[ff]=0;
	strOut.Empty();

	for(int x = 0; x < scanLine; x++)
	{			
		BYTE inByte = buffer[x];
		for (int ff=0;ff<8;ff++)
			arrayBytes[ff]=0;
			
		BYTE byteone;
		BYTE bytetwo;
		byteone = inByte >> 4;
		bytetwo = inByte << 4;
		bytetwo = bytetwo >> 4;

		switch (byteone)
		{
		case 0x1:
			arrayBytes[4]=1;
			break;
		case 0x2:
			arrayBytes[5]=1;
			break;
		case 0x3:
			arrayBytes[4]=1;
			arrayBytes[5]=1;
			break;
		case 0x4:
			arrayBytes[6]=1;
			break;
		case 0x5:
			arrayBytes[4]=1;
			arrayBytes[6]=1;
			break;
		case 0x6:
			arrayBytes[5]=1;
			arrayBytes[6]=1;
			break;
		case 0x7:
			arrayBytes[4]=1;
			arrayBytes[5]=1;
			arrayBytes[6]=1;
			break;
		case 0x8:
			arrayBytes[7]=1;
			break;
		case 0x9:
			arrayBytes[4]=1;
			arrayBytes[7]=1;
			break;
		case 0xA:
			arrayBytes[5]=1;
			arrayBytes[7]=1;
			break;
		case 0xB:
			arrayBytes[4]=1;
			arrayBytes[5]=1;
			arrayBytes[7]=1;
			break;
		case 0xC:
			arrayBytes[6]=1;
			arrayBytes[7]=1;
			break;
		case 0xD:
			arrayBytes[4]=1;
			arrayBytes[6]=1;
			arrayBytes[7]=1;
			break;
		case 0xE:
			arrayBytes[5]=1;
			arrayBytes[6]=1;
			arrayBytes[7]=1;
			break;
		case 0xF:
			arrayBytes[4]=1;
			arrayBytes[5]=1;
			arrayBytes[6]=1;
			arrayBytes[7]=1;
		default:
			;
		}
			
		switch (bytetwo)
		{
		case 0x1:
			arrayBytes[0]=1;
			break;
		case 0x2:
			arrayBytes[1]=1;
			break;
		case 0x3:
			arrayBytes[0]=1;
			arrayBytes[1]=1;
			break;
		case 0x4:
			arrayBytes[2]=1;
			break;
		case 0x5:
			arrayBytes[0]=1;
			arrayBytes[2]=1;
			break;
		case 0x6:
			arrayBytes[1]=1;
			arrayBytes[2]=1;
			break;
		case 0x7:
			arrayBytes[0]=1;
			arrayBytes[1]=1;
			arrayBytes[2]=1;
			break;
		case 0x8:
			arrayBytes[3]=1;
			break;
		case 0x9:
			arrayBytes[0]=1;
			arrayBytes[3]=1;
			break;
		case 0xA:
			arrayBytes[1]=1;
			arrayBytes[3]=1;
			break;
		case 0xB:
			arrayBytes[0]=1;
			arrayBytes[1]=1;
			arrayBytes[3]=1;
			break;
		case 0xC:
			arrayBytes[2]=1;
			arrayBytes[3]=1;
			break;
		case 0xD:
			arrayBytes[0]=1;
			arrayBytes[2]=1;
			arrayBytes[3]=1;
			break;
		case 0xE:
			arrayBytes[1]=1;
			arrayBytes[2]=1;
			arrayBytes[3]=1;
			break;
		case 0xF:
			arrayBytes[0]=1;
			arrayBytes[1]=1;
			arrayBytes[2]=1;
			arrayBytes[3]=1;
			break;
		default:
			;
		}

		for (int z=7;z>=0; z--)
		{
			char buf[10];
			itoa(arrayBytes[z], buf, 10);
			buf[1]='\0';
			output  = fopen( "..\\images\\output.txt", "a+" );
			fseek(output, 0L, SEEK_END );
			fprintf(output, "%s", buf);
			fclose(output);
		}
	}

	output  = fopen( "..\\images\\output.txt", "a+" );
	fseek(output, 0L, SEEK_END );
	fprintf(output, "\n");
	fclose(output);
	bytesread = file.Read(buffer, scanLine);
}

fclose(output);
delete buffer;

delete pbmih;
file.Close();


Thanks for any insight you can provide,

Craig
AnswerRe: How do I access individual bits? Pin
User 988525-Sep-01 11:10
User 988525-Sep-01 11:10 
GeneralDirectShow (again) Pin
#realJSOP25-Sep-01 6:40
professional#realJSOP25-Sep-01 6:40 
GeneralNeed a link to article Pin
25-Sep-01 6:36
suss25-Sep-01 6:36 
GeneralRe: Need a link to article Pin
Michael Dunn25-Sep-01 16:59
sitebuilderMichael Dunn25-Sep-01 16:59 
GeneralWTL windows and unchanging cursors Pin
The Arabundi25-Sep-01 6:05
The Arabundi25-Sep-01 6:05 
GeneralRe: WTL windows and unchanging cursors Pin
Tim Smith25-Sep-01 6:33
Tim Smith25-Sep-01 6:33 
GeneralRe: WTL windows and unchanging cursors Pin
The Arabundi25-Sep-01 9:05
The Arabundi25-Sep-01 9:05 
GeneralTab order question Pin
RobJones25-Sep-01 5:51
RobJones25-Sep-01 5:51 
GeneralRe: Tab order question Pin
RobJones25-Sep-01 7:01
RobJones25-Sep-01 7:01 
GeneralRe: Tab order question Pin
Paolo Messina26-Sep-01 0:46
professionalPaolo Messina26-Sep-01 0:46 
GeneralRe: Tab order question Pin
RobJones26-Sep-01 4:39
RobJones26-Sep-01 4:39 
QuestionHow can I (programatically) scroll the client area derived from CHtmlView. Pin
Umar Riaz25-Sep-01 5:33
Umar Riaz25-Sep-01 5:33 
QuestionDebugging multi-threaded apps in VS IDE? Pin
jbay@nebs.com25-Sep-01 5:20
jbay@nebs.com25-Sep-01 5:20 
AnswerRe: Debugging multi-threaded apps in VS IDE? Pin
Jeremy Pullicino25-Sep-01 22:12
Jeremy Pullicino25-Sep-01 22:12 
Generalcontextmenu on treeviewctrl in wtl Pin
Steffen25-Sep-01 5:03
Steffen25-Sep-01 5:03 
GeneralRe: contextmenu on treeviewctrl in wtl Pin
25-Sep-01 8:12
suss25-Sep-01 8:12 
GeneralRe: contextmenu on treeviewctrl in wtl Pin
25-Sep-01 21:37
suss25-Sep-01 21: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.