Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

Graves Robber
($1.99)

African Adventure
($0.99)

iTazer
($0.99)

ArtStudio
($3.99)

Pigs Vs Wolves
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-01-2009, 10:16 AM   #5 (permalink)
urip
Registered Member
 
Join Date: Aug 2008
Posts: 17
Default

Quote:
Originally Posted by Kalimba View Post
Code:
NSData *data = [NSData dataWithContentsOfFile:path];
Byte *byteData = (Byte*)malloc([data length]);
memcpy(byteData, [data bytes], i);
What is the variable 'i' set to in the memcpy call? Does stepping through the code in the debugger glean any useful information?
Oh, sorry, the variable 'i' contains the [data length] value, which in this specific case is 2400.
The only thing I could tell from stepping through the code is that the problem is in the data I get from the file or in the way I access it (and not in the way I draw it to the screen).

Quote:
Originally Posted by Kalimba View Post
It just occurred to me that maybe it's an endian issue you're seeing.
as far as I know, endian is only the way the system interpret two or more bytes into numbers. So if for example I have two bytes:
00110110 11110000
these bits will stay the same no matter what endian is used, and the only thing changed would be the number represented by those two bytes. So I can't really see how it would change anything for me since I'm reading the file as separate bytes and not as full integers. Am I wrong?
Maybe it's something in the way I access the bits?
Code:
NSInteger byteIndex = requestedBitIndex / 8;
NSInteger bitIndexInByte = requestedBitIndex & 7;		//the bit index (0-7) in the byte
NSInteger mask = 128 >> bitIndexInByte;	//I read the bits from left to right so I take the binary number 10000000 and roll it bitIndex times to the right
if(byteData[byteIndex] & mask != 0)
	return YES;
else
	return NO;
This is how I access the bits. is there something wrong here? does the endian change anything in here?

is there another reason why the data is scrambled?

thanks again

Last edited by urip; 07-01-2009 at 11:04 AM.
urip is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,659
Threads: 38,415
Posts: 168,799
Top Poster: smasher (2,540)
Welcome to our newest member, suwimol
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.