Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-30-2009, 08:36 PM   #1 (permalink)
urip
Registered Member
 
Join Date: Aug 2008
Posts: 17
Question loading bytes from file

I'm experiencing some weird problem.
I've created a file, 2400 bytes long. Each bit in those bytes represents a (white/black) pixel.
I load the file like this:
Code:
NSData *data = [NSData dataWithContentsOfFile:path];
Byte *byteData = (Byte*)malloc([data length]);
memcpy(byteData, [data bytes], i);
but for some reason, the bytes are scrambled... I can't really identify the pattern of that disruption.
I've created the file in windows using C# and wrote it into a file using File.WriteAllBytes(). I analyzed it using C# too, and it was OK there.
Any ideas why it isn't OK in Objective C/Mac? Is there a difference in the way Mac and Windows read bytes?
or maybe NSData inserts some of its own bytes into the file's bytes?

thanks
urip is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,261
Threads: 39,058
Posts: 171,278
Top Poster: smasher (2,575)
Welcome to our newest member, SomeRandomNerd
Powered by vBadvanced CMPS v3.1.0

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