I created a java server that takes screenshots, resizes them and sends them over TCP / IP to my iPhone application. The application then uses NSInputStream to collect incoming image data, create an instance of NSMutableData with a byte buffer, and create an UIImage object to display on the iPhone. Screenshots, in fact. My iPhone code for collecting image data currently looks like this:
- (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent{
if(streamEvent == NSStreamEventHasBytesAvailable && [iStream hasBytesAvailable]){
uint8_t buffer[1024];
while([iStream hasBytesAvailable]){
NSLog(@"New Data");
int len = [iStream read:buffer maxLength:sizeof(buffer)];
[imgdata appendBytes:buffer length:len];
fullen=fullen+len;
if(buffer[len]=='FFD9'){
UIImage *img = [[UIImage alloc] initWithData:imgdata];
NSLog(@"NUMBER OF BYTES: %u", len);
image.image = img;
}
}
}
}
, , , NSMutableData UIImage. , JPEG - (EOI) (FFD9) - , . ? - , , JPEG, !