2017-02-08 4 views
1
unsigned char *ImgBytes = [ImgBytes stringByAppendingString:getStringForImage:imageView.image]; 

Fehler Bad Empfängertyp Unsigned charConvert Bild Bytes in Objective c

+0

prüfen diese http://stackoverflow.com/questions/7289150/uiimage-to-byte-array – kb920

+0

Mögliche Duplikat [UIImage to Byte-Array] (http://stackoverflow.com/questions/7289150/uiimage-to-byte-array) –

Antwort

0
NSString *ImgBytes; 
ImgBytes=[ImgBytes stringByAppendingString:[self getStringForImage:imageView.image]]; 

ImgBytes=[ImgBytes stringByAppendingString:[NSString stringWithFormat:@"^%@",q]]; 

-(NSString*)getStringForImage:(UIImage*)img 
{ 
    @try { 
     NSData *data = UIImagePNGRepresentation(img); 
     NSUInteger len = data.length; 
     uint8_t bytes = (uint8_t)[data bytes]; 
     NSMutableString *result = [NSMutableString stringWithCapacity:len]; 
     for (NSUInteger i = 0; i < len; i++) { 
      if (i) { 
       [result appendString:@","]; 
      } 
      [result appendFormat:@"%d",bytes]; 
     } 
     return result; 
    } @catch (NSException * e) { 
     NSLog(@"Exception: %@", e); 
    } 
    @finally { 
     NSLog(@"finally"); 
    } 
}